From ab4d24f3b5ae40cd9e3719d4e349aa1286f8e48e Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 31 Aug 2021 21:59:35 +1200 Subject: [PATCH 001/118] Realtime snapshot --- README.md | 12 +- build.gradle | 2 +- docs/examples/java/account/get-session.md | 48 - docs/examples/kotlin/account/get-session.md | 26 - library/build.gradle | 19 +- library/src/main/java/io/appwrite/Client.kt | 57 +- .../extensions/CollectionExtensions.kt | 12 + .../io/appwrite/extensions/JsonExtensions.kt | 34 +- .../java/io/appwrite/models/RealtimeModels.kt | 31 + .../main/java/io/appwrite/services/Account.kt | 37 +- .../main/java/io/appwrite/services/Avatars.kt | 2 +- .../java/io/appwrite/services/Database.kt | 159 ++- .../java/io/appwrite/services/Functions.kt | 354 +++++- .../main/java/io/appwrite/services/Health.kt | 275 +++++ .../main/java/io/appwrite/services/Locale.kt | 2 +- .../java/io/appwrite/services/Projects.kt | 1016 +++++++++++++++++ .../java/io/appwrite/services/Realtime.kt | 174 +++ .../services/{BaseService.kt => Service.kt} | 2 +- .../main/java/io/appwrite/services/Storage.kt | 5 +- .../main/java/io/appwrite/services/Teams.kt | 2 +- .../main/java/io/appwrite/services/Users.kt | 303 +++++ 21 files changed, 2428 insertions(+), 144 deletions(-) delete mode 100644 docs/examples/java/account/get-session.md delete mode 100644 docs/examples/kotlin/account/get-session.md create mode 100644 library/src/main/java/io/appwrite/extensions/CollectionExtensions.kt create mode 100644 library/src/main/java/io/appwrite/models/RealtimeModels.kt create mode 100644 library/src/main/java/io/appwrite/services/Health.kt create mode 100644 library/src/main/java/io/appwrite/services/Projects.kt create mode 100644 library/src/main/java/io/appwrite/services/Realtime.kt rename library/src/main/java/io/appwrite/services/{BaseService.kt => Service.kt} (50%) create mode 100644 library/src/main/java/io/appwrite/services/Users.kt diff --git a/README.md b/README.md index 66da83e..fd4990d 100644 --- a/README.md +++ b/README.md @@ -2,16 +2,16 @@ ![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-0.9.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-0.8.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_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 0.9.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).** +**This SDK is compatible with Appwrite server version 0.10.x. For older versions, please check previous releases.** -Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Android SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) +Appwrite 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 Flutter 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 -![Appwrite](https://appwrite.io/images/github.png) +![Appwrite](https://appwrite.io/v1/images/console.png) ## Installation @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:0.0.1") +implementation("io.appwrite:sdk-for-android:0.2.0-SNAPSHOT") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 0.0.1 + 0.2.0-SNAPSHOT ``` diff --git a/build.gradle b/build.gradle index ee004cf..6e75fcc 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,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.4.31" - version '0.0.1' + version '0.2.0-SNAPSHOT' repositories { maven { url "https://plugins.gradle.org/m2/" } google() diff --git a/docs/examples/java/account/get-session.md b/docs/examples/java/account/get-session.md deleted file mode 100644 index 8d4c95a..0000000 --- a/docs/examples/java/account/get-session.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.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.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 diff --git a/docs/examples/kotlin/account/get-session.md b/docs/examples/kotlin/account/get-session.md deleted file mode 100644 index 45f00b6..0000000 --- a/docs/examples/kotlin/account/get-session.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.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.getSession( - sessionId = "[SESSION_ID]" - ) - val json = response.body?.string() - } - } -} \ No newline at end of file diff --git a/library/build.gradle b/library/build.gradle index d5e9a7c..87899c6 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -7,11 +7,11 @@ plugins { ext { PUBLISH_GROUP_ID = 'io.appwrite' PUBLISH_ARTIFACT_ID = 'sdk-for-android' - PUBLISH_VERSION = '0.0.1' + PUBLISH_VERSION = '0.2.0-SNAPSHOT' POM_URL = 'https://github.com/appwrite/sdk-for-android' POM_SCM_URL = 'https://github.com/appwrite/sdk-for-android' POM_ISSUE_URL = 'https://github.com/appwrite/sdk-for-android/issues' - POM_DESCRIPTION = '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)' + POM_DESCRIPTION = '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 Flutter 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' POM_LICENSE_URL = 'https://opensource.org/licenses/GPL-3.0' POM_LICENSE_NAME = "GPL-3.0" POM_DEVELOPER_ID = 'appwrite' @@ -53,8 +53,8 @@ android { dependencies { implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${KotlinCompilerVersion.VERSION}") - api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3") - api("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3") + api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1") + api("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0") api(platform("com.squareup.okhttp3:okhttp-bom:4.9.0")) api("com.squareup.okhttp3:okhttp") @@ -65,15 +65,16 @@ dependencies { implementation("net.gotev:cookie-store:1.3.5") implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.3.1") implementation("androidx.lifecycle:lifecycle-common-java8:2.3.1") - implementation("androidx.appcompat:appcompat:1.2.0") - implementation("androidx.fragment:fragment-ktx:1.3.2") - implementation("androidx.activity:activity-ktx:1.2.2") + 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") testImplementation 'junit:junit:4.+' - testImplementation "androidx.test.ext:junit-ktx:1.1.2" - testImplementation "androidx.test:core-ktx:1.3.0" + 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") } 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 e15f2a5..be66506 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -5,8 +5,7 @@ import android.content.pm.PackageManager import com.google.gson.Gson import io.appwrite.appwrite.BuildConfig import io.appwrite.exceptions.AppwriteException -import io.appwrite.extensions.JsonExtensions.fromJson -import io.appwrite.models.Error +import io.appwrite.extensions.fromJson import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -36,6 +35,7 @@ import kotlin.coroutines.resume class Client @JvmOverloads constructor( context: Context, var endPoint: String = "https://appwrite.io/v1", + var endPointRealtime: String? = null, private var selfSigned: Boolean = false ) : CoroutineScope { @@ -71,7 +71,7 @@ class Client @JvmOverloads constructor( "origin" to "appwrite-android://${context.packageName}", "user-agent" to "${context.packageName}/${appVersion}, ${System.getProperty("http.agent")}", "x-sdk-version" to "appwrite:android:${BuildConfig.SDK_VERSION}", - "x-appwrite-response-format" to "0.9.0" + "x-appwrite-response-format" to "0.10.0" ) config = mutableMapOf() @@ -93,6 +93,21 @@ class Client @JvmOverloads constructor( return this } + /** + * Set Key + * + * Your secret API key + * + * @param {string} key + * + * @return this + */ + fun setKey(value: String): Client { + config["key"] = value + addHeader("x-appwrite-key", value) + return this + } + /** * Set JWT * @@ -121,6 +136,19 @@ class Client @JvmOverloads constructor( return this } + /** + * Set Mode + * + * @param {string} mode + * + * @return this + */ + fun setMode(value: String): Client { + config["mode"] = value + addHeader("x-appwrite-mode", value) + return this + } + /** * Set self Signed * @@ -171,7 +199,7 @@ class Client @JvmOverloads constructor( } /** - * Set endpoint + * Set endpoint and realtime endpoint. * * @param endpoint * @@ -179,6 +207,23 @@ class Client @JvmOverloads constructor( */ fun setEndpoint(endPoint: String): Client { this.endPoint = endPoint + + if (this.endPointRealtime == null && endPoint.startsWith("http")) { + this.endPointRealtime = endPoint.replaceFirst("http", "ws") + } + + return this + } + + /** + * Set realtime endpoint + * + * @param endpoint + * + * @return this + */ + fun setEndpointRealtime(endPoint: String): Client { + this.endPointRealtime = endPoint return this } @@ -317,9 +362,9 @@ class Client @JvmOverloads constructor( val contentType: String = response.headers["content-type"] ?: "" val error = if (contentType.contains("application/json", ignoreCase = true)) { - bodyString.fromJson(Error::class.java) + bodyString.fromJson() } else { - Error(bodyString, response.code) + AppwriteException(bodyString, response.code) } it.cancel(AppwriteException( diff --git a/library/src/main/java/io/appwrite/extensions/CollectionExtensions.kt b/library/src/main/java/io/appwrite/extensions/CollectionExtensions.kt new file mode 100644 index 0000000..a92704f --- /dev/null +++ b/library/src/main/java/io/appwrite/extensions/CollectionExtensions.kt @@ -0,0 +1,12 @@ +package io.appwrite.extensions + +import kotlinx.coroutines.Dispatchers.IO +import kotlinx.coroutines.async +import kotlinx.coroutines.awaitAll +import kotlinx.coroutines.withContext + +suspend fun Collection.forEachAsync( + callback: suspend (T) -> Unit +) = withContext(IO) { + map { async { callback.invoke(it) } }.awaitAll() +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/extensions/JsonExtensions.kt b/library/src/main/java/io/appwrite/extensions/JsonExtensions.kt index 4cf0f4f..444a77d 100644 --- a/library/src/main/java/io/appwrite/extensions/JsonExtensions.kt +++ b/library/src/main/java/io/appwrite/extensions/JsonExtensions.kt @@ -2,11 +2,33 @@ package io.appwrite.extensions import com.google.gson.Gson -object JsonExtensions { +val gson = Gson() - fun Any.toJson(): String = - Gson().toJson(this) +fun Any.toJson(): String = + gson.toJson(this) - fun String.fromJson(clazz: Class): T = - Gson().fromJson(this, clazz) -} \ No newline at end of file +fun String.fromJson(clazz: Class): T = + gson.fromJson(this, clazz) + +inline fun String.fromJson(): T = + gson.fromJson(this, T::class.java) + +fun Any.jsonCast(to: Class): T = + toJson().fromJson(to) + +inline fun Any.jsonCast(): T = + toJson().fromJson(T::class.java) + +fun Any.tryJsonCast(to: Class): T? = try { + toJson().fromJson(to) +} catch (ex: Exception) { + ex.printStackTrace() + null +} + +inline fun Any.tryJsonCast(): T? = try { + toJson().fromJson(T::class.java) +} catch (ex: Exception) { + ex.printStackTrace() + null +} diff --git a/library/src/main/java/io/appwrite/models/RealtimeModels.kt b/library/src/main/java/io/appwrite/models/RealtimeModels.kt new file mode 100644 index 0000000..b4990c8 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/RealtimeModels.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +import java.io.Closeable + +data class RealtimeSubscription( + private val close: () -> Unit +) : Closeable { + override fun close() = close.invoke() +} + +data class RealtimeCallback( + val payloadClass: Class<*>, + val callback: (RealtimeResponseEvent<*>) -> Unit +) + +open class RealtimeResponse( + val type: String, + val data: Any +) + +data class RealtimeResponseEvent( + val event: String, + val channels: Collection, + val timestamp: Long, + var payload: T +) + +enum class RealtimeCode(val value: Int) { + POLICY_VIOLATION(1008), + UNKNOWN_ERROR(-1) +} \ 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 bad36e5..4cd0504 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -11,7 +11,7 @@ import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import java.io.File -class Account(private val client: Client) : BaseService(client) { +class Account(client: Client) : Service(client) { /** * Get Account @@ -134,8 +134,7 @@ class Account(private val client: Client) : BaseService(client) { * 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. + * from its creation and will be invalid if the user will logout. * * @return [Response] */ @@ -432,10 +431,9 @@ class Account(private val client: Client) : BaseService(client) { * * 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). + * allow the new user to convert an anonymous account to a normal account + * account, you need to update its [email and + * password](/docs/client/account#accountUpdateEmail). * * @return [Response] */ @@ -529,31 +527,6 @@ class Account(private val client: Client) : BaseService(client) { } - /** - * Get Session By ID - * - * 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 - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getSession( - sessionId: String - ): Response { - val path = "/account/sessions/{sessionId}".replace("{sessionId}", sessionId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - /** * Delete Account Session * diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt index b828eb0..3e0432f 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -9,7 +9,7 @@ import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import java.io.File -class Avatars(private val client: Client) : BaseService(client) { +class Avatars(client: Client) : Service(client) { /** * Get Browser Icon diff --git a/library/src/main/java/io/appwrite/services/Database.kt b/library/src/main/java/io/appwrite/services/Database.kt index 81bf0c6..fc7fc9b 100644 --- a/library/src/main/java/io/appwrite/services/Database.kt +++ b/library/src/main/java/io/appwrite/services/Database.kt @@ -7,8 +7,165 @@ import okhttp3.Cookie import okhttp3.Response import java.io.File -class Database(private val client: Client) : BaseService(client) { +class Database(client: Client) : Service(client) { + /** + * List Collections + * + * Get a list of all the user collections. 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 collections. [Learn more about different API + * modes](/docs/admin). + * + * @param search + * @param limit + * @param offset + * @param orderType + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun listCollections( + search: String? = null, + limit: Int? = null, + offset: Int? = null, + orderType: String? = null + ): Response { + val path = "/database/collections" + val params = mapOf( + "search" to search, + "limit" to limit, + "offset" to offset, + "orderType" to orderType + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Create Collection + * + * Create a new Collection. + * + * @param name + * @param read + * @param write + * @param rules + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createCollection( + name: String, + read: List, + write: List, + rules: List + ): Response { + val path = "/database/collections" + val params = mapOf( + "name" to name, + "read" to read, + "write" to write, + "rules" to rules + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("POST", path, headers, params) + } + + /** + * Get Collection + * + * Get a collection by its unique ID. This endpoint response returns a JSON + * object with the collection metadata. + * + * @param collectionId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getCollection( + collectionId: String + ): Response { + val path = "/database/collections/{collectionId}".replace("{collectionId}", collectionId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Update Collection + * + * Update a collection by its unique ID. + * + * @param collectionId + * @param name + * @param read + * @param write + * @param rules + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updateCollection( + collectionId: String, + name: String, + read: List? = null, + write: List? = null, + rules: List? = null + ): Response { + val path = "/database/collections/{collectionId}".replace("{collectionId}", collectionId) + val params = mapOf( + "name" to name, + "read" to read, + "write" to write, + "rules" to rules + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("PUT", path, headers, params) + } + + /** + * Delete Collection + * + * Delete a collection by its unique ID. Only users with write permissions + * have access to delete this resource. + * + * @param collectionId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun deleteCollection( + collectionId: String + ): Response { + val path = "/database/collections/{collectionId}".replace("{collectionId}", collectionId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("DELETE", path, headers, params) + } + /** * List Documents * diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index 95c203c..fba3eba 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -7,8 +7,178 @@ import okhttp3.Cookie import okhttp3.Response import java.io.File -class Functions(private val client: Client) : BaseService(client) { +class Functions(client: Client) : Service(client) { + /** + * List Functions + * + * Get a list of all the project's functions. You can use the query params to + * filter your results. + * + * @param search + * @param limit + * @param offset + * @param orderType + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun list( + search: String? = null, + limit: Int? = null, + offset: Int? = null, + orderType: String? = null + ): Response { + val path = "/functions" + val params = mapOf( + "search" to search, + "limit" to limit, + "offset" to offset, + "orderType" to orderType + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Create Function + * + * Create a new function. You can pass a list of + * [permissions](/docs/permissions) to allow different project users or team + * with access to execute the function using the client API. + * + * @param name + * @param execute + * @param env + * @param vars + * @param events + * @param schedule + * @param timeout + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun create( + name: String, + execute: List, + env: String, + vars: Any? = null, + events: List? = null, + schedule: String? = null, + timeout: Int? = null + ): Response { + val path = "/functions" + val params = mapOf( + "name" to name, + "execute" to execute, + "env" to env, + "vars" to vars, + "events" to events, + "schedule" to schedule, + "timeout" to timeout + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("POST", path, headers, params) + } + + /** + * Get Function + * + * Get a function by its unique ID. + * + * @param functionId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun get( + functionId: String + ): Response { + val path = "/functions/{functionId}".replace("{functionId}", functionId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Update Function + * + * Update function by its unique ID. + * + * @param functionId + * @param name + * @param execute + * @param vars + * @param events + * @param schedule + * @param timeout + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun update( + functionId: String, + name: String, + execute: List, + vars: Any? = null, + events: List? = null, + schedule: String? = null, + timeout: Int? = null + ): Response { + val path = "/functions/{functionId}".replace("{functionId}", functionId) + val params = mapOf( + "name" to name, + "execute" to execute, + "vars" to vars, + "events" to events, + "schedule" to schedule, + "timeout" to timeout + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("PUT", path, headers, params) + } + + /** + * Delete Function + * + * Delete a function by its unique ID. + * + * @param functionId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun delete( + functionId: String + ): Response { + val path = "/functions/{functionId}".replace("{functionId}", functionId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("DELETE", path, headers, params) + } + /** * List Executions * @@ -104,4 +274,186 @@ class Functions(private val client: Client) : BaseService(client) { return client.call("GET", path, headers, params) } + /** + * Update Function Tag + * + * Update the function code tag ID using the unique function ID. Use this + * endpoint to switch the code tag that should be executed by the execution + * endpoint. + * + * @param functionId + * @param tag + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updateTag( + functionId: String, + tag: String + ): Response { + val path = "/functions/{functionId}/tag".replace("{functionId}", functionId) + val params = mapOf( + "tag" to tag + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("PATCH", path, headers, params) + } + + /** + * List Tags + * + * Get a list of all the project's code tags. You can use the query params to + * filter your results. + * + * @param functionId + * @param search + * @param limit + * @param offset + * @param orderType + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun listTags( + functionId: String, + search: String? = null, + limit: Int? = null, + offset: Int? = null, + orderType: String? = null + ): Response { + val path = "/functions/{functionId}/tags".replace("{functionId}", functionId) + val params = mapOf( + "search" to search, + "limit" to limit, + "offset" to offset, + "orderType" to orderType + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Create Tag + * + * Create a new function code tag. Use this endpoint to upload a new version + * of your code function. To execute your newly uploaded code, you'll need to + * update the function's tag to use your new tag UID. + * + * This endpoint accepts a tar.gz file compressed with your code. Make sure to + * include any dependencies your code has within the compressed file. You can + * learn more about code packaging in the [Appwrite Cloud Functions + * tutorial](/docs/functions). + * + * Use the "command" param to set the entry point used to execute your code. + * + * @param functionId + * @param command + * @param code + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createTag( + functionId: String, + command: String, + code: File + ): Response { + val path = "/functions/{functionId}/tags".replace("{functionId}", functionId) + val params = mapOf( + "command" to command, + "code" to code + ) + + val headers = mapOf( + "content-type" to "multipart/form-data" + ) + + return client.call("POST", path, headers, params) + } + + /** + * Get Tag + * + * Get a code tag by its unique ID. + * + * @param functionId + * @param tagId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getTag( + functionId: String, + tagId: String + ): Response { + val path = "/functions/{functionId}/tags/{tagId}".replace("{functionId}", functionId).replace("{tagId}", tagId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Delete Tag + * + * Delete a code tag by its unique ID. + * + * @param functionId + * @param tagId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun deleteTag( + functionId: String, + tagId: String + ): Response { + val path = "/functions/{functionId}/tags/{tagId}".replace("{functionId}", functionId).replace("{tagId}", tagId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("DELETE", path, headers, params) + } + + /** + * Get Function Usage + * + * @param functionId + * @param range + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getUsage( + functionId: String, + range: String? = null + ): Response { + val path = "/functions/{functionId}/usage".replace("{functionId}", functionId) + val params = mapOf( + "range" to range + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Health.kt b/library/src/main/java/io/appwrite/services/Health.kt new file mode 100644 index 0000000..cada8d5 --- /dev/null +++ b/library/src/main/java/io/appwrite/services/Health.kt @@ -0,0 +1,275 @@ +package io.appwrite.services + +import android.net.Uri +import io.appwrite.Client +import io.appwrite.exceptions.AppwriteException +import okhttp3.Cookie +import okhttp3.Response +import java.io.File + +class Health(client: Client) : Service(client) { + + /** + * Get HTTP + * + * Check the Appwrite HTTP server is up and responsive. + * + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun get(): Response { + val path = "/health" + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Get Anti virus + * + * Check the Appwrite Anti Virus server is up and connection is successful. + * + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getAntiVirus(): Response { + val path = "/health/anti-virus" + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Get Cache + * + * Check the Appwrite in-memory cache server is up and connection is + * successful. + * + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getCache(): Response { + val path = "/health/cache" + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Get DB + * + * Check the Appwrite database server is up and connection is successful. + * + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getDB(): Response { + val path = "/health/db" + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Get Certificate Queue + * + * Get the number of certificates that are waiting to be issued against + * [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue + * server. + * + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getQueueCertificates(): Response { + val path = "/health/queue/certificates" + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Get Functions Queue + * + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getQueueFunctions(): Response { + val path = "/health/queue/functions" + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Get Logs Queue + * + * Get the number of logs that are waiting to be processed in the Appwrite + * internal queue server. + * + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getQueueLogs(): Response { + val path = "/health/queue/logs" + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Get Tasks Queue + * + * Get the number of tasks that are waiting to be processed in the Appwrite + * internal queue server. + * + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getQueueTasks(): Response { + val path = "/health/queue/tasks" + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Get Usage Queue + * + * Get the number of usage stats that are waiting to be processed in the + * Appwrite internal queue server. + * + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getQueueUsage(): Response { + val path = "/health/queue/usage" + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Get Webhooks Queue + * + * Get the number of webhooks that are waiting to be processed in the Appwrite + * internal queue server. + * + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getQueueWebhooks(): Response { + val path = "/health/queue/webhooks" + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Get Local Storage + * + * Check the Appwrite local storage device is up and connection is successful. + * + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getStorageLocal(): Response { + val path = "/health/storage/local" + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Get Time + * + * Check the Appwrite server time is synced with Google remote NTP server. We + * use this technology to smoothly handle leap seconds with no disruptive + * events. The [Network Time + * Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is + * used by hundreds of millions of computers and devices to synchronize their + * clocks over the Internet. If your computer sets its own clock, it likely + * uses NTP. + * + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getTime(): Response { + val path = "/health/time" + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + +} \ 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 36a3fce..415df78 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -7,7 +7,7 @@ import okhttp3.Cookie import okhttp3.Response import java.io.File -class Locale(private val client: Client) : BaseService(client) { +class Locale(client: Client) : Service(client) { /** * Get User Locale diff --git a/library/src/main/java/io/appwrite/services/Projects.kt b/library/src/main/java/io/appwrite/services/Projects.kt new file mode 100644 index 0000000..e019a4e --- /dev/null +++ b/library/src/main/java/io/appwrite/services/Projects.kt @@ -0,0 +1,1016 @@ +package io.appwrite.services + +import android.net.Uri +import io.appwrite.Client +import io.appwrite.exceptions.AppwriteException +import okhttp3.Cookie +import okhttp3.Response +import java.io.File + +class Projects(client: Client) : Service(client) { + + /** + * List Projects + * + * @param search + * @param limit + * @param offset + * @param orderType + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun list( + search: String? = null, + limit: Int? = null, + offset: Int? = null, + orderType: String? = null + ): Response { + val path = "/projects" + val params = mapOf( + "search" to search, + "limit" to limit, + "offset" to offset, + "orderType" to orderType + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Create Project + * + * @param name + * @param teamId + * @param description + * @param logo + * @param url + * @param legalName + * @param legalCountry + * @param legalState + * @param legalCity + * @param legalAddress + * @param legalTaxId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun create( + name: String, + teamId: String, + description: String? = null, + logo: String? = null, + url: String? = null, + legalName: String? = null, + legalCountry: String? = null, + legalState: String? = null, + legalCity: String? = null, + legalAddress: String? = null, + legalTaxId: String? = null + ): Response { + val path = "/projects" + val params = mapOf( + "name" to name, + "teamId" to teamId, + "description" to description, + "logo" to logo, + "url" to url, + "legalName" to legalName, + "legalCountry" to legalCountry, + "legalState" to legalState, + "legalCity" to legalCity, + "legalAddress" to legalAddress, + "legalTaxId" to legalTaxId + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("POST", path, headers, params) + } + + /** + * Get Project + * + * @param projectId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun get( + projectId: String + ): Response { + val path = "/projects/{projectId}".replace("{projectId}", projectId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Update Project + * + * @param projectId + * @param name + * @param description + * @param logo + * @param url + * @param legalName + * @param legalCountry + * @param legalState + * @param legalCity + * @param legalAddress + * @param legalTaxId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun update( + projectId: String, + name: String, + description: String? = null, + logo: String? = null, + url: String? = null, + legalName: String? = null, + legalCountry: String? = null, + legalState: String? = null, + legalCity: String? = null, + legalAddress: String? = null, + legalTaxId: String? = null + ): Response { + val path = "/projects/{projectId}".replace("{projectId}", projectId) + val params = mapOf( + "name" to name, + "description" to description, + "logo" to logo, + "url" to url, + "legalName" to legalName, + "legalCountry" to legalCountry, + "legalState" to legalState, + "legalCity" to legalCity, + "legalAddress" to legalAddress, + "legalTaxId" to legalTaxId + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("PATCH", path, headers, params) + } + + /** + * Delete Project + * + * @param projectId + * @param password + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun delete( + projectId: String, + password: String + ): Response { + val path = "/projects/{projectId}".replace("{projectId}", projectId) + val params = mapOf( + "password" to password + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("DELETE", path, headers, params) + } + + /** + * Update Project users limit + * + * @param projectId + * @param limit + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updateAuthLimit( + projectId: String, + limit: String + ): Response { + val path = "/projects/{projectId}/auth/limit".replace("{projectId}", projectId) + val params = mapOf( + "limit" to limit + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("PATCH", path, headers, params) + } + + /** + * Update Project auth method status. Use this endpoint to enable or disable a given auth method for this project. + * + * @param projectId + * @param method + * @param status + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updateAuthStatus( + projectId: String, + method: String, + status: Boolean + ): Response { + val path = "/projects/{projectId}/auth/{method}".replace("{projectId}", projectId).replace("{method}", method) + val params = mapOf( + "status" to status + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("PATCH", path, headers, params) + } + + /** + * List Domains + * + * @param projectId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun listDomains( + projectId: String + ): Response { + val path = "/projects/{projectId}/domains".replace("{projectId}", projectId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Create Domain + * + * @param projectId + * @param domain + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createDomain( + projectId: String, + domain: String + ): Response { + val path = "/projects/{projectId}/domains".replace("{projectId}", projectId) + val params = mapOf( + "domain" to domain + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("POST", path, headers, params) + } + + /** + * Get Domain + * + * @param projectId + * @param domainId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getDomain( + projectId: String, + domainId: String + ): Response { + val path = "/projects/{projectId}/domains/{domainId}".replace("{projectId}", projectId).replace("{domainId}", domainId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Delete Domain + * + * @param projectId + * @param domainId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun deleteDomain( + projectId: String, + domainId: String + ): Response { + val path = "/projects/{projectId}/domains/{domainId}".replace("{projectId}", projectId).replace("{domainId}", domainId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("DELETE", path, headers, params) + } + + /** + * Update Domain Verification Status + * + * @param projectId + * @param domainId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updateDomainVerification( + projectId: String, + domainId: String + ): Response { + val path = "/projects/{projectId}/domains/{domainId}/verification".replace("{projectId}", projectId).replace("{domainId}", domainId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("PATCH", path, headers, params) + } + + /** + * List Keys + * + * @param projectId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun listKeys( + projectId: String + ): Response { + val path = "/projects/{projectId}/keys".replace("{projectId}", projectId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Create Key + * + * @param projectId + * @param name + * @param scopes + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createKey( + projectId: String, + name: String, + scopes: List + ): Response { + val path = "/projects/{projectId}/keys".replace("{projectId}", projectId) + val params = mapOf( + "name" to name, + "scopes" to scopes + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("POST", path, headers, params) + } + + /** + * Get Key + * + * @param projectId + * @param keyId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getKey( + projectId: String, + keyId: String + ): Response { + val path = "/projects/{projectId}/keys/{keyId}".replace("{projectId}", projectId).replace("{keyId}", keyId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Update Key + * + * @param projectId + * @param keyId + * @param name + * @param scopes + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updateKey( + projectId: String, + keyId: String, + name: String, + scopes: List + ): Response { + val path = "/projects/{projectId}/keys/{keyId}".replace("{projectId}", projectId).replace("{keyId}", keyId) + val params = mapOf( + "name" to name, + "scopes" to scopes + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("PUT", path, headers, params) + } + + /** + * Delete Key + * + * @param projectId + * @param keyId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun deleteKey( + projectId: String, + keyId: String + ): Response { + val path = "/projects/{projectId}/keys/{keyId}".replace("{projectId}", projectId).replace("{keyId}", keyId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("DELETE", path, headers, params) + } + + /** + * Update Project OAuth2 + * + * @param projectId + * @param provider + * @param appId + * @param secret + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updateOAuth2( + projectId: String, + provider: String, + appId: String? = null, + secret: String? = null + ): Response { + val path = "/projects/{projectId}/oauth2".replace("{projectId}", projectId) + val params = mapOf( + "provider" to provider, + "appId" to appId, + "secret" to secret + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("PATCH", path, headers, params) + } + + /** + * List Platforms + * + * @param projectId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun listPlatforms( + projectId: String + ): Response { + val path = "/projects/{projectId}/platforms".replace("{projectId}", projectId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Create Platform + * + * @param projectId + * @param type + * @param name + * @param key + * @param store + * @param hostname + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createPlatform( + projectId: String, + type: String, + name: String, + key: String? = null, + store: String? = null, + hostname: String? = null + ): Response { + val path = "/projects/{projectId}/platforms".replace("{projectId}", projectId) + val params = mapOf( + "type" to type, + "name" to name, + "key" to key, + "store" to store, + "hostname" to hostname + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("POST", path, headers, params) + } + + /** + * Get Platform + * + * @param projectId + * @param platformId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getPlatform( + projectId: String, + platformId: String + ): Response { + val path = "/projects/{projectId}/platforms/{platformId}".replace("{projectId}", projectId).replace("{platformId}", platformId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Update Platform + * + * @param projectId + * @param platformId + * @param name + * @param key + * @param store + * @param hostname + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updatePlatform( + projectId: String, + platformId: String, + name: String, + key: String? = null, + store: String? = null, + hostname: String? = null + ): Response { + val path = "/projects/{projectId}/platforms/{platformId}".replace("{projectId}", projectId).replace("{platformId}", platformId) + val params = mapOf( + "name" to name, + "key" to key, + "store" to store, + "hostname" to hostname + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("PUT", path, headers, params) + } + + /** + * Delete Platform + * + * @param projectId + * @param platformId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun deletePlatform( + projectId: String, + platformId: String + ): Response { + val path = "/projects/{projectId}/platforms/{platformId}".replace("{projectId}", projectId).replace("{platformId}", platformId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("DELETE", path, headers, params) + } + + /** + * List Tasks + * + * @param projectId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun listTasks( + projectId: String + ): Response { + val path = "/projects/{projectId}/tasks".replace("{projectId}", projectId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Create Task + * + * @param projectId + * @param name + * @param status + * @param schedule + * @param security + * @param httpMethod + * @param httpUrl + * @param httpHeaders + * @param httpUser + * @param httpPass + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createTask( + projectId: String, + name: String, + status: String, + schedule: String, + security: Boolean, + httpMethod: String, + httpUrl: String, + httpHeaders: List? = null, + httpUser: String? = null, + httpPass: String? = null + ): Response { + val path = "/projects/{projectId}/tasks".replace("{projectId}", projectId) + val params = mapOf( + "name" to name, + "status" to status, + "schedule" to schedule, + "security" to security, + "httpMethod" to httpMethod, + "httpUrl" to httpUrl, + "httpHeaders" to httpHeaders, + "httpUser" to httpUser, + "httpPass" to httpPass + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("POST", path, headers, params) + } + + /** + * Get Task + * + * @param projectId + * @param taskId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getTask( + projectId: String, + taskId: String + ): Response { + val path = "/projects/{projectId}/tasks/{taskId}".replace("{projectId}", projectId).replace("{taskId}", taskId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Update Task + * + * @param projectId + * @param taskId + * @param name + * @param status + * @param schedule + * @param security + * @param httpMethod + * @param httpUrl + * @param httpHeaders + * @param httpUser + * @param httpPass + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updateTask( + projectId: String, + taskId: String, + name: String, + status: String, + schedule: String, + security: Boolean, + httpMethod: String, + httpUrl: String, + httpHeaders: List? = null, + httpUser: String? = null, + httpPass: String? = null + ): Response { + val path = "/projects/{projectId}/tasks/{taskId}".replace("{projectId}", projectId).replace("{taskId}", taskId) + val params = mapOf( + "name" to name, + "status" to status, + "schedule" to schedule, + "security" to security, + "httpMethod" to httpMethod, + "httpUrl" to httpUrl, + "httpHeaders" to httpHeaders, + "httpUser" to httpUser, + "httpPass" to httpPass + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("PUT", path, headers, params) + } + + /** + * Delete Task + * + * @param projectId + * @param taskId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun deleteTask( + projectId: String, + taskId: String + ): Response { + val path = "/projects/{projectId}/tasks/{taskId}".replace("{projectId}", projectId).replace("{taskId}", taskId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("DELETE", path, headers, params) + } + + /** + * Get Project + * + * @param projectId + * @param range + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getUsage( + projectId: String, + range: String? = null + ): Response { + val path = "/projects/{projectId}/usage".replace("{projectId}", projectId) + val params = mapOf( + "range" to range + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * List Webhooks + * + * @param projectId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun listWebhooks( + projectId: String + ): Response { + val path = "/projects/{projectId}/webhooks".replace("{projectId}", projectId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Create Webhook + * + * @param projectId + * @param name + * @param events + * @param url + * @param security + * @param httpUser + * @param httpPass + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createWebhook( + projectId: String, + name: String, + events: List, + url: String, + security: Boolean, + httpUser: String? = null, + httpPass: String? = null + ): Response { + val path = "/projects/{projectId}/webhooks".replace("{projectId}", projectId) + val params = mapOf( + "name" to name, + "events" to events, + "url" to url, + "security" to security, + "httpUser" to httpUser, + "httpPass" to httpPass + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("POST", path, headers, params) + } + + /** + * Get Webhook + * + * @param projectId + * @param webhookId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getWebhook( + projectId: String, + webhookId: String + ): Response { + val path = "/projects/{projectId}/webhooks/{webhookId}".replace("{projectId}", projectId).replace("{webhookId}", webhookId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Update Webhook + * + * @param projectId + * @param webhookId + * @param name + * @param events + * @param url + * @param security + * @param httpUser + * @param httpPass + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updateWebhook( + projectId: String, + webhookId: String, + name: String, + events: List, + url: String, + security: Boolean, + httpUser: String? = null, + httpPass: String? = null + ): Response { + val path = "/projects/{projectId}/webhooks/{webhookId}".replace("{projectId}", projectId).replace("{webhookId}", webhookId) + val params = mapOf( + "name" to name, + "events" to events, + "url" to url, + "security" to security, + "httpUser" to httpUser, + "httpPass" to httpPass + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("PUT", path, headers, params) + } + + /** + * Delete Webhook + * + * @param projectId + * @param webhookId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun deleteWebhook( + projectId: String, + webhookId: String + ): Response { + val path = "/projects/{projectId}/webhooks/{webhookId}".replace("{projectId}", projectId).replace("{webhookId}", webhookId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("DELETE", path, headers, params) + } + +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Realtime.kt b/library/src/main/java/io/appwrite/services/Realtime.kt new file mode 100644 index 0000000..cec1dad --- /dev/null +++ b/library/src/main/java/io/appwrite/services/Realtime.kt @@ -0,0 +1,174 @@ +package io.appwrite.services + +import io.appwrite.Client +import io.appwrite.exceptions.AppwriteException +import io.appwrite.extensions.forEachAsync +import io.appwrite.extensions.fromJson +import io.appwrite.extensions.jsonCast +import io.appwrite.models.* +import kotlinx.coroutines.* +import kotlinx.coroutines.Dispatchers.IO +import okhttp3.Request +import okhttp3.Response +import okhttp3.WebSocket +import okhttp3.WebSocketListener +import okhttp3.internal.concurrent.TaskRunner +import okhttp3.internal.ws.RealWebSocket +import java.util.* +import kotlin.coroutines.CoroutineContext + +class Realtime(client: Client) : Service(client), CoroutineScope { + + private val job = Job() + + override val coroutineContext: CoroutineContext + get() = Dispatchers.Main + job + + private companion object { + private const val TYPE_ERROR = "error" + private const val TYPE_EVENT = "event" + + private const val DEBOUNCE_MILLIS = 1L + + private var socket: RealWebSocket? = null + private var channelCallbacks = mutableMapOf>() + private var errorCallbacks = mutableSetOf<(AppwriteException) -> Unit>() + + private var subCallDepth = 0 + } + + private fun createSocket() { + val queryParamBuilder = StringBuilder() + .append("project=${client.config["project"]}") + + channelCallbacks.keys.forEach { + queryParamBuilder + .append("&channels[]=$it") + } + + val request = Request.Builder() + .url("${client.endPointRealtime}/realtime?$queryParamBuilder") + .build() + + if (socket != null) { + closeSocket() + } + + socket = RealWebSocket( + taskRunner = TaskRunner.INSTANCE, + originalRequest = request, + listener = AppwriteWebSocketListener(), + random = Random(), + pingIntervalMillis = client.http.pingIntervalMillis.toLong(), + extensions = null, + minimumDeflateSize = client.http.minWebSocketMessageToCompress + ) + + socket!!.connect(client.http) + } + + private fun closeSocket() { + socket?.close(RealtimeCode.POLICY_VIOLATION.value, null) + } + + fun subscribe( + vararg channels: String, + callback: (RealtimeResponseEvent) -> Unit, + ) = subscribe( + channels = channels, + Any::class.java, + callback + ) + + fun subscribe( + vararg channels: String, + payloadType: Class, + callback: (RealtimeResponseEvent) -> Unit, + ): RealtimeSubscription { + channels.forEach { + if (!channelCallbacks.containsKey(it)) { + channelCallbacks[it] = mutableListOf( + RealtimeCallback( + payloadType, + callback as (RealtimeResponseEvent<*>) -> Unit + ) + ) + return@forEach + } + channelCallbacks[it]?.add( + RealtimeCallback(payloadType, callback as (RealtimeResponseEvent<*>) -> Unit) + ) + } + + launch { + subCallDepth++ + delay(DEBOUNCE_MILLIS) + if (subCallDepth == 1) { + createSocket() + } + subCallDepth-- + } + + return RealtimeSubscription { unsubscribe(*channels) } + } + + fun unsubscribe(vararg channels: String) { + channels.forEach { + channelCallbacks[it] = mutableListOf() + } + if (channelCallbacks.all { it.value.isEmpty() }) { + errorCallbacks = mutableSetOf() + closeSocket() + } + } + + fun doOnError(callback: (AppwriteException) -> Unit) { + errorCallbacks.add(callback) + } + + private inner class AppwriteWebSocketListener : WebSocketListener() { + + override fun onMessage(webSocket: WebSocket, text: String) { + super.onMessage(webSocket, text) + + launch(IO) { + val message = text.fromJson() + when (message.type) { + TYPE_ERROR -> handleResponseError(message) + TYPE_EVENT -> handleResponseEvent(message) + } + } + } + + private fun handleResponseError(message: RealtimeResponse) { + val error = message.data.jsonCast() + errorCallbacks.forEach { it.invoke(error) } + } + + private suspend fun handleResponseEvent(message: RealtimeResponse) { + val event = message.data.jsonCast>() + event.channels.forEachAsync { channel -> + channelCallbacks[channel]?.forEachAsync { callbackWrapper -> + event.payload = event.payload.jsonCast(callbackWrapper.payloadClass) + callbackWrapper.callback.invoke(event) + } + } + } + + override fun onClosing(webSocket: WebSocket, code: Int, reason: String) { + super.onClosing(webSocket, code, reason) + if (code == RealtimeCode.POLICY_VIOLATION.value) { + return + } + launch { + delay(1000) + createSocket() + } + } + + override fun onFailure(webSocket: WebSocket, t: Throwable, response: Response?) { + super.onFailure(webSocket, t, response) + t.printStackTrace() + } + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/BaseService.kt b/library/src/main/java/io/appwrite/services/Service.kt similarity index 50% rename from library/src/main/java/io/appwrite/services/BaseService.kt rename to library/src/main/java/io/appwrite/services/Service.kt index 1d6df97..6a00fb1 100644 --- a/library/src/main/java/io/appwrite/services/BaseService.kt +++ b/library/src/main/java/io/appwrite/services/Service.kt @@ -2,4 +2,4 @@ package io.appwrite.services import io.appwrite.Client -abstract class BaseService(private val client: Client) +abstract class Service(val client: Client) diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index 6b053d0..c13a0a3 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -9,7 +9,7 @@ import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import java.io.File -class Storage(private val client: Client) : BaseService(client) { +class Storage(client: Client) : Service(client) { /** * List Files @@ -195,7 +195,6 @@ class Storage(private val client: Client) : BaseService(client) { * @param fileId * @param width * @param height - * @param gravity * @param quality * @param borderWidth * @param borderColor @@ -212,7 +211,6 @@ class Storage(private val client: Client) : BaseService(client) { fileId: String, width: Int? = null, height: Int? = null, - gravity: String? = null, quality: Int? = null, borderWidth: Int? = null, borderColor: String? = null, @@ -226,7 +224,6 @@ class Storage(private val client: Client) : BaseService(client) { val params = mapOf( "width" to width, "height" to height, - "gravity" to gravity, "quality" to quality, "borderWidth" to borderWidth, "borderColor" to borderColor, diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 8e14663..873de7d 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -7,7 +7,7 @@ import okhttp3.Cookie import okhttp3.Response import java.io.File -class Teams(private val client: Client) : BaseService(client) { +class Teams(client: Client) : Service(client) { /** * List Teams diff --git a/library/src/main/java/io/appwrite/services/Users.kt b/library/src/main/java/io/appwrite/services/Users.kt new file mode 100644 index 0000000..0241d2d --- /dev/null +++ b/library/src/main/java/io/appwrite/services/Users.kt @@ -0,0 +1,303 @@ +package io.appwrite.services + +import android.net.Uri +import io.appwrite.Client +import io.appwrite.exceptions.AppwriteException +import okhttp3.Cookie +import okhttp3.Response +import java.io.File + +class Users(client: Client) : Service(client) { + + /** + * List Users + * + * Get a list of all the project's users. You can use the query params to + * filter your results. + * + * @param search + * @param limit + * @param offset + * @param orderType + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun list( + search: String? = null, + limit: Int? = null, + offset: Int? = null, + orderType: String? = null + ): Response { + val path = "/users" + val params = mapOf( + "search" to search, + "limit" to limit, + "offset" to offset, + "orderType" to orderType + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Create User + * + * Create a new user. + * + * @param email + * @param password + * @param name + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun create( + email: String, + password: String, + name: String? = null + ): Response { + val path = "/users" + val params = mapOf( + "email" to email, + "password" to password, + "name" to name + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("POST", path, headers, params) + } + + /** + * Get User + * + * Get a user by its unique ID. + * + * @param userId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun get( + userId: String + ): Response { + val path = "/users/{userId}".replace("{userId}", userId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Delete User + * + * Delete a user by its unique ID. + * + * @param userId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun delete( + userId: String + ): Response { + val path = "/users/{userId}".replace("{userId}", userId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("DELETE", path, headers, params) + } + + /** + * Get User Logs + * + * Get a user activity logs list by its unique ID. + * + * @param userId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getLogs( + userId: String + ): Response { + val path = "/users/{userId}/logs".replace("{userId}", userId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Get User Preferences + * + * Get the user preferences by its unique ID. + * + * @param userId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getPrefs( + userId: String + ): Response { + val path = "/users/{userId}/prefs".replace("{userId}", userId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Update User Preferences + * + * Update the user preferences by its unique ID. You can pass only the + * specific settings you wish to update. + * + * @param userId + * @param prefs + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updatePrefs( + userId: String, + prefs: Any + ): Response { + val path = "/users/{userId}/prefs".replace("{userId}", userId) + val params = mapOf( + "prefs" to prefs + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("PATCH", path, headers, params) + } + + /** + * Get User Sessions + * + * Get the user sessions list by its unique ID. + * + * @param userId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getSessions( + userId: String + ): Response { + val path = "/users/{userId}/sessions".replace("{userId}", userId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("GET", path, headers, params) + } + + /** + * Delete User Sessions + * + * Delete all user's sessions by using the user's unique ID. + * + * @param userId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun deleteSessions( + userId: String + ): Response { + val path = "/users/{userId}/sessions".replace("{userId}", userId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("DELETE", path, headers, params) + } + + /** + * Delete User Session + * + * Delete a user sessions by its unique ID. + * + * @param userId + * @param sessionId + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun deleteSession( + userId: String, + sessionId: String + ): Response { + val path = "/users/{userId}/sessions/{sessionId}".replace("{userId}", userId).replace("{sessionId}", sessionId) + val params = mapOf( + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("DELETE", path, headers, params) + } + + /** + * Update User Status + * + * Update the user status by its unique ID. + * + * @param userId + * @param status + * @return [Response] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updateStatus( + userId: String, + status: Int + ): Response { + val path = "/users/{userId}/status".replace("{userId}", userId) + val params = mapOf( + "status" to status + ) + + val headers = mapOf( + "content-type" to "application/json" + ) + + return client.call("PATCH", path, headers, params) + } + +} \ No newline at end of file From d5cadf8960441263ab32b88f2eb7e22c2e6daec8 Mon Sep 17 00:00:00 2001 From: Sumit Singh Date: Fri, 1 Oct 2021 16:43:53 +0530 Subject: [PATCH 002/118] Add feature issue form --- .github/ISSUE_TEMPLATE/feature.yaml | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/feature.yaml diff --git a/.github/ISSUE_TEMPLATE/feature.yaml b/.github/ISSUE_TEMPLATE/feature.yaml new file mode 100644 index 0000000..e32afd4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature.yaml @@ -0,0 +1,33 @@ +name: 🚀 Feature Request +description: "Submit a proposal for a new feature" +title: "🚀 Feature: " +labels: [feature] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out our feature request form 🙏 + - type: textarea + id: feature-description + validations: + required: true + attributes: + label: "🔖 Feature description" + description: "A clear and concise description of what the feature is." + placeholder: "You should add ..." + - type: textarea + id: pitch + validations: + required: true + attributes: + label: "🎤 Pitch" + description: "Please explain why this feature should be implemented and how it would be used. Add examples, if applicable." + placeholder: "In my use-case, ..." + - type: checkboxes + id: no-duplicate-issues + attributes: + label: "👀 Have you spent some time to check if this issue has been raised before?" + description: "Have you Googled for a similar issue or checked our older issues for a similar bug?" + options: + - label: "I checked and didn't find similar issue" + required: true From 61528cff1da09323f8a7542af392f7f75268d909 Mon Sep 17 00:00:00 2001 From: Sumit Singh Date: Fri, 1 Oct 2021 16:47:20 +0530 Subject: [PATCH 003/118] Add bug issue form --- .github/ISSUE_TEMPLATE/bug.yaml | 75 +++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug.yaml diff --git a/.github/ISSUE_TEMPLATE/bug.yaml b/.github/ISSUE_TEMPLATE/bug.yaml new file mode 100644 index 0000000..e04f1b4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yaml @@ -0,0 +1,75 @@ +name: "🐛 Bug Report" +description: "Submit a bug report to help us improve" +title: "🐛 Bug Report: " +labels: [bug] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out our bug report form 🙏 + - type: textarea + id: steps-to-reproduce + validations: + required: true + attributes: + label: "👟 Reproduction steps" + description: "How do you trigger this bug? Please walk us through it step by step." + placeholder: "When I ..." + - type: textarea + id: expected-behavior + validations: + required: true + attributes: + label: "👍 Expected behavior" + description: "What did you think would happen?" + placeholder: "It should ..." + - type: textarea + id: actual-behavior + validations: + required: true + attributes: + label: "👎 Actual Behavior" + description: "What did actually happen? Add screenshots, if applicable." + placeholder: "It actually ..." + - type: dropdown + id: appwrite-version + attributes: + label: "🎲 Appwrite version" + description: "What version of Appwrite are you running?" + options: + - Version 0.10.x + - Version 0.9.x + - Version 0.8.x + - Version 0.7.x + - Version 0.6.x + - Different version (specify in environment) + validations: + required: true + - type: dropdown + id: operating-system + attributes: + label: "💻 Operating system" + description: "What OS is your server / device running on?" + options: + - Linux + - MacOS + - Windows + - Something else + validations: + required: true + - type: textarea + id: enviromnemt + validations: + required: false + attributes: + label: "🧱 Your Environment" + description: "Is your environment customized in any way?" + placeholder: "I use Cloudflare for ..." + - type: checkboxes + id: no-duplicate-issues + attributes: + label: "👀 Have you spent some time to check if this issue has been raised before?" + description: "Have you Googled for a similar issue or checked our older issues for a similar bug?" + options: + - label: "I checked and didn't find similar issue" + required: true From c5380d23434c425b44cd497525124aead9e7d0a9 Mon Sep 17 00:00:00 2001 From: Sumit Singh Date: Fri, 1 Oct 2021 16:49:43 +0530 Subject: [PATCH 004/118] Add documentation issue form --- .github/ISSUE_TEMPLATE/documentation.yaml | 33 +++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/documentation.yaml diff --git a/.github/ISSUE_TEMPLATE/documentation.yaml b/.github/ISSUE_TEMPLATE/documentation.yaml new file mode 100644 index 0000000..6d1a73f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation.yaml @@ -0,0 +1,33 @@ +name: "📚 Documentation" +description: "Report an issue related to documentation" +title: "📚 Documentation: " +labels: [documentation] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out our documentation update request form 🙏 + - type: textarea + id: issue-description + validations: + required: true + attributes: + label: "💭 Description" + description: "A clear and concise description of what the issue is." + placeholder: "Documentation should not ..." + - type: checkboxes + id: no-duplicate-issues + attributes: + label: "👀 Have you spent some time to check if this issue has been raised before?" + description: "Have you Googled for a similar issue or checked our older issues for a similar bug?" + options: + - label: "I checked and didn't find similar issue" + required: true + - type: checkboxes + id: read-code-of-conduct + attributes: + description: "This is our [Code of Conduct](https://github.com/appwrite/appwrite/blob/master/CODE_OF_CONDUCT.md)." + label: "🏢 Have you read the Code of Conduct?" + options: + - label: "I read the Code of Conduct" + required: true From 3a09a3de28f85f727397104810f2f2159cf9c08b Mon Sep 17 00:00:00 2001 From: Sumit Singh Date: Sun, 3 Oct 2021 16:15:29 +0530 Subject: [PATCH 005/118] Add the code of conduct checkbox --- .github/ISSUE_TEMPLATE/bug.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/bug.yaml b/.github/ISSUE_TEMPLATE/bug.yaml index e04f1b4..175c606 100644 --- a/.github/ISSUE_TEMPLATE/bug.yaml +++ b/.github/ISSUE_TEMPLATE/bug.yaml @@ -73,3 +73,10 @@ body: options: - label: "I checked and didn't find similar issue" required: true + - type: checkboxes + id: read-code-of-conduct + attributes: + label: "🏢 Have you read the Code of Conduct?" + options: + - label: "I have read the [Code of Conduct](https://github.com/appwrite/appwrite/blob/HEAD/CODE_OF_CONDUCT.md)" + required: true From 302ebe2c485a2c24abfa7eed7937437023a5dd85 Mon Sep 17 00:00:00 2001 From: Sumit Singh Date: Sun, 3 Oct 2021 16:17:53 +0530 Subject: [PATCH 006/118] Add code of conduct in documentation.yaml --- .github/ISSUE_TEMPLATE/documentation.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/documentation.yaml b/.github/ISSUE_TEMPLATE/documentation.yaml index 6d1a73f..b6189b0 100644 --- a/.github/ISSUE_TEMPLATE/documentation.yaml +++ b/.github/ISSUE_TEMPLATE/documentation.yaml @@ -6,7 +6,7 @@ body: - type: markdown attributes: value: | - Thanks for taking the time to fill out our documentation update request form 🙏 + Thanks for taking the time to make our documentation better 🙏 - type: textarea id: issue-description validations: @@ -26,8 +26,7 @@ body: - type: checkboxes id: read-code-of-conduct attributes: - description: "This is our [Code of Conduct](https://github.com/appwrite/appwrite/blob/master/CODE_OF_CONDUCT.md)." label: "🏢 Have you read the Code of Conduct?" options: - - label: "I read the Code of Conduct" + - label: "I have read the [Code of Conduct](https://github.com/appwrite/appwrite/blob/HEAD/CODE_OF_CONDUCT.md)" required: true From 085591169619346470b771fbe9efd4d1e0116520 Mon Sep 17 00:00:00 2001 From: Sumit Singh Date: Sun, 3 Oct 2021 16:18:58 +0530 Subject: [PATCH 007/118] Add code of conduct in feature.yaml --- .github/ISSUE_TEMPLATE/feature.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/feature.yaml b/.github/ISSUE_TEMPLATE/feature.yaml index e32afd4..630af44 100644 --- a/.github/ISSUE_TEMPLATE/feature.yaml +++ b/.github/ISSUE_TEMPLATE/feature.yaml @@ -1,4 +1,4 @@ -name: 🚀 Feature Request +name: 🚀 Feature description: "Submit a proposal for a new feature" title: "🚀 Feature: " labels: [feature] @@ -31,3 +31,10 @@ body: options: - label: "I checked and didn't find similar issue" required: true + - type: checkboxes + id: read-code-of-conduct + attributes: + label: "🏢 Have you read the Code of Conduct?" + options: + - label: "I have read the [Code of Conduct](https://github.com/appwrite/appwrite/blob/HEAD/CODE_OF_CONDUCT.md)" + required: true From 31eac35af90d2bf2653f6c9ad50bc2fcf3c55117 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Mon, 18 Oct 2021 09:17:29 +0200 Subject: [PATCH 008/118] target right branch --- README.md | 8 ++++---- build.gradle | 2 +- library/src/main/java/io/appwrite/Client.kt | 2 +- library/src/main/java/io/appwrite/services/Teams.kt | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f4fdd6d..862d6b8 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-0.10.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-0.11.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_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 0.10.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).** +**This SDK is compatible with Appwrite server version 0.11.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:0.2.0") +implementation("io.appwrite:sdk-for-android:0.2.1") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 0.2.0 + 0.2.1 ``` diff --git a/build.gradle b/build.gradle index f7f3d55..4df4d35 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,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.4.31" - version '0.2.0' + version '0.2.1' repositories { maven { url "https://plugins.gradle.org/m2/" } google() diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 0e55ec7..4dba7e5 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -71,7 +71,7 @@ class Client @JvmOverloads constructor( "origin" to "appwrite-android://${context.packageName}", "user-agent" to "${context.packageName}/${appVersion}, ${System.getProperty("http.agent")}", "x-sdk-version" to "appwrite:android:${BuildConfig.SDK_VERSION}", - "x-appwrite-response-format" to "0.10.0" + "x-appwrite-response-format" to "0.11.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index b003bd9..741fd03 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -231,9 +231,9 @@ class Teams(client: Client) : Service(client) { val path = "/teams/{teamId}/memberships".replace("{teamId}", teamId) val params = mapOf( "email" to email, - "name" to name, "roles" to roles, - "url" to url + "url" to url, + "name" to name ) val headers = mapOf( From 1832682fa66a5963c0b03f6c621e4897b1776d6a Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 2 Nov 2021 19:37:22 +1300 Subject: [PATCH 009/118] Add response models --- README.md | 6 +- build.gradle | 6 +- docs/examples/java/account/get-session.md | 48 + docs/examples/kotlin/account/get-session.md | 26 + example-java/build.gradle | 7 +- example-java/src/main/AndroidManifest.xml | 2 +- .../appwrite/example_java/MainActivity.java | 13 +- example/build.gradle | 25 +- example/src/main/AndroidManifest.xml | 4 +- .../android/ui/accounts/AccountsViewModel.kt | 40 +- gradle/wrapper/gradle-wrapper.properties | 2 +- library/build.gradle | 15 +- library/src/main/java/io/appwrite/Client.kt | 136 ++- .../appwrite/exceptions/AppwriteException.kt | 2 +- .../io/appwrite/json/PreciseNumberAdapter.kt | 64 ++ .../main/java/io/appwrite/models/Continent.kt | 31 + .../java/io/appwrite/models/ContinentList.kt | 31 + .../main/java/io/appwrite/models/Country.kt | 31 + .../java/io/appwrite/models/CountryList.kt | 31 + .../main/java/io/appwrite/models/Currency.kt | 71 ++ .../java/io/appwrite/models/CurrencyList.kt | 31 + .../main/java/io/appwrite/models/Document.kt | 47 + .../java/io/appwrite/models/DocumentList.kt | 34 + .../main/java/io/appwrite/models/Execution.kt | 95 ++ .../java/io/appwrite/models/ExecutionList.kt | 31 + .../src/main/java/io/appwrite/models/File.kt | 71 ++ .../main/java/io/appwrite/models/FileList.kt | 31 + .../src/main/java/io/appwrite/models/Jwt.kt | 23 + .../main/java/io/appwrite/models/Language.kt | 39 + .../java/io/appwrite/models/LanguageList.kt | 31 + .../main/java/io/appwrite/models/Locale.kt | 71 ++ .../src/main/java/io/appwrite/models/Log.kt | 151 +++ .../main/java/io/appwrite/models/LogList.kt | 23 + .../java/io/appwrite/models/Membership.kt | 87 ++ .../java/io/appwrite/models/MembershipList.kt | 31 + .../java/io/appwrite/models/Permissions.kt | 31 + .../src/main/java/io/appwrite/models/Phone.kt | 39 + .../main/java/io/appwrite/models/PhoneList.kt | 31 + .../java/io/appwrite/models/Preferences.kt | 23 + .../java/io/appwrite/models/RealtimeModels.kt | 1 + .../main/java/io/appwrite/models/Session.kt | 191 ++++ .../java/io/appwrite/models/SessionList.kt | 31 + .../src/main/java/io/appwrite/models/Team.kt | 47 + .../main/java/io/appwrite/models/TeamList.kt | 31 + .../src/main/java/io/appwrite/models/Token.kt | 47 + .../src/main/java/io/appwrite/models/User.kt | 79 ++ .../main/java/io/appwrite/services/Account.kt | 470 +++++--- .../main/java/io/appwrite/services/Avatars.kt | 165 +-- .../java/io/appwrite/services/Database.kt | 296 ++--- .../java/io/appwrite/services/Functions.kt | 427 +------ .../main/java/io/appwrite/services/Health.kt | 275 ----- .../main/java/io/appwrite/services/Locale.kt | 127 ++- .../java/io/appwrite/services/Projects.kt | 1016 ----------------- .../java/io/appwrite/services/Realtime.kt | 106 +- .../main/java/io/appwrite/services/Storage.kt | 192 ++-- .../main/java/io/appwrite/services/Teams.kt | 239 ++-- .../main/java/io/appwrite/services/Users.kt | 303 ----- 57 files changed, 2815 insertions(+), 2739 deletions(-) create mode 100644 docs/examples/java/account/get-session.md create mode 100644 docs/examples/kotlin/account/get-session.md create mode 100644 library/src/main/java/io/appwrite/json/PreciseNumberAdapter.kt create mode 100644 library/src/main/java/io/appwrite/models/Continent.kt create mode 100644 library/src/main/java/io/appwrite/models/ContinentList.kt create mode 100644 library/src/main/java/io/appwrite/models/Country.kt create mode 100644 library/src/main/java/io/appwrite/models/CountryList.kt create mode 100644 library/src/main/java/io/appwrite/models/Currency.kt create mode 100644 library/src/main/java/io/appwrite/models/CurrencyList.kt create mode 100644 library/src/main/java/io/appwrite/models/Document.kt create mode 100644 library/src/main/java/io/appwrite/models/DocumentList.kt create mode 100644 library/src/main/java/io/appwrite/models/Execution.kt create mode 100644 library/src/main/java/io/appwrite/models/ExecutionList.kt create mode 100644 library/src/main/java/io/appwrite/models/File.kt create mode 100644 library/src/main/java/io/appwrite/models/FileList.kt create mode 100644 library/src/main/java/io/appwrite/models/Jwt.kt create mode 100644 library/src/main/java/io/appwrite/models/Language.kt create mode 100644 library/src/main/java/io/appwrite/models/LanguageList.kt create mode 100644 library/src/main/java/io/appwrite/models/Locale.kt create mode 100644 library/src/main/java/io/appwrite/models/Log.kt create mode 100644 library/src/main/java/io/appwrite/models/LogList.kt create mode 100644 library/src/main/java/io/appwrite/models/Membership.kt create mode 100644 library/src/main/java/io/appwrite/models/MembershipList.kt create mode 100644 library/src/main/java/io/appwrite/models/Permissions.kt create mode 100644 library/src/main/java/io/appwrite/models/Phone.kt create mode 100644 library/src/main/java/io/appwrite/models/PhoneList.kt create mode 100644 library/src/main/java/io/appwrite/models/Preferences.kt create mode 100644 library/src/main/java/io/appwrite/models/Session.kt create mode 100644 library/src/main/java/io/appwrite/models/SessionList.kt create mode 100644 library/src/main/java/io/appwrite/models/Team.kt create mode 100644 library/src/main/java/io/appwrite/models/TeamList.kt create mode 100644 library/src/main/java/io/appwrite/models/Token.kt create mode 100644 library/src/main/java/io/appwrite/models/User.kt delete mode 100644 library/src/main/java/io/appwrite/services/Health.kt delete mode 100644 library/src/main/java/io/appwrite/services/Projects.kt delete mode 100644 library/src/main/java/io/appwrite/services/Users.kt diff --git a/README.md b/README.md index c9790d4..862d6b8 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,9 @@ **This SDK is compatible with Appwrite server version 0.11.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 Flutter 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 +Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Android SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) -![Appwrite](https://appwrite.io/v1/images/console.png) +![Appwrite](https://appwrite.io/images/github.png) ## Installation @@ -156,4 +156,4 @@ This library is auto-generated by Appwrite custom [SDK Generator](https://github ## License -Please see the [BSD-3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information. +Please see the [BSD-3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information. \ No newline at end of file diff --git a/build.gradle b/build.gradle index 4df4d35..5dd7a83 100644 --- a/build.gradle +++ b/build.gradle @@ -2,15 +2,15 @@ apply plugin: 'io.github.gradle-nexus.publish-plugin' // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = "1.4.31" - version '0.2.1' + ext.kotlin_version = "1.5.31" + version "0.3.0-SNAPSHOT" repositories { maven { url "https://plugins.gradle.org/m2/" } google() mavenCentral() } dependencies { - classpath "com.android.tools.build:gradle:4.2.0" + classpath "com.android.tools.build:gradle:7.0.3" 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/get-session.md b/docs/examples/java/account/get-session.md new file mode 100644 index 0000000..8d4c95a --- /dev/null +++ b/docs/examples/java/account/get-session.md @@ -0,0 +1,48 @@ +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.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 diff --git a/docs/examples/kotlin/account/get-session.md b/docs/examples/kotlin/account/get-session.md new file mode 100644 index 0000000..45f00b6 --- /dev/null +++ b/docs/examples/kotlin/account/get-session.md @@ -0,0 +1,26 @@ +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.getSession( + sessionId = "[SESSION_ID]" + ) + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/example-java/build.gradle b/example-java/build.gradle index fb49677..fb916fa 100644 --- a/example-java/build.gradle +++ b/example-java/build.gradle @@ -3,13 +3,12 @@ plugins { } android { - compileSdkVersion 30 - buildToolsVersion "30.0.3" + compileSdkVersion 31 defaultConfig { applicationId "io.appwrite.example_java" minSdkVersion 23 - targetSdkVersion 30 + targetSdkVersion 31 versionCode 1 versionName "1.0" @@ -29,8 +28,8 @@ android { } dependencies { - implementation project(path: ':library') + implementation 'androidx.appcompat:appcompat:1.3.0' implementation 'com.google.android.material:material:1.3.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' diff --git a/example-java/src/main/AndroidManifest.xml b/example-java/src/main/AndroidManifest.xml index 1fd3789..0276c9c 100644 --- a/example-java/src/main/AndroidManifest.xml +++ b/example-java/src/main/AndroidManifest.xml @@ -9,7 +9,7 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.AppwriteAndroidSDK"> - + 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 5b0d09b..28e3222 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 @@ -4,15 +4,15 @@ import android.os.Bundle; import android.util.Log; import org.jetbrains.annotations.NotNull; -import org.json.JSONObject; import io.appwrite.Client; import io.appwrite.exceptions.AppwriteException; +import io.appwrite.extensions.JsonExtensionsKt; +import io.appwrite.models.Session; import io.appwrite.services.Account; import kotlin.Result; import kotlin.coroutines.Continuation; import kotlin.coroutines.CoroutineContext; import kotlin.coroutines.EmptyCoroutineContext; -import okhttp3.Response; public class MainActivity extends AppCompatActivity { @@ -28,7 +28,7 @@ protected void onCreate(Bundle savedInstanceState) { Account account = new Account(client); try { - account.createSession("test7@test.com","password", new Continuation() { + account.createSession("test7@test.com","password", new Continuation() { @NotNull @Override public CoroutineContext getContext() { @@ -37,16 +37,13 @@ public CoroutineContext getContext() { @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(); - json = new JSONObject(json).toString(8); - Log.d("RESPONSE", json); + Session session = (Session) o; + Log.d("RESPONSE", JsonExtensionsKt.toJson(session)); } } catch (Throwable th) { Log.e("ERROR", th.toString()); diff --git a/example/build.gradle b/example/build.gradle index 6057427..6c5e1f5 100644 --- a/example/build.gradle +++ b/example/build.gradle @@ -4,13 +4,12 @@ plugins { } android { - compileSdkVersion 30 - buildToolsVersion "30.0.3" + compileSdkVersion 31 defaultConfig { applicationId "io.appwrite.android" minSdkVersion 21 - targetSdkVersion 30 + targetSdkVersion 31 versionCode 1 versionName "1.0" @@ -37,23 +36,23 @@ android { } dependencies { - implementation project(path: ':library') + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.core:core-ktx:1.5.0' - implementation 'androidx.appcompat:appcompat:1.3.0' - implementation 'com.google.android.material:material:1.3.0' - implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + implementation 'androidx.core:core-ktx:1.6.0' + implementation 'androidx.appcompat:appcompat:1.3.1' + implementation 'com.google.android.material:material:1.4.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.1' implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5' - implementation "androidx.fragment:fragment-ktx:1.3.2" + implementation "androidx.fragment:fragment-ktx:1.3.6" implementation 'androidx.navigation:navigation-ui-ktx:2.3.5' implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1' implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1' implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5' implementation 'androidx.navigation:navigation-ui-ktx:2.3.5' - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2" testImplementation 'junit:junit:4.+' - androidTestImplementation 'androidx.test.ext:junit:1.1.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' } \ No newline at end of file diff --git a/example/src/main/AndroidManifest.xml b/example/src/main/AndroidManifest.xml index 91f2179..e3c2421 100644 --- a/example/src/main/AndroidManifest.xml +++ b/example/src/main/AndroidManifest.xml @@ -9,14 +9,14 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.AppwriteAndroidSDK"> - + - + 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 2d812e8..1e7b084 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 @@ -6,10 +6,9 @@ import androidx.lifecycle.* import io.appwrite.android.utils.Client.client import io.appwrite.android.utils.Event import io.appwrite.exceptions.AppwriteException +import io.appwrite.extensions.toJson import io.appwrite.services.Account import kotlinx.coroutines.launch -import org.json.JSONObject - class AccountsViewModel : ViewModel() { @@ -27,13 +26,11 @@ class AccountsViewModel : ViewModel() { Account(client) } - fun onLogin(email: Editable , password : Editable) { + fun onLogin(email: Editable, password: Editable) { viewModelScope.launch { try { - var response = accountService.createSession(email.toString(), password.toString()) - var json = response.body?.string() ?: "" - json = JSONObject(json).toString(8) - _response.postValue(Event(json)) + val session = accountService.createSession(email.toString(), password.toString()) + _response.postValue(Event(session.toJson())) } catch (e: AppwriteException) { _error.postValue(Event(e)) } @@ -41,13 +38,12 @@ class AccountsViewModel : ViewModel() { } - fun onSignup(email: Editable , password : Editable, name: Editable) { + fun onSignup(email: Editable, password: Editable, name: Editable) { viewModelScope.launch { try { - var response = accountService.create(email.toString(), password.toString(), name.toString()) - var json = response.body?.string() ?: "" - json = JSONObject(json).toString(2) - _response.postValue(Event(json)) + val user = + accountService.create(email.toString(), password.toString(), name.toString()) + _response.postValue(Event(user.toJson())) } catch (e: AppwriteException) { _error.postValue(Event(e)) } @@ -58,7 +54,12 @@ class AccountsViewModel : ViewModel() { fun oAuthLogin(activity: ComponentActivity) { viewModelScope.launch { try { - accountService.createOAuth2Session(activity, "facebook", "appwrite-callback-6070749e6acd4://demo.appwrite.io/auth/oauth2/success", "appwrite-callback-6070749e6acd4://demo.appwrite.io/auth/oauth2/failure") + accountService.createOAuth2Session( + activity, + "facebook", + "appwrite-callback-6070749e6acd4://demo.appwrite.io/auth/oauth2/success", + "appwrite-callback-6070749e6acd4://demo.appwrite.io/auth/oauth2/failure" + ) } catch (e: Exception) { _error.postValue(Event(e)) } catch (e: AppwriteException) { @@ -70,10 +71,8 @@ class AccountsViewModel : ViewModel() { fun getUser() { viewModelScope.launch { try { - var response = accountService.get() - var json = response.body?.string() ?: "" - json = JSONObject(json).toString(2) - _response.postValue(Event(json)) + val account = accountService.get() + _response.postValue(Event(account.toJson())) } catch (e: AppwriteException) { _error.postValue(Event(e)) } @@ -83,14 +82,11 @@ class AccountsViewModel : ViewModel() { fun logout() { viewModelScope.launch { try { - var response = accountService.deleteSession("current") - var json = response.body?.string()?.ifEmpty { "{}" } - json = JSONObject(json).toString(4) - _response.postValue(Event(json)) + val result = accountService.deleteSession("current") + _response.postValue(Event(result.toJson())) } catch (e: AppwriteException) { _error.postValue(Event(e)) } } } - } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2dadb9d..710f6bd 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Tue Jun 01 15:55:54 IST 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/library/build.gradle b/library/build.gradle index 2b036f1..cb15537 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,4 +1,3 @@ -import org.jetbrains.kotlin.config.KotlinCompilerVersion plugins { id("com.android.library") id("kotlin-android") @@ -11,7 +10,7 @@ ext { POM_URL = 'https://github.com/appwrite/sdk-for-android' POM_SCM_URL = 'https://github.com/appwrite/sdk-for-android' POM_ISSUE_URL = 'https://github.com/appwrite/sdk-for-android/issues' - POM_DESCRIPTION = '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 Flutter 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' + POM_DESCRIPTION = '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)' POM_LICENSE_URL = 'https://opensource.org/licenses/GPL-3.0' POM_LICENSE_NAME = "GPL-3.0" POM_DEVELOPER_ID = 'appwrite' @@ -21,11 +20,11 @@ ext { } android { - compileSdkVersion(30) + compileSdkVersion(31) defaultConfig { minSdkVersion(21) - targetSdkVersion(30) + targetSdkVersion(31) versionCode = 1 versionName = "1.0" buildConfigField "String", "SDK_VERSION", "\"${PUBLISH_VERSION}\"" @@ -52,9 +51,9 @@ android { } dependencies { - implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${KotlinCompilerVersion.VERSION}") - api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1") - api("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0") + 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(platform("com.squareup.okhttp3:okhttp-bom:4.9.0")) api("com.squareup.okhttp3:okhttp") @@ -77,4 +76,4 @@ dependencies { testApi("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.5.1") } -apply from: "${rootProject.projectDir}/scripts/publish-module.gradle" +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 b1d16f6..162357e 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -2,10 +2,12 @@ package io.appwrite import android.content.Context import android.content.pm.PackageManager -import com.google.gson.Gson +import com.google.gson.GsonBuilder +import com.google.gson.reflect.TypeToken import io.appwrite.appwrite.BuildConfig import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.fromJson +import io.appwrite.json.PreciseNumberAdapter import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -17,6 +19,7 @@ import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.MediaType.Companion.toMediaType import okhttp3.RequestBody.Companion.asRequestBody import okhttp3.RequestBody.Companion.toRequestBody +import java.io.BufferedInputStream import java.io.BufferedReader import java.io.File import java.io.IOException @@ -44,6 +47,11 @@ class Client @JvmOverloads constructor( private val job = Job() + private val gson = GsonBuilder().registerTypeAdapter( + object : TypeToken>(){}.type, + PreciseNumberAdapter() + ).create() + lateinit var http: OkHttpClient private val headers: MutableMap @@ -93,21 +101,6 @@ class Client @JvmOverloads constructor( return this } - /** - * Set Key - * - * Your secret API key - * - * @param {string} key - * - * @return this - */ - fun setKey(value: String): Client { - config["key"] = value - addHeader("x-appwrite-key", value) - return this - } - /** * Set JWT * @@ -136,19 +129,6 @@ class Client @JvmOverloads constructor( return this } - /** - * Set Mode - * - * @param {string} mode - * - * @return this - */ - fun setMode(value: String): Client { - config["mode"] = value - addHeader("x-appwrite-mode", value) - return this - } - /** * Set self Signed * @@ -171,9 +151,12 @@ class Client @JvmOverloads constructor( try { // Create a trust manager that does not validate certificate chains val trustAllCerts = arrayOf( + @Suppress("CustomX509TrustManager") object : X509TrustManager { + @Suppress("TrustAllX509TrustManager") override fun checkClientTrusted(chain: Array, authType: String) { } + @Suppress("TrustAllX509TrustManager") override fun checkServerTrusted(chain: Array, authType: String) { } override fun getAcceptedIssuers(): Array { @@ -251,13 +234,14 @@ class Client @JvmOverloads constructor( * @return [Response] */ @Throws(AppwriteException::class) - suspend fun call( + suspend fun call( method: String, path: String, headers: Map = mapOf(), - params: Map = mapOf() - ): Response { - + params: Map = mapOf(), + responseType: Class, + convert: ((Map) -> T)? = null + ): T { val filteredParams = params.filterValues { it != null } val requestHeaders = this.headers.toHeaders().newBuilder() @@ -292,7 +276,7 @@ class Client @JvmOverloads constructor( .get() .build() - return awaitResponse(request) + return awaitResponse(request, responseType, convert) } val body = if (MultipartBody.FORM.toString() == headers["content-type"]) { @@ -320,7 +304,7 @@ class Client @JvmOverloads constructor( } builder.build() } else { - Gson().toJson(filteredParams) + gson.toJson(filteredParams) .toRequestBody("application/json".toMediaType()) } @@ -330,21 +314,24 @@ class Client @JvmOverloads constructor( .method(method, body) .build() - return awaitResponse(request) + return awaitResponse(request, responseType, convert) } /** * Await Response - * - * @param method - * @param path - * @param headers - * @param params * - * @return [Response] + * @param request + * @param responseType + * @param convert + * + * @return [T] */ @Throws(AppwriteException::class) - private suspend fun awaitResponse(request: Request) = suspendCancellableCoroutine { + private suspend fun awaitResponse( + request: Request, + responseType: Class, + convert: ((Map) -> T)? = null + ) = suspendCancellableCoroutine { http.newCall(request).enqueue(object : Callback { override fun onFailure(call: Call, e: IOException) { if (it.isCancelled) { @@ -353,28 +340,55 @@ class Client @JvmOverloads constructor( it.cancel(e) } + @Suppress("UNCHECKED_CAST") override fun onResponse(call: Call, response: Response) { - if (response.code >= 400) { - val bodyString = response.body - ?.charStream() - ?.buffered() - ?.use(BufferedReader::readText) ?: "" - - val contentType: String = response.headers["content-type"] ?: "" - val error = if (contentType.contains("application/json", ignoreCase = true)) { - bodyString.fromJson() + if (!response.isSuccessful) { + val body = response.body!! + .charStream() + .buffered() + .use(BufferedReader::readText) + val error = if (response.headers["content-type"]?.contains("application/json") == true) { + body.fromJson() } else { - AppwriteException(bodyString, response.code) + AppwriteException(body, response.code) } - - it.cancel(AppwriteException( - error.message, - error.code, - bodyString - )) + it.cancel(error) + return + } + when { + responseType == Boolean::class.java -> { + it.resume(true as T) + return + } + responseType == ByteArray::class.java -> { + it.resume(response.body!! + .byteStream() + .buffered() + .use(BufferedInputStream::readBytes) as T + ) + return + } + response.body == null -> { + it.resume(true as T) + return + } + } + val body = response.body!! + .charStream() + .buffered() + .use(BufferedReader::readText) + if (body.isEmpty()) { + it.resume(true as T) + return } - it.resume(response) + val map = gson.fromJson>( + body, + object : TypeToken>(){}.type + ) + it.resume( + convert?.invoke(map) ?: map as T + ) } }) } -} +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/exceptions/AppwriteException.kt b/library/src/main/java/io/appwrite/exceptions/AppwriteException.kt index d7d4fbc..1d22595 100644 --- a/library/src/main/java/io/appwrite/exceptions/AppwriteException.kt +++ b/library/src/main/java/io/appwrite/exceptions/AppwriteException.kt @@ -3,7 +3,7 @@ package io.appwrite.exceptions import java.lang.Exception class AppwriteException( - message: String? = null, + override val message: String? = null, val code: Int? = null, val response: String? = null ) : Exception(message) \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/json/PreciseNumberAdapter.kt b/library/src/main/java/io/appwrite/json/PreciseNumberAdapter.kt new file mode 100644 index 0000000..6d408ac --- /dev/null +++ b/library/src/main/java/io/appwrite/json/PreciseNumberAdapter.kt @@ -0,0 +1,64 @@ +package io.appwrite.json + +import com.google.gson.Gson +import com.google.gson.TypeAdapter +import com.google.gson.stream.JsonReader +import com.google.gson.stream.JsonToken.* +import com.google.gson.stream.JsonWriter +import java.io.IOException + +internal class PreciseNumberAdapter : TypeAdapter() { + + private val delegate = Gson() + .getAdapter(Any::class.java) + + @Throws(IOException::class) + override fun write(out: JsonWriter?, value: Any?) { + delegate.write(out, value) + } + + @Throws(IOException::class) + override fun read(input: JsonReader): Any? { + return when (input.peek()) { + BEGIN_ARRAY -> { + val list = mutableListOf() + input.beginArray() + while (input.hasNext()) { + list.add(read(input)) + } + input.endArray() + list + } + BEGIN_OBJECT -> { + val map = mutableMapOf() + input.beginObject() + while (input.hasNext()) { + map[input.nextName()] = read(input) + } + input.endObject() + map + } + STRING -> { + input.nextString() + } + NUMBER -> { + val numberString = input.nextString() + if (numberString.indexOf('.') != -1) { + numberString.toDouble() + } else { + numberString.toLong() + } + } + BOOLEAN -> { + input.nextBoolean() + } + NULL -> { + input.nextNull() + null + } + else -> { + throw IllegalStateException() + } + } + } +} \ 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 new file mode 100644 index 0000000..da6eca6 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Continent.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Continent + */ +data class Continent( + /** + * Continent name. + * + */ + val name: String, + + /** + * Continent two letter code. + * + */ + val code: String +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Continent( + name = map["name"] 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 new file mode 100644 index 0000000..9b076c4 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/ContinentList.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Continents List + */ +data class ContinentList( + /** + * Total number of items available on the server. + * + */ + val sum: Long, + + /** + * List of continents. + * + */ + val continents: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = ContinentList( + sum = map["sum"] as Long, + continents = (map["continents"] as List>).map { Continent.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "sum" to sum 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 new file mode 100644 index 0000000..8c1d608 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Country.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Country + */ +data class Country( + /** + * Country name. + * + */ + val name: String, + + /** + * Country two-character ISO 3166-1 alpha code. + * + */ + val code: String +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Country( + name = map["name"] 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 new file mode 100644 index 0000000..a1476a1 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/CountryList.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Countries List + */ +data class CountryList( + /** + * Total number of items available on the server. + * + */ + val sum: Long, + + /** + * List of countries. + * + */ + val countries: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = CountryList( + sum = map["sum"] as Long, + countries = (map["countries"] as List>).map { Country.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "sum" to sum 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 new file mode 100644 index 0000000..58002c2 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Currency.kt @@ -0,0 +1,71 @@ +package io.appwrite.models + +/** + * Currency + */ +data class Currency( + /** + * Currency symbol. + * + */ + val symbol: String, + + /** + * Currency name. + * + */ + val name: String, + + /** + * Currency native symbol. + * + */ + val symbolNative: String, + + /** + * Number of decimal digits. + * + */ + val decimalDigits: Long, + + /** + * Currency digit rounding. + * + */ + val rounding: Double, + + /** + * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. + * + */ + val code: String, + + /** + * Currency plural name + * + */ + val namePlural: String +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Currency( + symbol = map["symbol"] as String, + name = map["name"] as String, + symbolNative = map["symbolNative"] as String, + decimalDigits = map["decimalDigits"] as Long, + rounding = map["rounding"] as Double, + code = map["code"] 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 new file mode 100644 index 0000000..d2863d9 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/CurrencyList.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Currencies List + */ +data class CurrencyList( + /** + * Total number of items available on the server. + * + */ + val sum: Long, + + /** + * List of currencies. + * + */ + val currencies: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = CurrencyList( + sum = map["sum"] as Long, + currencies = (map["currencies"] as List>).map { Currency.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "sum" to sum 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 new file mode 100644 index 0000000..0941dfe --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Document.kt @@ -0,0 +1,47 @@ +package io.appwrite.models + +/** + * Document + */ +data class Document( + /** + * Document ID. + * + */ + val id: String, + + /** + * Collection ID. + * + */ + val collection: String, + + /** + * Document permissions. + * + */ + val permissions: Permissions, + + val data: Map +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Document( + id = map["\$id"] as String, + collection = map["\$collection"] as String, + permissions = Permissions.from(map = map["\$permissions"] as Map), + data = map + ) + } + + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$collection" to collection as Any, + "\$permissions" to permissions.toMap() as Any, + "data" to data + ) + + fun convertTo(fromJson: (Map) -> T): T { + return fromJson(data) + } +} \ 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 new file mode 100644 index 0000000..c05899f --- /dev/null +++ b/library/src/main/java/io/appwrite/models/DocumentList.kt @@ -0,0 +1,34 @@ +package io.appwrite.models + +/** + * Documents List + */ +data class DocumentList( + /** + * Total number of items available on the server. + * + */ + val sum: Long, + + /** + * List of documents. + * + */ + val documents: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = DocumentList( + sum = map["sum"] as Long, + documents = (map["documents"] as List>).map { Document.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "sum" to sum 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 new file mode 100644 index 0000000..e9e8d8f --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -0,0 +1,95 @@ +package io.appwrite.models + +/** + * Execution + */ +data class Execution( + /** + * Execution ID. + * + */ + val id: String, + + /** + * Execution permissions. + * + */ + val permissions: Permissions, + + /** + * Function ID. + * + */ + val functionId: String, + + /** + * The execution creation date in Unix timestamp. + * + */ + val dateCreated: Long, + + /** + * The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. + * + */ + val trigger: String, + + /** + * The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. + * + */ + val status: String, + + /** + * The script exit code. + * + */ + val exitCode: Long, + + /** + * The script stdout output string. Logs the last 4,000 characters of the execution stdout output. + * + */ + val stdout: String, + + /** + * The script stderr output string. Logs the last 4,000 characters of the execution stderr output + * + */ + val stderr: String, + + /** + * The script execution time in seconds. + * + */ + val time: Double +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Execution( + id = map["\$id"] as String, + permissions = Permissions.from(map = map["\$permissions"] as Map), + functionId = map["functionId"] as String, + dateCreated = map["dateCreated"] as Long, + trigger = map["trigger"] as String, + status = map["status"] as String, + exitCode = map["exitCode"] as Long, + stdout = map["stdout"] as String, + stderr = map["stderr"] as String, + time = map["time"] as Double + ) + } + + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$permissions" to permissions.toMap() as Any, + "functionId" to functionId as Any, + "dateCreated" to dateCreated as Any, + "trigger" to trigger as Any, + "status" to status as Any, + "exitCode" to exitCode as Any, + "stdout" to stdout as Any, + "stderr" to stderr as Any, + "time" to time 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 new file mode 100644 index 0000000..5ab06b7 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/ExecutionList.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Executions List + */ +data class ExecutionList( + /** + * Total number of items available on the server. + * + */ + val sum: Long, + + /** + * List of executions. + * + */ + val executions: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = ExecutionList( + sum = map["sum"] as Long, + executions = (map["executions"] as List>).map { Execution.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "sum" to sum 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 new file mode 100644 index 0000000..daa35c2 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/File.kt @@ -0,0 +1,71 @@ +package io.appwrite.models + +/** + * File + */ +data class File( + /** + * File ID. + * + */ + val id: String, + + /** + * File permissions. + * + */ + val permissions: Permissions, + + /** + * File name. + * + */ + val name: String, + + /** + * File creation date in Unix timestamp. + * + */ + val dateCreated: Long, + + /** + * File MD5 signature. + * + */ + val signature: String, + + /** + * File mime type. + * + */ + val mimeType: String, + + /** + * File original size in bytes. + * + */ + val sizeOriginal: Long +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = File( + id = map["\$id"] as String, + permissions = Permissions.from(map = map["\$permissions"] as Map), + name = map["name"] as String, + dateCreated = map["dateCreated"] as Long, + signature = map["signature"] as String, + mimeType = map["mimeType"] as String, + sizeOriginal = map["sizeOriginal"] as Long + ) + } + + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$permissions" to permissions.toMap() as Any, + "name" to name as Any, + "dateCreated" to dateCreated as Any, + "signature" to signature as Any, + "mimeType" to mimeType as Any, + "sizeOriginal" to sizeOriginal 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 new file mode 100644 index 0000000..4c9cf1c --- /dev/null +++ b/library/src/main/java/io/appwrite/models/FileList.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Files List + */ +data class FileList( + /** + * Total number of items available on the server. + * + */ + val sum: Long, + + /** + * List of files. + * + */ + val files: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = FileList( + sum = map["sum"] as Long, + files = (map["files"] as List>).map { File.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "sum" to sum 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 new file mode 100644 index 0000000..4012643 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Jwt.kt @@ -0,0 +1,23 @@ +package io.appwrite.models + +/** + * JWT + */ +data class Jwt( + /** + * JWT encoded string. + * + */ + val jwt: String +) { + companion object { + @Suppress("UNCHECKED_CAST") + 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 new file mode 100644 index 0000000..0f050a8 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Language.kt @@ -0,0 +1,39 @@ +package io.appwrite.models + +/** + * Language + */ +data class Language( + /** + * Language name. + * + */ + val name: String, + + /** + * Language two-character ISO 639-1 codes. + * + */ + val code: String, + + /** + * Language native name. + * + */ + val nativeName: String +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Language( + name = map["name"] as String, + code = map["code"] 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 new file mode 100644 index 0000000..813c99b --- /dev/null +++ b/library/src/main/java/io/appwrite/models/LanguageList.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Languages List + */ +data class LanguageList( + /** + * Total number of items available on the server. + * + */ + val sum: Long, + + /** + * List of languages. + * + */ + val languages: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = LanguageList( + sum = map["sum"] as Long, + languages = (map["languages"] as List>).map { Language.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "sum" to sum 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 new file mode 100644 index 0000000..6e812c5 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Locale.kt @@ -0,0 +1,71 @@ +package io.appwrite.models + +/** + * Locale + */ +data class Locale( + /** + * User IP address. + * + */ + val ip: String, + + /** + * Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format + * + */ + val countryCode: String, + + /** + * Country name. This field support localization. + * + */ + 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. + * + */ + val continentCode: String, + + /** + * Continent name. This field support localization. + * + */ + val continent: String, + + /** + * True if country is part of the Europian Union. + * + */ + val eu: Boolean, + + /** + * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format + * + */ + val currency: String +) { + companion object { + @Suppress("UNCHECKED_CAST") + 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 + ) + } + + 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 new file mode 100644 index 0000000..028aa71 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Log.kt @@ -0,0 +1,151 @@ +package io.appwrite.models + +/** + * Log + */ +data class Log( + /** + * Event name. + * + */ + val event: String, + + /** + * IP session in use when the session was created. + * + */ + val ip: String, + + /** + * Log creation time in Unix timestamp. + * + */ + val time: Long, + + /** + * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + * + */ + val osCode: String, + + /** + * Operating system name. + * + */ + val osName: String, + + /** + * Operating system version. + * + */ + val osVersion: String, + + /** + * Client type. + * + */ + val clientType: String, + + /** + * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + * + */ + val clientCode: String, + + /** + * Client name. + * + */ + val clientName: String, + + /** + * Client version. + * + */ + val clientVersion: String, + + /** + * Client engine name. + * + */ + val clientEngine: String, + + /** + * Client engine name. + * + */ + val clientEngineVersion: String, + + /** + * Device name. + * + */ + val deviceName: String, + + /** + * Device brand name. + * + */ + val deviceBrand: String, + + /** + * Device model name. + * + */ + val deviceModel: String, + + /** + * Country two-character ISO 3166-1 alpha code. + * + */ + val countryCode: String, + + /** + * Country name. + * + */ + val countryName: String +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Log( + event = map["event"] as String, + ip = map["ip"] as String, + time = map["time"] as Long, + osCode = map["osCode"] as String, + osName = map["osName"] as String, + osVersion = map["osVersion"] as String, + clientType = map["clientType"] as String, + clientCode = map["clientCode"] as String, + clientName = map["clientName"] as String, + clientVersion = map["clientVersion"] as String, + clientEngine = map["clientEngine"] as String, + clientEngineVersion = map["clientEngineVersion"] as String, + deviceName = map["deviceName"] as String, + deviceBrand = map["deviceBrand"] as String, + deviceModel = map["deviceModel"] as String, + countryCode = map["countryCode"] as String, + countryName = map["countryName"] as String + ) + } + + fun toMap(): Map = mapOf( + "event" to event 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 new file mode 100644 index 0000000..a741ae4 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/LogList.kt @@ -0,0 +1,23 @@ +package io.appwrite.models + +/** + * Logs List + */ +data class LogList( + /** + * List of logs. + * + */ + val logs: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = LogList( + logs = (map["logs"] as List>).map { Log.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "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 new file mode 100644 index 0000000..9e0266f --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Membership.kt @@ -0,0 +1,87 @@ +package io.appwrite.models + +/** + * Membership + */ +data class Membership( + /** + * Membership ID. + * + */ + val id: String, + + /** + * User ID. + * + */ + val userId: String, + + /** + * Team ID. + * + */ + val teamId: String, + + /** + * User name. + * + */ + val name: String, + + /** + * User email address. + * + */ + val email: String, + + /** + * Date, the user has been invited to join the team in Unix timestamp. + * + */ + val invited: Long, + + /** + * Date, the user has accepted the invitation to join the team in Unix timestamp. + * + */ + val joined: Long, + + /** + * User confirmation status, true if the user has joined the team or false otherwise. + * + */ + val confirm: Boolean, + + /** + * User list of roles + * + */ + val roles: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Membership( + id = map["\$id"] as String, + userId = map["userId"] as String, + teamId = map["teamId"] as String, + name = map["name"] as String, + email = map["email"] as String, + invited = map["invited"] as Long, + joined = map["joined"] as Long, + confirm = map["confirm"] as Boolean, + roles = map["roles"] as List + ) + } + + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "userId" to userId as Any, + "teamId" to teamId as Any, + "name" to name as Any, + "email" to email 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 new file mode 100644 index 0000000..3935263 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/MembershipList.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Memberships List + */ +data class MembershipList( + /** + * Total number of items available on the server. + * + */ + val sum: Long, + + /** + * List of memberships. + * + */ + val memberships: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = MembershipList( + sum = map["sum"] as Long, + memberships = (map["memberships"] as List>).map { Membership.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "sum" to sum 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/Permissions.kt b/library/src/main/java/io/appwrite/models/Permissions.kt new file mode 100644 index 0000000..81cd07d --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Permissions.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Permissions + */ +data class Permissions( + /** + * Read permissions. + * + */ + val read: List, + + /** + * Write permissions. + * + */ + val write: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Permissions( + read = map["read"] as List, + write = map["write"] as List + ) + } + + fun toMap(): Map = mapOf( + "read" to read as Any, + "write" to write 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 new file mode 100644 index 0000000..a11de9d --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Phone.kt @@ -0,0 +1,39 @@ +package io.appwrite.models + +/** + * Phone + */ +data class Phone( + /** + * Phone code. + * + */ + val code: String, + + /** + * Country two-character ISO 3166-1 alpha code. + * + */ + val countryCode: String, + + /** + * Country name. + * + */ + val countryName: String +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Phone( + code = map["code"] as String, + countryCode = map["countryCode"] 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 new file mode 100644 index 0000000..a7b92d0 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/PhoneList.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Phones List + */ +data class PhoneList( + /** + * Total number of items available on the server. + * + */ + val sum: Long, + + /** + * List of phones. + * + */ + val phones: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = PhoneList( + sum = map["sum"] as Long, + phones = (map["phones"] as List>).map { Phone.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "sum" to sum 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 new file mode 100644 index 0000000..a95850f --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Preferences.kt @@ -0,0 +1,23 @@ +package io.appwrite.models + +/** + * Preferences + */ +data class Preferences( + val data: Map +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Preferences( + data = map + ) + } + + fun toMap(): Map = mapOf( + "data" to data + ) + + fun convertTo(fromJson: (Map) -> T): T { + return fromJson(data) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/RealtimeModels.kt b/library/src/main/java/io/appwrite/models/RealtimeModels.kt index b4990c8..e2b012a 100644 --- a/library/src/main/java/io/appwrite/models/RealtimeModels.kt +++ b/library/src/main/java/io/appwrite/models/RealtimeModels.kt @@ -9,6 +9,7 @@ data class RealtimeSubscription( } data class RealtimeCallback( + val channels: Collection, val payloadClass: Class<*>, val callback: (RealtimeResponseEvent<*>) -> Unit ) diff --git a/library/src/main/java/io/appwrite/models/Session.kt b/library/src/main/java/io/appwrite/models/Session.kt new file mode 100644 index 0000000..fa8a91f --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Session.kt @@ -0,0 +1,191 @@ +package io.appwrite.models + +/** + * Session + */ +data class Session( + /** + * Session ID. + * + */ + val id: String, + + /** + * User ID. + * + */ + val userId: String, + + /** + * Session expiration date in Unix timestamp. + * + */ + val expire: Long, + + /** + * Session Provider. + * + */ + val provider: String, + + /** + * Session Provider User ID. + * + */ + val providerUid: String, + + /** + * Session Provider Token. + * + */ + val providerToken: String, + + /** + * IP in use when the session was created. + * + */ + val ip: String, + + /** + * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + * + */ + val osCode: String, + + /** + * Operating system name. + * + */ + val osName: String, + + /** + * Operating system version. + * + */ + val osVersion: String, + + /** + * Client type. + * + */ + val clientType: String, + + /** + * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + * + */ + val clientCode: String, + + /** + * Client name. + * + */ + val clientName: String, + + /** + * Client version. + * + */ + val clientVersion: String, + + /** + * Client engine name. + * + */ + val clientEngine: String, + + /** + * Client engine name. + * + */ + val clientEngineVersion: String, + + /** + * Device name. + * + */ + val deviceName: String, + + /** + * Device brand name. + * + */ + val deviceBrand: String, + + /** + * Device model name. + * + */ + val deviceModel: String, + + /** + * Country two-character ISO 3166-1 alpha code. + * + */ + val countryCode: String, + + /** + * Country name. + * + */ + val countryName: String, + + /** + * Returns true if this the current user session. + * + */ + val current: Boolean +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Session( + id = map["\$id"] as String, + userId = map["userId"] as String, + expire = map["expire"] as Long, + provider = map["provider"] as String, + providerUid = map["providerUid"] as String, + providerToken = map["providerToken"] as String, + ip = map["ip"] as String, + osCode = map["osCode"] as String, + osName = map["osName"] as String, + osVersion = map["osVersion"] as String, + clientType = map["clientType"] as String, + clientCode = map["clientCode"] as String, + clientName = map["clientName"] as String, + clientVersion = map["clientVersion"] as String, + clientEngine = map["clientEngine"] as String, + clientEngineVersion = map["clientEngineVersion"] as String, + deviceName = map["deviceName"] as String, + deviceBrand = map["deviceBrand"] as String, + deviceModel = map["deviceModel"] as String, + countryCode = map["countryCode"] as String, + countryName = map["countryName"] as String, + current = map["current"] as Boolean + ) + } + + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "userId" to userId as Any, + "expire" to expire as Any, + "provider" to provider as Any, + "providerUid" to providerUid as Any, + "providerToken" to providerToken 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 new file mode 100644 index 0000000..655701d --- /dev/null +++ b/library/src/main/java/io/appwrite/models/SessionList.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Sessions List + */ +data class SessionList( + /** + * Total number of items available on the server. + * + */ + val sum: Long, + + /** + * List of sessions. + * + */ + val sessions: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = SessionList( + sum = map["sum"] as Long, + sessions = (map["sessions"] as List>).map { Session.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "sum" to sum 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 new file mode 100644 index 0000000..414886a --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Team.kt @@ -0,0 +1,47 @@ +package io.appwrite.models + +/** + * Team + */ +data class Team( + /** + * Team ID. + * + */ + val id: String, + + /** + * Team name. + * + */ + val name: String, + + /** + * Team creation date in Unix timestamp. + * + */ + val dateCreated: Long, + + /** + * Total sum of team members. + * + */ + val sum: Long +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Team( + id = map["\$id"] as String, + name = map["name"] as String, + dateCreated = map["dateCreated"] as Long, + sum = map["sum"] as Long + ) + } + + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "name" to name as Any, + "dateCreated" to dateCreated as Any, + "sum" to sum 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 new file mode 100644 index 0000000..3adca8d --- /dev/null +++ b/library/src/main/java/io/appwrite/models/TeamList.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Teams List + */ +data class TeamList( + /** + * Total number of items available on the server. + * + */ + val sum: Long, + + /** + * List of teams. + * + */ + val teams: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = TeamList( + sum = map["sum"] as Long, + teams = (map["teams"] as List>).map { Team.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "sum" to sum 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 new file mode 100644 index 0000000..5041d1a --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Token.kt @@ -0,0 +1,47 @@ +package io.appwrite.models + +/** + * Token + */ +data class Token( + /** + * Token ID. + * + */ + val id: String, + + /** + * User ID. + * + */ + 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. + * + */ + val secret: String, + + /** + * Token expiration date in Unix timestamp. + * + */ + val expire: Long +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Token( + id = map["\$id"] as String, + userId = map["userId"] as String, + secret = map["secret"] as String, + expire = map["expire"] as Long + ) + } + + fun toMap(): Map = mapOf( + "\$id" to id 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/models/User.kt b/library/src/main/java/io/appwrite/models/User.kt new file mode 100644 index 0000000..82039e4 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/User.kt @@ -0,0 +1,79 @@ +package io.appwrite.models + +/** + * User + */ +data class User( + /** + * User ID. + * + */ + val id: String, + + /** + * User name. + * + */ + val name: String, + + /** + * User registration date in Unix timestamp. + * + */ + val registration: Long, + + /** + * User status. 0 for Unactivated, 1 for active and 2 is blocked. + * + */ + val status: Long, + + /** + * Unix timestamp of the most recent password update + * + */ + val passwordUpdate: Long, + + /** + * User email address. + * + */ + val email: String, + + /** + * Email verification status. + * + */ + val emailVerification: Boolean, + + /** + * User preferences as a key-value object + * + */ + val prefs: Preferences +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = User( + id = map["\$id"] as String, + name = map["name"] as String, + registration = map["registration"] as Long, + status = map["status"] as Long, + passwordUpdate = map["passwordUpdate"] as Long, + email = map["email"] as String, + emailVerification = map["emailVerification"] as Boolean, + prefs = Preferences.from(map = map["prefs"] as Map) + ) + } + + fun toMap(): Map = mapOf( + "\$id" to id 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, + "emailVerification" to emailVerification as Any, + "prefs" to prefs.toMap() 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 fa9cd0f..063d602 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -2,6 +2,7 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client +import io.appwrite.models.* import io.appwrite.WebAuthComponent import androidx.activity.ComponentActivity import io.appwrite.exceptions.AppwriteException @@ -18,20 +19,28 @@ class Account(client: Client) : Service(client) { * * Get currently logged in user data as JSON object. * - * @return [Response] + * @return [io.appwrite.models.User] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun get(): Response { + suspend fun get(): io.appwrite.models.User { val path = "/account" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.User::class.java, + convert = convert + ) } /** @@ -44,10 +53,10 @@ class Account(client: Client) : Service(client) { * login to their new account, you need to create a new [account * session](/docs/client/account#accountCreateSession). * - * @param email - * @param password - * @param name - * @return [Response] + * @param email User email. + * @param password User password. Must be between 6 to 32 chars. + * @param name User name. Max length: 128 chars. + * @return [io.appwrite.models.User] */ @JvmOverloads @Throws(AppwriteException::class) @@ -55,19 +64,27 @@ class Account(client: Client) : Service(client) { email: String, password: String, name: String? = null - ): Response { + ): io.appwrite.models.User { val path = "/account" val params = mapOf( "email" to email, "password" to password, "name" to name ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("POST", path, headers, params) + val convert: (Map) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.User::class.java, + convert = convert + ) } /** @@ -79,20 +96,24 @@ class Account(client: Client) : Service(client) { * address. Any user-related resources like documents or storage files should * be deleted separately. * - * @return [Response] + * @return [Any] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun delete(): Response { + suspend fun delete(): Any { val path = "/account" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("DELETE", path, headers, params) + return client.call( + "DELETE", + path, + headers, + params, + responseType = Any::class.java, + ) } /** @@ -105,27 +126,35 @@ class Account(client: Client) : Service(client) { * 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 - * @param password - * @return [Response] + * @param email User email. + * @param password User password. Must be between 6 to 32 chars. + * @return [io.appwrite.models.User] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun updateEmail( email: String, password: String - ): Response { + ): io.appwrite.models.User { val path = "/account/email" val params = mapOf( "email" to email, "password" to password ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("PATCH", path, headers, params) + val convert: (Map) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.User::class.java, + convert = convert + ) } /** @@ -134,22 +163,31 @@ class Account(client: Client) : Service(client) { * 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. + * from its creation and will be invalid if the user will logout in that time + * frame. * - * @return [Response] + * @return [io.appwrite.models.Jwt] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun createJWT(): Response { + suspend fun createJWT(): io.appwrite.models.Jwt { val path = "/account/jwt" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("POST", path, headers, params) + val convert: (Map) -> io.appwrite.models.Jwt = { + io.appwrite.models.Jwt.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Jwt::class.java, + convert = convert + ) } /** @@ -158,20 +196,28 @@ class Account(client: Client) : Service(client) { * Get currently logged in user list of latest security activity logs. Each * log returns user IP address, location and date and time of log. * - * @return [Response] + * @return [io.appwrite.models.LogList] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getLogs(): Response { + suspend fun getLogs(): io.appwrite.models.LogList { val path = "/account/logs" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.LogList = { + io.appwrite.models.LogList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.LogList::class.java, + convert = convert + ) } /** @@ -179,24 +225,32 @@ class Account(client: Client) : Service(client) { * * Update currently logged in user account name. * - * @param name - * @return [Response] + * @param name User name. Max length: 128 chars. + * @return [io.appwrite.models.User] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun updateName( name: String - ): Response { + ): io.appwrite.models.User { val path = "/account/name" val params = mapOf( "name" to name ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("PATCH", path, headers, params) + val convert: (Map) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.User::class.java, + convert = convert + ) } /** @@ -206,27 +260,35 @@ class Account(client: Client) : Service(client) { * to pass in the new password, and the old password. For users created with * OAuth and Team Invites, oldPassword is optional. * - * @param password - * @param oldPassword - * @return [Response] + * @param password New user password. Must be between 6 to 32 chars. + * @param oldPassword Old user password. Must be between 6 to 32 chars. + * @return [io.appwrite.models.User] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun updatePassword( password: String, oldPassword: String? = null - ): Response { + ): io.appwrite.models.User { val path = "/account/password" val params = mapOf( "password" to password, "oldPassword" to oldPassword ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("PATCH", path, headers, params) + val convert: (Map) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.User::class.java, + convert = convert + ) } /** @@ -234,20 +296,28 @@ class Account(client: Client) : Service(client) { * * Get currently logged in user preferences as a key-value object. * - * @return [Response] + * @return [io.appwrite.models.Preferences] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getPrefs(): Response { + suspend fun getPrefs(): io.appwrite.models.Preferences { val path = "/account/prefs" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.Preferences = { + io.appwrite.models.Preferences.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.Preferences::class.java, + convert = convert + ) } /** @@ -256,24 +326,32 @@ class Account(client: Client) : Service(client) { * Update currently logged in user account preferences. You can pass only the * specific settings you wish to update. * - * @param prefs - * @return [Response] + * @param prefs Prefs key-value JSON object. + * @return [io.appwrite.models.User] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun updatePrefs( prefs: Any - ): Response { + ): io.appwrite.models.User { val path = "/account/prefs" val params = mapOf( "prefs" to prefs ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("PATCH", path, headers, params) + val convert: (Map) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.User::class.java, + convert = convert + ) } /** @@ -288,27 +366,35 @@ class Account(client: Client) : Service(client) { * complete the process. The verification link sent to the user's email * address is valid for 1 hour. * - * @param email - * @param url - * @return [Response] + * @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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun createRecovery( email: String, url: String - ): Response { + ): io.appwrite.models.Token { val path = "/account/recovery" val params = mapOf( "email" to email, "url" to url ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("POST", path, headers, params) + val convert: (Map) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Token::class.java, + convert = convert + ) } /** @@ -324,11 +410,11 @@ class Account(client: Client) : Service(client) { * the only valid redirect URLs are the ones from domains you have set when * adding your platforms in the console interface. * - * @param userId - * @param secret - * @param password - * @param passwordAgain - * @return [Response] + * @param userId User account UID address. + * @param secret Valid reset token. + * @param password New password. Must be between 6 to 32 chars. + * @param passwordAgain New password again. Must be between 6 to 32 chars. + * @return [io.appwrite.models.Token] */ @JvmOverloads @Throws(AppwriteException::class) @@ -337,7 +423,7 @@ class Account(client: Client) : Service(client) { secret: String, password: String, passwordAgain: String - ): Response { + ): io.appwrite.models.Token { val path = "/account/recovery" val params = mapOf( "userId" to userId, @@ -345,12 +431,20 @@ class Account(client: Client) : Service(client) { "password" to password, "passwordAgain" to passwordAgain ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("PUT", path, headers, params) + val convert: (Map) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it) + } + return client.call( + "PUT", + path, + headers, + params, + responseType = io.appwrite.models.Token::class.java, + convert = convert + ) } /** @@ -359,20 +453,28 @@ class Account(client: Client) : Service(client) { * Get currently logged in user list of active sessions across different * devices. * - * @return [Response] + * @return [io.appwrite.models.SessionList] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getSessions(): Response { + suspend fun getSessions(): io.appwrite.models.SessionList { val path = "/account/sessions" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.SessionList = { + io.appwrite.models.SessionList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.SessionList::class.java, + convert = convert + ) } /** @@ -381,27 +483,35 @@ class Account(client: Client) : Service(client) { * 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. * - * @param email - * @param password - * @return [Response] + * @param email User email. + * @param password User password. Must be between 6 to 32 chars. + * @return [io.appwrite.models.Session] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun createSession( email: String, password: String - ): Response { + ): io.appwrite.models.Session { val path = "/account/sessions" val params = mapOf( "email" to email, "password" to password ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("POST", path, headers, params) + val convert: (Map) -> io.appwrite.models.Session = { + io.appwrite.models.Session.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Session::class.java, + convert = convert + ) } /** @@ -410,20 +520,24 @@ class Account(client: Client) : Service(client) { * Delete all sessions from the user account and remove any sessions cookies * from the end client. * - * @return [Response] + * @return [Any] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun deleteSessions(): Response { + suspend fun deleteSessions(): Any { val path = "/account/sessions" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("DELETE", path, headers, params) + return client.call( + "DELETE", + path, + headers, + params, + responseType = Any::class.java, + ) } /** @@ -431,24 +545,33 @@ class Account(client: Client) : Service(client) { * * 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 - * account, you need to update its [email and - * password](/docs/client/account#accountUpdateEmail). + * 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 [Response] + * @return [io.appwrite.models.Session] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun createAnonymousSession(): Response { + suspend fun createAnonymousSession(): io.appwrite.models.Session { val path = "/account/sessions/anonymous" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("POST", path, headers, params) + val convert: (Map) -> io.appwrite.models.Session = { + io.appwrite.models.Session.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Session::class.java, + convert = convert + ) } /** @@ -465,27 +588,35 @@ class Account(client: Client) : Service(client) { * the URL parameter empty, so that the login completion will be handled by * your Appwrite instance by default. * - * @param email - * @param url - * @return [Response] + * @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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun createMagicURLSession( email: String, url: String? = null - ): Response { + ): io.appwrite.models.Token { val path = "/account/sessions/magic-url" val params = mapOf( "email" to email, "url" to url ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("POST", path, headers, params) + val convert: (Map) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Token::class.java, + convert = convert + ) } /** @@ -503,27 +634,35 @@ class Account(client: Client) : Service(client) { * the only valid redirect URLs are the ones from domains you have set when * adding your platforms in the console interface. * - * @param userId - * @param secret - * @return [Response] + * @param userId User unique ID. + * @param secret Valid verification token. + * @return [io.appwrite.models.Session] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun updateMagicURLSession( userId: String, secret: String - ): Response { + ): io.appwrite.models.Session { val path = "/account/sessions/magic-url" val params = mapOf( "userId" to userId, "secret" to secret ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("PUT", path, headers, params) + val convert: (Map) -> io.appwrite.models.Session = { + io.appwrite.models.Session.from(map = it) + } + return client.call( + "PUT", + path, + headers, + params, + responseType = io.appwrite.models.Session::class.java, + convert = convert + ) } /** @@ -542,10 +681,10 @@ class Account(client: Client) : Service(client) { * user.. * * - * @param provider - * @param success - * @param failure - * @param scopes + * @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, bitbucket, bitly, box, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, paypal, paypalSandbox, salesforce, slack, spotify, tradeshift, tradeshiftBox, twitch, vk, yahoo, yandex, wordpress. + * @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. * */ @JvmOverloads @@ -564,7 +703,6 @@ class Account(client: Client) : Service(client) { "scopes" to scopes, "project" to client.config["project"] ) - val query = mutableListOf() params.forEach { when (it.value) { @@ -607,7 +745,39 @@ class Account(client: Client) : Service(client) { listOf(cookie) ) } - + } + + /** + * Get Session By ID + * + * 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 unique ID. Use the string 'current' to get the current device 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) + val params = mapOf( + ) + val headers = mapOf( + "content-type" to "application/json" + ) + val convert: (Map) -> io.appwrite.models.Session = { + io.appwrite.models.Session.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.Session::class.java, + convert = convert + ) } /** @@ -617,23 +787,27 @@ class Account(client: Client) : Service(client) { * account sessions across all of their different devices. When using the * option id argument, only the session unique ID provider will be deleted. * - * @param sessionId - * @return [Response] + * @param sessionId Session unique ID. Use the string 'current' to delete the current device session. + * @return [Any] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun deleteSession( sessionId: String - ): Response { + ): Any { val path = "/account/sessions/{sessionId}".replace("{sessionId}", sessionId) val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("DELETE", path, headers, params) + return client.call( + "DELETE", + path, + headers, + params, + responseType = Any::class.java, + ) } /** @@ -655,24 +829,32 @@ class Account(client: Client) : Service(client) { * adding your platforms in the console interface. * * - * @param url - * @return [Response] + * @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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun createVerification( url: String - ): Response { + ): io.appwrite.models.Token { val path = "/account/verification" val params = mapOf( "url" to url ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("POST", path, headers, params) + val convert: (Map) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Token::class.java, + convert = convert + ) } /** @@ -683,27 +865,35 @@ class Account(client: Client) : Service(client) { * to verify the user email ownership. If confirmed this route will return a * 200 status code. * - * @param userId - * @param secret - * @return [Response] + * @param userId User unique ID. + * @param secret Valid verification token. + * @return [io.appwrite.models.Token] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun updateVerification( userId: String, secret: String - ): Response { + ): io.appwrite.models.Token { val path = "/account/verification" val params = mapOf( "userId" to userId, "secret" to secret ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("PUT", path, headers, params) + val convert: (Map) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it) + } + return client.call( + "PUT", + path, + headers, + params, + responseType = io.appwrite.models.Token::class.java, + convert = convert + ) } } \ 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 3e0432f..912b1e5 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -2,6 +2,7 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client +import io.appwrite.models.* import io.appwrite.exceptions.AppwriteException import okhttp3.Cookie import okhttp3.Response @@ -19,20 +20,20 @@ class Avatars(client: Client) : Service(client) { * /account/sessions endpoint. Use width, height and quality arguments to * change the output settings. * - * @param code - * @param width - * @param height - * @param quality - * @return [Response] + * @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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getBrowser( code: String, - width: Int? = null, - height: Int? = null, - quality: Int? = null - ): Response { + width: Long? = null, + height: Long? = null, + quality: Long? = null + ): ByteArray { val path = "/avatars/browsers/{code}".replace("{code}", code) val params = mapOf( "width" to width, @@ -40,8 +41,12 @@ class Avatars(client: Client) : Service(client) { "quality" to quality, "project" to client.config["project"] ) - - return client.call("GET", path, params = params) + return client.call( + "GET", + path, + params = params, + responseType = ByteArray::class.java + ) } /** @@ -51,20 +56,20 @@ class Avatars(client: Client) : Service(client) { * provider you need. Use width, height and quality arguments to change the * output settings. * - * @param code - * @param width - * @param height - * @param quality - * @return [Response] + * @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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getCreditCard( code: String, - width: Int? = null, - height: Int? = null, - quality: Int? = null - ): Response { + width: Long? = null, + height: Long? = null, + quality: Long? = null + ): ByteArray { val path = "/avatars/credit-cards/{code}".replace("{code}", code) val params = mapOf( "width" to width, @@ -72,8 +77,12 @@ class Avatars(client: Client) : Service(client) { "quality" to quality, "project" to client.config["project"] ) - - return client.call("GET", path, params = params) + return client.call( + "GET", + path, + params = params, + responseType = ByteArray::class.java + ) } /** @@ -83,21 +92,25 @@ class Avatars(client: Client) : Service(client) { * website URL. * * - * @param url - * @return [Response] + * @param url Website URL which you want to fetch the favicon from. + * @return [ByteArray] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getFavicon( url: String - ): Response { + ): ByteArray { val path = "/avatars/favicon" val params = mapOf( "url" to url, "project" to client.config["project"] ) - - return client.call("GET", path, params = params) + return client.call( + "GET", + path, + params = params, + responseType = ByteArray::class.java + ) } /** @@ -107,20 +120,20 @@ class Avatars(client: Client) : Service(client) { * users. The code argument receives the 2 letter country code. Use width, * height and quality arguments to change the output settings. * - * @param code - * @param width - * @param height - * @param quality - * @return [Response] + * @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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getFlag( code: String, - width: Int? = null, - height: Int? = null, - quality: Int? = null - ): Response { + width: Long? = null, + height: Long? = null, + quality: Long? = null + ): ByteArray { val path = "/avatars/flags/{code}".replace("{code}", code) val params = mapOf( "width" to width, @@ -128,8 +141,12 @@ class Avatars(client: Client) : Service(client) { "quality" to quality, "project" to client.config["project"] ) - - return client.call("GET", path, params = params) + return client.call( + "GET", + path, + params = params, + responseType = ByteArray::class.java + ) } /** @@ -140,18 +157,18 @@ class Avatars(client: Client) : Service(client) { * remote images in your app or in case you want to make sure a 3rd party * image is properly served using a TLS protocol. * - * @param url - * @param width - * @param height - * @return [Response] + * @param url Image URL which you want to crop. + * @param width Resize preview image width, Pass an integer between 0 to 2000. + * @param height Resize preview image height, Pass an integer between 0 to 2000. + * @return [ByteArray] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getImage( url: String, - width: Int? = null, - height: Int? = null - ): Response { + width: Long? = null, + height: Long? = null + ): ByteArray { val path = "/avatars/image" val params = mapOf( "url" to url, @@ -159,8 +176,12 @@ class Avatars(client: Client) : Service(client) { "height" to height, "project" to client.config["project"] ) - - return client.call("GET", path, params = params) + return client.call( + "GET", + path, + params = params, + responseType = ByteArray::class.java + ) } /** @@ -177,22 +198,22 @@ class Avatars(client: Client) : Service(client) { * the user's initials when reloading the same theme will always return for * the same initials. * - * @param name - * @param width - * @param height - * @param color - * @param background - * @return [Response] + * @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 color Changes text color. By default a random color will be picked and stay will persistent to the given name. + * @param background Changes background color. By default a random color will be picked and stay will persistent to the given name. + * @return [ByteArray] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getInitials( name: String? = null, - width: Int? = null, - height: Int? = null, + width: Long? = null, + height: Long? = null, color: String? = null, background: String? = null - ): Response { + ): ByteArray { val path = "/avatars/initials" val params = mapOf( "name" to name, @@ -202,8 +223,12 @@ class Avatars(client: Client) : Service(client) { "background" to background, "project" to client.config["project"] ) - - return client.call("GET", path, params = params) + return client.call( + "GET", + path, + params = params, + responseType = ByteArray::class.java + ) } /** @@ -212,20 +237,20 @@ class Avatars(client: Client) : Service(client) { * 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 - * @param size - * @param margin - * @param download - * @return [Response] + * @param text Plain text to be converted to QR code image. + * @param size QR code size. Pass an integer between 0 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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getQR( text: String, - size: Int? = null, - margin: Int? = null, + size: Long? = null, + margin: Long? = null, download: Boolean? = null - ): Response { + ): ByteArray { val path = "/avatars/qr" val params = mapOf( "text" to text, @@ -234,8 +259,12 @@ class Avatars(client: Client) : Service(client) { "download" to download, "project" to client.config["project"] ) - - return client.call("GET", path, params = params) + return client.call( + "GET", + path, + params = params, + responseType = ByteArray::class.java + ) } } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Database.kt b/library/src/main/java/io/appwrite/services/Database.kt index fc7fc9b..6baecdc 100644 --- a/library/src/main/java/io/appwrite/services/Database.kt +++ b/library/src/main/java/io/appwrite/services/Database.kt @@ -2,6 +2,7 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client +import io.appwrite.models.* import io.appwrite.exceptions.AppwriteException import okhttp3.Cookie import okhttp3.Response @@ -9,163 +10,6 @@ import java.io.File class Database(client: Client) : Service(client) { - /** - * List Collections - * - * Get a list of all the user collections. 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 collections. [Learn more about different API - * modes](/docs/admin). - * - * @param search - * @param limit - * @param offset - * @param orderType - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun listCollections( - search: String? = null, - limit: Int? = null, - offset: Int? = null, - orderType: String? = null - ): Response { - val path = "/database/collections" - val params = mapOf( - "search" to search, - "limit" to limit, - "offset" to offset, - "orderType" to orderType - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Create Collection - * - * Create a new Collection. - * - * @param name - * @param read - * @param write - * @param rules - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun createCollection( - name: String, - read: List, - write: List, - rules: List - ): Response { - val path = "/database/collections" - val params = mapOf( - "name" to name, - "read" to read, - "write" to write, - "rules" to rules - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("POST", path, headers, params) - } - - /** - * Get Collection - * - * Get a collection by its unique ID. This endpoint response returns a JSON - * object with the collection metadata. - * - * @param collectionId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getCollection( - collectionId: String - ): Response { - val path = "/database/collections/{collectionId}".replace("{collectionId}", collectionId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Update Collection - * - * Update a collection by its unique ID. - * - * @param collectionId - * @param name - * @param read - * @param write - * @param rules - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun updateCollection( - collectionId: String, - name: String, - read: List? = null, - write: List? = null, - rules: List? = null - ): Response { - val path = "/database/collections/{collectionId}".replace("{collectionId}", collectionId) - val params = mapOf( - "name" to name, - "read" to read, - "write" to write, - "rules" to rules - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("PUT", path, headers, params) - } - - /** - * Delete Collection - * - * Delete a collection by its unique ID. Only users with write permissions - * have access to delete this resource. - * - * @param collectionId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun deleteCollection( - collectionId: String - ): Response { - val path = "/database/collections/{collectionId}".replace("{collectionId}", collectionId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("DELETE", path, headers, params) - } - /** * List Documents * @@ -174,28 +18,28 @@ class Database(client: Client) : Service(client) { * of the project's documents. [Learn more about different API * modes](/docs/admin). * - * @param collectionId - * @param filters - * @param limit - * @param offset - * @param orderField - * @param orderType - * @param orderCast - * @param search - * @return [Response] + * @param collectionId Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection). + * @param filters Array of filter strings. Each filter is constructed from a key name, comparison operator (=, !=, >, <, <=, >=) and a value. You can also use a dot (.) separator in attribute names to filter by child document attributes. Examples: 'name=John Doe' or 'category.$id>=5bed2d152c362'. + * @param limit Maximum number of documents to return in response. Use this value to manage pagination. By default will return maximum 25 results. Maximum of 100 results allowed per request. + * @param offset Offset value. The default value is 0. Use this param to manage pagination. + * @param orderField Document field that results will be sorted by. + * @param orderType Order direction. Possible values are DESC for descending order, or ASC for ascending order. + * @param orderCast Order field type casting. Possible values are int, string, date, time or datetime. The database will attempt to cast the order field to the value you pass here. The default value is a string. + * @param search Search query. Enter any free text search. The database will try to find a match against all document attributes and children. Max length: 256 chars. + * @return [io.appwrite.models.DocumentList] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun listDocuments( collectionId: String, filters: List? = null, - limit: Int? = null, - offset: Int? = null, + limit: Long? = null, + offset: Long? = null, orderField: String? = null, orderType: String? = null, orderCast: String? = null, search: String? = null - ): Response { + ): io.appwrite.models.DocumentList { val path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId) val params = mapOf( "filters" to filters, @@ -206,12 +50,20 @@ class Database(client: Client) : Service(client) { "orderCast" to orderCast, "search" to search ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.DocumentList = { + io.appwrite.models.DocumentList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.DocumentList::class.java, + convert = convert + ) } /** @@ -222,14 +74,14 @@ class Database(client: Client) : Service(client) { * integration](/docs/server/database#databaseCreateCollection) API or * directly from your database console. * - * @param collectionId - * @param data - * @param read - * @param write - * @param parentDocument - * @param parentProperty - * @param parentPropertyType - * @return [Response] + * @param collectionId Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection). + * @param data Document data as JSON object. + * @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. + * @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. + * @param parentDocument Parent document unique ID. Use when you want your new document to be a child of a parent document. + * @param parentProperty Parent document property name. Use when you want your new document to be a child of a parent document. + * @param parentPropertyType Parent document property connection type. You can set this value to **assign**, **append** or **prepend**, default value is assign. Use when you want your new document to be a child of a parent document. + * @return [io.appwrite.models.Document] */ @JvmOverloads @Throws(AppwriteException::class) @@ -241,7 +93,7 @@ class Database(client: Client) : Service(client) { parentDocument: String? = null, parentProperty: String? = null, parentPropertyType: String? = null - ): Response { + ): io.appwrite.models.Document { val path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId) val params = mapOf( "data" to data, @@ -251,12 +103,20 @@ class Database(client: Client) : Service(client) { "parentProperty" to parentProperty, "parentPropertyType" to parentPropertyType ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("POST", path, headers, params) + val convert: (Map) -> io.appwrite.models.Document = { + io.appwrite.models.Document.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Document::class.java, + convert = convert + ) } /** @@ -265,25 +125,33 @@ class Database(client: Client) : Service(client) { * Get a document by its unique ID. This endpoint response returns a JSON * object with the document data. * - * @param collectionId - * @param documentId - * @return [Response] + * @param collectionId Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection). + * @param documentId Document unique ID. + * @return [io.appwrite.models.Document] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getDocument( collectionId: String, documentId: String - ): Response { + ): io.appwrite.models.Document { val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId) val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.Document = { + io.appwrite.models.Document.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.Document::class.java, + convert = convert + ) } /** @@ -292,12 +160,12 @@ class Database(client: Client) : Service(client) { * Update a document by its unique ID. Using the patch method you can pass * only specific fields that will get updated. * - * @param collectionId - * @param documentId - * @param data - * @param read - * @param write - * @return [Response] + * @param collectionId Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection). + * @param documentId Document unique ID. + * @param data Document data as JSON object. + * @param read An array of strings with read permissions. By default inherits the existing read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. + * @param write An array of strings with write permissions. By default inherits the existing write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. + * @return [io.appwrite.models.Document] */ @JvmOverloads @Throws(AppwriteException::class) @@ -307,19 +175,27 @@ class Database(client: Client) : Service(client) { data: Any, read: List? = null, write: List? = null - ): Response { + ): io.appwrite.models.Document { val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId) val params = mapOf( "data" to data, "read" to read, "write" to write ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("PATCH", path, headers, params) + val convert: (Map) -> io.appwrite.models.Document = { + io.appwrite.models.Document.from(map = it) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.Document::class.java, + convert = convert + ) } /** @@ -329,25 +205,29 @@ class Database(client: Client) : Service(client) { * documents, its attributes and relations to other documents. Child documents * **will not** be deleted. * - * @param collectionId - * @param documentId - * @return [Response] + * @param collectionId Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection). + * @param documentId Document unique ID. + * @return [Any] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun deleteDocument( collectionId: String, documentId: String - ): Response { + ): Any { val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId) val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("DELETE", path, headers, params) + return client.call( + "DELETE", + path, + headers, + params, + 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 fba3eba..83ac165 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -2,6 +2,7 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client +import io.appwrite.models.* import io.appwrite.exceptions.AppwriteException import okhttp3.Cookie import okhttp3.Response @@ -9,176 +10,6 @@ import java.io.File class Functions(client: Client) : Service(client) { - /** - * List Functions - * - * Get a list of all the project's functions. You can use the query params to - * filter your results. - * - * @param search - * @param limit - * @param offset - * @param orderType - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun list( - search: String? = null, - limit: Int? = null, - offset: Int? = null, - orderType: String? = null - ): Response { - val path = "/functions" - val params = mapOf( - "search" to search, - "limit" to limit, - "offset" to offset, - "orderType" to orderType - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Create Function - * - * Create a new function. You can pass a list of - * [permissions](/docs/permissions) to allow different project users or team - * with access to execute the function using the client API. - * - * @param name - * @param execute - * @param env - * @param vars - * @param events - * @param schedule - * @param timeout - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun create( - name: String, - execute: List, - env: String, - vars: Any? = null, - events: List? = null, - schedule: String? = null, - timeout: Int? = null - ): Response { - val path = "/functions" - val params = mapOf( - "name" to name, - "execute" to execute, - "env" to env, - "vars" to vars, - "events" to events, - "schedule" to schedule, - "timeout" to timeout - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("POST", path, headers, params) - } - - /** - * Get Function - * - * Get a function by its unique ID. - * - * @param functionId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun get( - functionId: String - ): Response { - val path = "/functions/{functionId}".replace("{functionId}", functionId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Update Function - * - * Update function by its unique ID. - * - * @param functionId - * @param name - * @param execute - * @param vars - * @param events - * @param schedule - * @param timeout - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun update( - functionId: String, - name: String, - execute: List, - vars: Any? = null, - events: List? = null, - schedule: String? = null, - timeout: Int? = null - ): Response { - val path = "/functions/{functionId}".replace("{functionId}", functionId) - val params = mapOf( - "name" to name, - "execute" to execute, - "vars" to vars, - "events" to events, - "schedule" to schedule, - "timeout" to timeout - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("PUT", path, headers, params) - } - - /** - * Delete Function - * - * Delete a function by its unique ID. - * - * @param functionId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun delete( - functionId: String - ): Response { - val path = "/functions/{functionId}".replace("{functionId}", functionId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("DELETE", path, headers, params) - } - /** * List Executions * @@ -187,22 +18,22 @@ class Functions(client: Client) : Service(client) { * return a list of all of the project's executions. [Learn more about * different API modes](/docs/admin). * - * @param functionId - * @param search - * @param limit - * @param offset - * @param orderType - * @return [Response] + * @param functionId Function unique ID. + * @param search Search term to filter your list results. Max length: 256 chars. + * @param limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. + * @param offset Results offset. The default value is 0. Use this param to manage pagination. + * @param orderType Order result by ASC or DESC order. + * @return [io.appwrite.models.ExecutionList] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun listExecutions( functionId: String, search: String? = null, - limit: Int? = null, - offset: Int? = null, + limit: Long? = null, + offset: Long? = null, orderType: String? = null - ): Response { + ): io.appwrite.models.ExecutionList { val path = "/functions/{functionId}/executions".replace("{functionId}", functionId) val params = mapOf( "search" to search, @@ -210,12 +41,20 @@ class Functions(client: Client) : Service(client) { "offset" to offset, "orderType" to orderType ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.ExecutionList = { + io.appwrite.models.ExecutionList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.ExecutionList::class.java, + convert = convert + ) } /** @@ -226,26 +65,34 @@ class Functions(client: Client) : Service(client) { * updates on the current execution status. Once this endpoint is called, your * function execution process will start asynchronously. * - * @param functionId - * @param data - * @return [Response] + * @param functionId Function unique ID. + * @param data String of custom data to send to function. + * @return [io.appwrite.models.Execution] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun createExecution( functionId: String, data: String? = null - ): Response { + ): io.appwrite.models.Execution { val path = "/functions/{functionId}/executions".replace("{functionId}", functionId) val params = mapOf( "data" to data ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("POST", path, headers, params) + val convert: (Map) -> io.appwrite.models.Execution = { + io.appwrite.models.Execution.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Execution::class.java, + convert = convert + ) } /** @@ -253,207 +100,33 @@ class Functions(client: Client) : Service(client) { * * Get a function execution log by its unique ID. * - * @param functionId - * @param executionId - * @return [Response] + * @param functionId Function unique ID. + * @param executionId Execution unique ID. + * @return [io.appwrite.models.Execution] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getExecution( functionId: String, executionId: String - ): Response { + ): io.appwrite.models.Execution { val path = "/functions/{functionId}/executions/{executionId}".replace("{functionId}", functionId).replace("{executionId}", executionId) val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) - } - - /** - * Update Function Tag - * - * Update the function code tag ID using the unique function ID. Use this - * endpoint to switch the code tag that should be executed by the execution - * endpoint. - * - * @param functionId - * @param tag - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun updateTag( - functionId: String, - tag: String - ): Response { - val path = "/functions/{functionId}/tag".replace("{functionId}", functionId) - val params = mapOf( - "tag" to tag - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("PATCH", path, headers, params) - } - - /** - * List Tags - * - * Get a list of all the project's code tags. You can use the query params to - * filter your results. - * - * @param functionId - * @param search - * @param limit - * @param offset - * @param orderType - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun listTags( - functionId: String, - search: String? = null, - limit: Int? = null, - offset: Int? = null, - orderType: String? = null - ): Response { - val path = "/functions/{functionId}/tags".replace("{functionId}", functionId) - val params = mapOf( - "search" to search, - "limit" to limit, - "offset" to offset, - "orderType" to orderType - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Create Tag - * - * Create a new function code tag. Use this endpoint to upload a new version - * of your code function. To execute your newly uploaded code, you'll need to - * update the function's tag to use your new tag UID. - * - * This endpoint accepts a tar.gz file compressed with your code. Make sure to - * include any dependencies your code has within the compressed file. You can - * learn more about code packaging in the [Appwrite Cloud Functions - * tutorial](/docs/functions). - * - * Use the "command" param to set the entry point used to execute your code. - * - * @param functionId - * @param command - * @param code - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun createTag( - functionId: String, - command: String, - code: File - ): Response { - val path = "/functions/{functionId}/tags".replace("{functionId}", functionId) - val params = mapOf( - "command" to command, - "code" to code - ) - - val headers = mapOf( - "content-type" to "multipart/form-data" - ) - - return client.call("POST", path, headers, params) - } - - /** - * Get Tag - * - * Get a code tag by its unique ID. - * - * @param functionId - * @param tagId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getTag( - functionId: String, - tagId: String - ): Response { - val path = "/functions/{functionId}/tags/{tagId}".replace("{functionId}", functionId).replace("{tagId}", tagId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" + val convert: (Map) -> io.appwrite.models.Execution = { + io.appwrite.models.Execution.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.Execution::class.java, + convert = convert ) - - return client.call("GET", path, headers, params) - } - - /** - * Delete Tag - * - * Delete a code tag by its unique ID. - * - * @param functionId - * @param tagId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun deleteTag( - functionId: String, - tagId: String - ): Response { - val path = "/functions/{functionId}/tags/{tagId}".replace("{functionId}", functionId).replace("{tagId}", tagId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("DELETE", path, headers, params) - } - - /** - * Get Function Usage - * - * @param functionId - * @param range - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getUsage( - functionId: String, - range: String? = null - ): Response { - val path = "/functions/{functionId}/usage".replace("{functionId}", functionId) - val params = mapOf( - "range" to range - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) } } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Health.kt b/library/src/main/java/io/appwrite/services/Health.kt deleted file mode 100644 index cada8d5..0000000 --- a/library/src/main/java/io/appwrite/services/Health.kt +++ /dev/null @@ -1,275 +0,0 @@ -package io.appwrite.services - -import android.net.Uri -import io.appwrite.Client -import io.appwrite.exceptions.AppwriteException -import okhttp3.Cookie -import okhttp3.Response -import java.io.File - -class Health(client: Client) : Service(client) { - - /** - * Get HTTP - * - * Check the Appwrite HTTP server is up and responsive. - * - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun get(): Response { - val path = "/health" - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Get Anti virus - * - * Check the Appwrite Anti Virus server is up and connection is successful. - * - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getAntiVirus(): Response { - val path = "/health/anti-virus" - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Get Cache - * - * Check the Appwrite in-memory cache server is up and connection is - * successful. - * - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getCache(): Response { - val path = "/health/cache" - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Get DB - * - * Check the Appwrite database server is up and connection is successful. - * - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getDB(): Response { - val path = "/health/db" - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Get Certificate Queue - * - * Get the number of certificates that are waiting to be issued against - * [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue - * server. - * - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getQueueCertificates(): Response { - val path = "/health/queue/certificates" - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Get Functions Queue - * - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getQueueFunctions(): Response { - val path = "/health/queue/functions" - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Get Logs Queue - * - * Get the number of logs that are waiting to be processed in the Appwrite - * internal queue server. - * - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getQueueLogs(): Response { - val path = "/health/queue/logs" - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Get Tasks Queue - * - * Get the number of tasks that are waiting to be processed in the Appwrite - * internal queue server. - * - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getQueueTasks(): Response { - val path = "/health/queue/tasks" - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Get Usage Queue - * - * Get the number of usage stats that are waiting to be processed in the - * Appwrite internal queue server. - * - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getQueueUsage(): Response { - val path = "/health/queue/usage" - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Get Webhooks Queue - * - * Get the number of webhooks that are waiting to be processed in the Appwrite - * internal queue server. - * - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getQueueWebhooks(): Response { - val path = "/health/queue/webhooks" - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Get Local Storage - * - * Check the Appwrite local storage device is up and connection is successful. - * - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getStorageLocal(): Response { - val path = "/health/storage/local" - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Get Time - * - * Check the Appwrite server time is synced with Google remote NTP server. We - * use this technology to smoothly handle leap seconds with no disruptive - * events. The [Network Time - * Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is - * used by hundreds of millions of computers and devices to synchronize their - * clocks over the Internet. If your computer sets its own clock, it likely - * uses NTP. - * - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getTime(): Response { - val path = "/health/time" - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - -} \ 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 415df78..423a323 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -2,6 +2,7 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client +import io.appwrite.models.* import io.appwrite.exceptions.AppwriteException import okhttp3.Cookie import okhttp3.Response @@ -19,20 +20,28 @@ class Locale(client: Client) : Service(client) { * * ([IP Geolocation by DB-IP](https://db-ip.com)) * - * @return [Response] + * @return [io.appwrite.models.Locale] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun get(): Response { + suspend fun get(): io.appwrite.models.Locale { val path = "/locale" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.Locale = { + io.appwrite.models.Locale.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.Locale::class.java, + convert = convert + ) } /** @@ -41,20 +50,28 @@ class Locale(client: Client) : Service(client) { * List of all continents. You can use the locale header to get the data in a * supported language. * - * @return [Response] + * @return [io.appwrite.models.ContinentList] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getContinents(): Response { + suspend fun getContinents(): io.appwrite.models.ContinentList { val path = "/locale/continents" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.ContinentList = { + io.appwrite.models.ContinentList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.ContinentList::class.java, + convert = convert + ) } /** @@ -63,20 +80,28 @@ class Locale(client: Client) : Service(client) { * List of all countries. You can use the locale header to get the data in a * supported language. * - * @return [Response] + * @return [io.appwrite.models.CountryList] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getCountries(): Response { + suspend fun getCountries(): io.appwrite.models.CountryList { val path = "/locale/countries" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.CountryList = { + io.appwrite.models.CountryList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.CountryList::class.java, + convert = convert + ) } /** @@ -85,20 +110,28 @@ class Locale(client: Client) : Service(client) { * 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 [Response] + * @return [io.appwrite.models.CountryList] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getCountriesEU(): Response { + suspend fun getCountriesEU(): io.appwrite.models.CountryList { val path = "/locale/countries/eu" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.CountryList = { + io.appwrite.models.CountryList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.CountryList::class.java, + convert = convert + ) } /** @@ -107,20 +140,28 @@ class Locale(client: Client) : Service(client) { * List of all countries phone codes. You can use the locale header to get the * data in a supported language. * - * @return [Response] + * @return [io.appwrite.models.PhoneList] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getCountriesPhones(): Response { + suspend fun getCountriesPhones(): io.appwrite.models.PhoneList { val path = "/locale/countries/phones" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.PhoneList = { + io.appwrite.models.PhoneList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.PhoneList::class.java, + convert = convert + ) } /** @@ -130,20 +171,28 @@ class Locale(client: Client) : Service(client) { * decimal digits for all major and minor currencies. You can use the locale * header to get the data in a supported language. * - * @return [Response] + * @return [io.appwrite.models.CurrencyList] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getCurrencies(): Response { + suspend fun getCurrencies(): io.appwrite.models.CurrencyList { val path = "/locale/currencies" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.CurrencyList = { + io.appwrite.models.CurrencyList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.CurrencyList::class.java, + convert = convert + ) } /** @@ -152,20 +201,28 @@ class Locale(client: Client) : Service(client) { * List of all languages classified by ISO 639-1 including 2-letter code, name * in English, and name in the respective language. * - * @return [Response] + * @return [io.appwrite.models.LanguageList] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getLanguages(): Response { + suspend fun getLanguages(): io.appwrite.models.LanguageList { val path = "/locale/languages" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.LanguageList = { + io.appwrite.models.LanguageList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.LanguageList::class.java, + convert = convert + ) } } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Projects.kt b/library/src/main/java/io/appwrite/services/Projects.kt deleted file mode 100644 index e019a4e..0000000 --- a/library/src/main/java/io/appwrite/services/Projects.kt +++ /dev/null @@ -1,1016 +0,0 @@ -package io.appwrite.services - -import android.net.Uri -import io.appwrite.Client -import io.appwrite.exceptions.AppwriteException -import okhttp3.Cookie -import okhttp3.Response -import java.io.File - -class Projects(client: Client) : Service(client) { - - /** - * List Projects - * - * @param search - * @param limit - * @param offset - * @param orderType - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun list( - search: String? = null, - limit: Int? = null, - offset: Int? = null, - orderType: String? = null - ): Response { - val path = "/projects" - val params = mapOf( - "search" to search, - "limit" to limit, - "offset" to offset, - "orderType" to orderType - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Create Project - * - * @param name - * @param teamId - * @param description - * @param logo - * @param url - * @param legalName - * @param legalCountry - * @param legalState - * @param legalCity - * @param legalAddress - * @param legalTaxId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun create( - name: String, - teamId: String, - description: String? = null, - logo: String? = null, - url: String? = null, - legalName: String? = null, - legalCountry: String? = null, - legalState: String? = null, - legalCity: String? = null, - legalAddress: String? = null, - legalTaxId: String? = null - ): Response { - val path = "/projects" - val params = mapOf( - "name" to name, - "teamId" to teamId, - "description" to description, - "logo" to logo, - "url" to url, - "legalName" to legalName, - "legalCountry" to legalCountry, - "legalState" to legalState, - "legalCity" to legalCity, - "legalAddress" to legalAddress, - "legalTaxId" to legalTaxId - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("POST", path, headers, params) - } - - /** - * Get Project - * - * @param projectId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun get( - projectId: String - ): Response { - val path = "/projects/{projectId}".replace("{projectId}", projectId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Update Project - * - * @param projectId - * @param name - * @param description - * @param logo - * @param url - * @param legalName - * @param legalCountry - * @param legalState - * @param legalCity - * @param legalAddress - * @param legalTaxId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun update( - projectId: String, - name: String, - description: String? = null, - logo: String? = null, - url: String? = null, - legalName: String? = null, - legalCountry: String? = null, - legalState: String? = null, - legalCity: String? = null, - legalAddress: String? = null, - legalTaxId: String? = null - ): Response { - val path = "/projects/{projectId}".replace("{projectId}", projectId) - val params = mapOf( - "name" to name, - "description" to description, - "logo" to logo, - "url" to url, - "legalName" to legalName, - "legalCountry" to legalCountry, - "legalState" to legalState, - "legalCity" to legalCity, - "legalAddress" to legalAddress, - "legalTaxId" to legalTaxId - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("PATCH", path, headers, params) - } - - /** - * Delete Project - * - * @param projectId - * @param password - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun delete( - projectId: String, - password: String - ): Response { - val path = "/projects/{projectId}".replace("{projectId}", projectId) - val params = mapOf( - "password" to password - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("DELETE", path, headers, params) - } - - /** - * Update Project users limit - * - * @param projectId - * @param limit - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun updateAuthLimit( - projectId: String, - limit: String - ): Response { - val path = "/projects/{projectId}/auth/limit".replace("{projectId}", projectId) - val params = mapOf( - "limit" to limit - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("PATCH", path, headers, params) - } - - /** - * Update Project auth method status. Use this endpoint to enable or disable a given auth method for this project. - * - * @param projectId - * @param method - * @param status - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun updateAuthStatus( - projectId: String, - method: String, - status: Boolean - ): Response { - val path = "/projects/{projectId}/auth/{method}".replace("{projectId}", projectId).replace("{method}", method) - val params = mapOf( - "status" to status - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("PATCH", path, headers, params) - } - - /** - * List Domains - * - * @param projectId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun listDomains( - projectId: String - ): Response { - val path = "/projects/{projectId}/domains".replace("{projectId}", projectId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Create Domain - * - * @param projectId - * @param domain - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun createDomain( - projectId: String, - domain: String - ): Response { - val path = "/projects/{projectId}/domains".replace("{projectId}", projectId) - val params = mapOf( - "domain" to domain - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("POST", path, headers, params) - } - - /** - * Get Domain - * - * @param projectId - * @param domainId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getDomain( - projectId: String, - domainId: String - ): Response { - val path = "/projects/{projectId}/domains/{domainId}".replace("{projectId}", projectId).replace("{domainId}", domainId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Delete Domain - * - * @param projectId - * @param domainId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun deleteDomain( - projectId: String, - domainId: String - ): Response { - val path = "/projects/{projectId}/domains/{domainId}".replace("{projectId}", projectId).replace("{domainId}", domainId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("DELETE", path, headers, params) - } - - /** - * Update Domain Verification Status - * - * @param projectId - * @param domainId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun updateDomainVerification( - projectId: String, - domainId: String - ): Response { - val path = "/projects/{projectId}/domains/{domainId}/verification".replace("{projectId}", projectId).replace("{domainId}", domainId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("PATCH", path, headers, params) - } - - /** - * List Keys - * - * @param projectId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun listKeys( - projectId: String - ): Response { - val path = "/projects/{projectId}/keys".replace("{projectId}", projectId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Create Key - * - * @param projectId - * @param name - * @param scopes - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun createKey( - projectId: String, - name: String, - scopes: List - ): Response { - val path = "/projects/{projectId}/keys".replace("{projectId}", projectId) - val params = mapOf( - "name" to name, - "scopes" to scopes - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("POST", path, headers, params) - } - - /** - * Get Key - * - * @param projectId - * @param keyId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getKey( - projectId: String, - keyId: String - ): Response { - val path = "/projects/{projectId}/keys/{keyId}".replace("{projectId}", projectId).replace("{keyId}", keyId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Update Key - * - * @param projectId - * @param keyId - * @param name - * @param scopes - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun updateKey( - projectId: String, - keyId: String, - name: String, - scopes: List - ): Response { - val path = "/projects/{projectId}/keys/{keyId}".replace("{projectId}", projectId).replace("{keyId}", keyId) - val params = mapOf( - "name" to name, - "scopes" to scopes - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("PUT", path, headers, params) - } - - /** - * Delete Key - * - * @param projectId - * @param keyId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun deleteKey( - projectId: String, - keyId: String - ): Response { - val path = "/projects/{projectId}/keys/{keyId}".replace("{projectId}", projectId).replace("{keyId}", keyId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("DELETE", path, headers, params) - } - - /** - * Update Project OAuth2 - * - * @param projectId - * @param provider - * @param appId - * @param secret - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun updateOAuth2( - projectId: String, - provider: String, - appId: String? = null, - secret: String? = null - ): Response { - val path = "/projects/{projectId}/oauth2".replace("{projectId}", projectId) - val params = mapOf( - "provider" to provider, - "appId" to appId, - "secret" to secret - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("PATCH", path, headers, params) - } - - /** - * List Platforms - * - * @param projectId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun listPlatforms( - projectId: String - ): Response { - val path = "/projects/{projectId}/platforms".replace("{projectId}", projectId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Create Platform - * - * @param projectId - * @param type - * @param name - * @param key - * @param store - * @param hostname - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun createPlatform( - projectId: String, - type: String, - name: String, - key: String? = null, - store: String? = null, - hostname: String? = null - ): Response { - val path = "/projects/{projectId}/platforms".replace("{projectId}", projectId) - val params = mapOf( - "type" to type, - "name" to name, - "key" to key, - "store" to store, - "hostname" to hostname - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("POST", path, headers, params) - } - - /** - * Get Platform - * - * @param projectId - * @param platformId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getPlatform( - projectId: String, - platformId: String - ): Response { - val path = "/projects/{projectId}/platforms/{platformId}".replace("{projectId}", projectId).replace("{platformId}", platformId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Update Platform - * - * @param projectId - * @param platformId - * @param name - * @param key - * @param store - * @param hostname - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun updatePlatform( - projectId: String, - platformId: String, - name: String, - key: String? = null, - store: String? = null, - hostname: String? = null - ): Response { - val path = "/projects/{projectId}/platforms/{platformId}".replace("{projectId}", projectId).replace("{platformId}", platformId) - val params = mapOf( - "name" to name, - "key" to key, - "store" to store, - "hostname" to hostname - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("PUT", path, headers, params) - } - - /** - * Delete Platform - * - * @param projectId - * @param platformId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun deletePlatform( - projectId: String, - platformId: String - ): Response { - val path = "/projects/{projectId}/platforms/{platformId}".replace("{projectId}", projectId).replace("{platformId}", platformId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("DELETE", path, headers, params) - } - - /** - * List Tasks - * - * @param projectId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun listTasks( - projectId: String - ): Response { - val path = "/projects/{projectId}/tasks".replace("{projectId}", projectId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Create Task - * - * @param projectId - * @param name - * @param status - * @param schedule - * @param security - * @param httpMethod - * @param httpUrl - * @param httpHeaders - * @param httpUser - * @param httpPass - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun createTask( - projectId: String, - name: String, - status: String, - schedule: String, - security: Boolean, - httpMethod: String, - httpUrl: String, - httpHeaders: List? = null, - httpUser: String? = null, - httpPass: String? = null - ): Response { - val path = "/projects/{projectId}/tasks".replace("{projectId}", projectId) - val params = mapOf( - "name" to name, - "status" to status, - "schedule" to schedule, - "security" to security, - "httpMethod" to httpMethod, - "httpUrl" to httpUrl, - "httpHeaders" to httpHeaders, - "httpUser" to httpUser, - "httpPass" to httpPass - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("POST", path, headers, params) - } - - /** - * Get Task - * - * @param projectId - * @param taskId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getTask( - projectId: String, - taskId: String - ): Response { - val path = "/projects/{projectId}/tasks/{taskId}".replace("{projectId}", projectId).replace("{taskId}", taskId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Update Task - * - * @param projectId - * @param taskId - * @param name - * @param status - * @param schedule - * @param security - * @param httpMethod - * @param httpUrl - * @param httpHeaders - * @param httpUser - * @param httpPass - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun updateTask( - projectId: String, - taskId: String, - name: String, - status: String, - schedule: String, - security: Boolean, - httpMethod: String, - httpUrl: String, - httpHeaders: List? = null, - httpUser: String? = null, - httpPass: String? = null - ): Response { - val path = "/projects/{projectId}/tasks/{taskId}".replace("{projectId}", projectId).replace("{taskId}", taskId) - val params = mapOf( - "name" to name, - "status" to status, - "schedule" to schedule, - "security" to security, - "httpMethod" to httpMethod, - "httpUrl" to httpUrl, - "httpHeaders" to httpHeaders, - "httpUser" to httpUser, - "httpPass" to httpPass - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("PUT", path, headers, params) - } - - /** - * Delete Task - * - * @param projectId - * @param taskId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun deleteTask( - projectId: String, - taskId: String - ): Response { - val path = "/projects/{projectId}/tasks/{taskId}".replace("{projectId}", projectId).replace("{taskId}", taskId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("DELETE", path, headers, params) - } - - /** - * Get Project - * - * @param projectId - * @param range - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getUsage( - projectId: String, - range: String? = null - ): Response { - val path = "/projects/{projectId}/usage".replace("{projectId}", projectId) - val params = mapOf( - "range" to range - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * List Webhooks - * - * @param projectId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun listWebhooks( - projectId: String - ): Response { - val path = "/projects/{projectId}/webhooks".replace("{projectId}", projectId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Create Webhook - * - * @param projectId - * @param name - * @param events - * @param url - * @param security - * @param httpUser - * @param httpPass - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun createWebhook( - projectId: String, - name: String, - events: List, - url: String, - security: Boolean, - httpUser: String? = null, - httpPass: String? = null - ): Response { - val path = "/projects/{projectId}/webhooks".replace("{projectId}", projectId) - val params = mapOf( - "name" to name, - "events" to events, - "url" to url, - "security" to security, - "httpUser" to httpUser, - "httpPass" to httpPass - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("POST", path, headers, params) - } - - /** - * Get Webhook - * - * @param projectId - * @param webhookId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getWebhook( - projectId: String, - webhookId: String - ): Response { - val path = "/projects/{projectId}/webhooks/{webhookId}".replace("{projectId}", projectId).replace("{webhookId}", webhookId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Update Webhook - * - * @param projectId - * @param webhookId - * @param name - * @param events - * @param url - * @param security - * @param httpUser - * @param httpPass - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun updateWebhook( - projectId: String, - webhookId: String, - name: String, - events: List, - url: String, - security: Boolean, - httpUser: String? = null, - httpPass: String? = null - ): Response { - val path = "/projects/{projectId}/webhooks/{webhookId}".replace("{projectId}", projectId).replace("{webhookId}", webhookId) - val params = mapOf( - "name" to name, - "events" to events, - "url" to url, - "security" to security, - "httpUser" to httpUser, - "httpPass" to httpPass - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("PUT", path, headers, params) - } - - /** - * Delete Webhook - * - * @param projectId - * @param webhookId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun deleteWebhook( - projectId: String, - webhookId: String - ): Response { - val path = "/projects/{projectId}/webhooks/{webhookId}".replace("{projectId}", projectId).replace("{webhookId}", webhookId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("DELETE", path, headers, params) - } - -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Realtime.kt b/library/src/main/java/io/appwrite/services/Realtime.kt index cec1dad..316054a 100644 --- a/library/src/main/java/io/appwrite/services/Realtime.kt +++ b/library/src/main/java/io/appwrite/services/Realtime.kt @@ -15,6 +15,7 @@ import okhttp3.WebSocketListener import okhttp3.internal.concurrent.TaskRunner import okhttp3.internal.ws.RealWebSocket import java.util.* +import android.util.Log import kotlin.coroutines.CoroutineContext class Realtime(client: Client) : Service(client), CoroutineScope { @@ -31,17 +32,24 @@ class Realtime(client: Client) : Service(client), CoroutineScope { private const val DEBOUNCE_MILLIS = 1L private var socket: RealWebSocket? = null - private var channelCallbacks = mutableMapOf>() - private var errorCallbacks = mutableSetOf<(AppwriteException) -> Unit>() + private var activeChannels = mutableSetOf() + private var activeSubscriptions = mutableMapOf() private var subCallDepth = 0 + private var reconnectAttempts = 0 + private var subscriptionsCounter = 0 + private var reconnect = true } private fun createSocket() { + if (activeChannels.isEmpty()) { + return + } + val queryParamBuilder = StringBuilder() .append("project=${client.config["project"]}") - channelCallbacks.keys.forEach { + activeChannels.forEach { queryParamBuilder .append("&channels[]=$it") } @@ -51,6 +59,7 @@ class Realtime(client: Client) : Service(client), CoroutineScope { .build() if (socket != null) { + reconnect = false closeSocket() } @@ -71,6 +80,13 @@ class Realtime(client: Client) : Service(client), CoroutineScope { socket?.close(RealtimeCode.POLICY_VIOLATION.value, null) } + private fun getTimeout() = when { + reconnectAttempts < 5 -> 1000L + reconnectAttempts < 15 -> 5000L + reconnectAttempts < 100 -> 10000L + else -> 60000L + } + fun subscribe( vararg channels: String, callback: (RealtimeResponseEvent) -> Unit, @@ -85,20 +101,14 @@ class Realtime(client: Client) : Service(client), CoroutineScope { payloadType: Class, callback: (RealtimeResponseEvent) -> Unit, ): RealtimeSubscription { - channels.forEach { - if (!channelCallbacks.containsKey(it)) { - channelCallbacks[it] = mutableListOf( - RealtimeCallback( - payloadType, - callback as (RealtimeResponseEvent<*>) -> Unit - ) - ) - return@forEach - } - channelCallbacks[it]?.add( - RealtimeCallback(payloadType, callback as (RealtimeResponseEvent<*>) -> Unit) - ) - } + val counter = subscriptionsCounter++ + + activeChannels.addAll(channels) + activeSubscriptions[counter] = RealtimeCallback( + channels.toList(), + payloadType, + callback as (RealtimeResponseEvent<*>) -> Unit + ) launch { subCallDepth++ @@ -109,25 +119,31 @@ class Realtime(client: Client) : Service(client), CoroutineScope { subCallDepth-- } - return RealtimeSubscription { unsubscribe(*channels) } - } - - fun unsubscribe(vararg channels: String) { - channels.forEach { - channelCallbacks[it] = mutableListOf() - } - if (channelCallbacks.all { it.value.isEmpty() }) { - errorCallbacks = mutableSetOf() - closeSocket() + return RealtimeSubscription { + activeSubscriptions.remove(counter) + cleanUp(*channels) + createSocket() } } - fun doOnError(callback: (AppwriteException) -> Unit) { - errorCallbacks.add(callback) + private fun cleanUp(vararg channels: String) { + activeChannels.removeAll { channel -> + if (!channels.contains(channel)) { + return@removeAll false + } + activeSubscriptions.values.none { callback -> + callback.channels.contains(channel) + } + } } private inner class AppwriteWebSocketListener : WebSocketListener() { + override fun onOpen(webSocket: WebSocket, response: Response) { + super.onOpen(webSocket, response) + reconnectAttempts = 0 + } + override fun onMessage(webSocket: WebSocket, text: String) { super.onMessage(webSocket, text) @@ -141,27 +157,43 @@ class Realtime(client: Client) : Service(client), CoroutineScope { } private fun handleResponseError(message: RealtimeResponse) { - val error = message.data.jsonCast() - errorCallbacks.forEach { it.invoke(error) } + throw message.data.jsonCast() } private suspend fun handleResponseEvent(message: RealtimeResponse) { val event = message.data.jsonCast>() - event.channels.forEachAsync { channel -> - channelCallbacks[channel]?.forEachAsync { callbackWrapper -> - event.payload = event.payload.jsonCast(callbackWrapper.payloadClass) - callbackWrapper.callback.invoke(event) + if (event.channels.isEmpty()) { + return + } + if (!event.channels.any { activeChannels.contains(it) }) { + return + } + activeSubscriptions.values.forEachAsync { subscription -> + if (event.channels.any { subscription.channels.contains(it) }) { + event.payload = event.payload.jsonCast(subscription.payloadClass) + subscription.callback(event) } } } override fun onClosing(webSocket: WebSocket, code: Int, reason: String) { super.onClosing(webSocket, code, reason) - if (code == RealtimeCode.POLICY_VIOLATION.value) { + if (!reconnect || code == RealtimeCode.POLICY_VIOLATION.value) { + reconnect = true return } + + val timeout = getTimeout() + + Log.e( + this@Realtime::class.java.name, + "Realtime disconnected. Re-connecting in ${timeout / 1000} seconds.", + AppwriteException(reason, code) + ) + launch { - delay(1000) + delay(timeout) + reconnectAttempts++ createSocket() } } diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index c13a0a3..1b1941e 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -2,6 +2,7 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client +import io.appwrite.models.* import io.appwrite.exceptions.AppwriteException import okhttp3.Cookie import okhttp3.Response @@ -18,20 +19,20 @@ class Storage(client: Client) : Service(client) { * 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). * - * @param search - * @param limit - * @param offset - * @param orderType - * @return [Response] + * @param search Search term to filter your list results. Max length: 256 chars. + * @param limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. + * @param offset Results offset. The default value is 0. Use this param to manage pagination. + * @param orderType Order result by ASC or DESC order. + * @return [io.appwrite.models.FileList] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun listFiles( search: String? = null, - limit: Int? = null, - offset: Int? = null, + limit: Long? = null, + offset: Long? = null, orderType: String? = null - ): Response { + ): io.appwrite.models.FileList { val path = "/storage/files" val params = mapOf( "search" to search, @@ -39,12 +40,20 @@ class Storage(client: Client) : Service(client) { "offset" to offset, "orderType" to orderType ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.FileList = { + io.appwrite.models.FileList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.FileList::class.java, + convert = convert + ) } /** @@ -54,10 +63,10 @@ class Storage(client: Client) : Service(client) { * assigned to read and write access unless he has passed custom values for * read and write arguments. * - * @param file - * @param read - * @param write - * @return [Response] + * @param file Binary file. + * @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. + * @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. + * @return [io.appwrite.models.File] */ @JvmOverloads @Throws(AppwriteException::class) @@ -65,19 +74,27 @@ class Storage(client: Client) : Service(client) { file: File, read: List? = null, write: List? = null - ): Response { + ): io.appwrite.models.File { val path = "/storage/files" val params = mapOf( "file" to file, "read" to read, "write" to write ) - val headers = mapOf( "content-type" to "multipart/form-data" ) - - return client.call("POST", path, headers, params) + val convert: (Map) -> io.appwrite.models.File = { + io.appwrite.models.File.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.File::class.java, + convert = convert + ) } /** @@ -86,23 +103,31 @@ class Storage(client: Client) : Service(client) { * Get a file by its unique ID. This endpoint response returns a JSON object * with the file metadata. * - * @param fileId - * @return [Response] + * @param fileId File unique ID. + * @return [io.appwrite.models.File] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getFile( fileId: String - ): Response { + ): io.appwrite.models.File { val path = "/storage/files/{fileId}".replace("{fileId}", fileId) val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.File = { + io.appwrite.models.File.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.File::class.java, + convert = convert + ) } /** @@ -111,10 +136,10 @@ class Storage(client: Client) : Service(client) { * Update a file by its unique ID. Only users with write permissions have * access to update this resource. * - * @param fileId - * @param read - * @param write - * @return [Response] + * @param fileId File unique ID. + * @param read An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. + * @param write An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. + * @return [io.appwrite.models.File] */ @JvmOverloads @Throws(AppwriteException::class) @@ -122,18 +147,26 @@ class Storage(client: Client) : Service(client) { fileId: String, read: List, write: List - ): Response { + ): io.appwrite.models.File { val path = "/storage/files/{fileId}".replace("{fileId}", fileId) val params = mapOf( "read" to read, "write" to write ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("PUT", path, headers, params) + val convert: (Map) -> io.appwrite.models.File = { + io.appwrite.models.File.from(map = it) + } + return client.call( + "PUT", + path, + headers, + params, + responseType = io.appwrite.models.File::class.java, + convert = convert + ) } /** @@ -142,23 +175,27 @@ class Storage(client: Client) : Service(client) { * Delete a file by its unique ID. Only users with write permissions have * access to delete this resource. * - * @param fileId - * @return [Response] + * @param fileId File unique ID. + * @return [Any] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun deleteFile( fileId: String - ): Response { + ): Any { val path = "/storage/files/{fileId}".replace("{fileId}", fileId) val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("DELETE", path, headers, params) + return client.call( + "DELETE", + path, + headers, + params, + responseType = Any::class.java, + ) } /** @@ -168,20 +205,24 @@ class Storage(client: Client) : Service(client) { * 'Content-Disposition: attachment' header that tells the browser to start * downloading the file to user downloads directory. * - * @param fileId - * @return [Response] + * @param fileId File unique ID. + * @return [ByteArray] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getFileDownload( fileId: String - ): Response { + ): ByteArray { val path = "/storage/files/{fileId}/download".replace("{fileId}", fileId) val params = mapOf( "project" to client.config["project"] ) - - return client.call("GET", path, params = params) + return client.call( + "GET", + path, + params = params, + responseType = ByteArray::class.java + ) } /** @@ -192,38 +233,41 @@ class Storage(client: Client) : Service(client) { * and spreadsheets, will return the file icon image. You can also pass query * string arguments for cutting and resizing your preview image. * - * @param fileId - * @param width - * @param height - * @param quality - * @param borderWidth - * @param borderColor - * @param borderRadius - * @param opacity - * @param rotation - * @param background - * @param output - * @return [Response] + * @param fileId File unique ID + * @param width Resize preview image width, Pass an integer between 0 to 4000. + * @param height Resize preview image height, Pass an integer between 0 to 4000. + * @param gravity Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right + * @param quality Preview image quality. Pass an integer between 0 to 100. Defaults to 100. + * @param borderWidth Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0. + * @param borderColor Preview image border color. Use a valid HEX color, no # is needed for prefix. + * @param borderRadius Preview image border radius in pixels. Pass an integer between 0 to 4000. + * @param opacity Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1. + * @param rotation Preview image rotation in degrees. Pass an integer between 0 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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getFilePreview( fileId: String, - width: Int? = null, - height: Int? = null, - quality: Int? = null, - borderWidth: Int? = null, + width: Long? = null, + height: Long? = null, + gravity: String? = null, + quality: Long? = null, + borderWidth: Long? = null, borderColor: String? = null, - borderRadius: Int? = null, + borderRadius: Long? = null, opacity: Double? = null, - rotation: Int? = null, + rotation: Long? = null, background: String? = null, output: String? = null - ): Response { + ): ByteArray { val path = "/storage/files/{fileId}/preview".replace("{fileId}", fileId) val params = mapOf( "width" to width, "height" to height, + "gravity" to gravity, "quality" to quality, "borderWidth" to borderWidth, "borderColor" to borderColor, @@ -234,8 +278,12 @@ class Storage(client: Client) : Service(client) { "output" to output, "project" to client.config["project"] ) - - return client.call("GET", path, params = params) + return client.call( + "GET", + path, + params = params, + responseType = ByteArray::class.java + ) } /** @@ -245,20 +293,24 @@ class Storage(client: Client) : Service(client) { * download method but returns with no 'Content-Disposition: attachment' * header. * - * @param fileId - * @return [Response] + * @param fileId File unique ID. + * @return [ByteArray] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getFileView( fileId: String - ): Response { + ): ByteArray { val path = "/storage/files/{fileId}/view".replace("{fileId}", fileId) val params = mapOf( "project" to client.config["project"] ) - - return client.call("GET", path, params = params) + return client.call( + "GET", + path, + params = params, + 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 741fd03..90dcba1 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -2,6 +2,7 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client +import io.appwrite.models.* import io.appwrite.exceptions.AppwriteException import okhttp3.Cookie import okhttp3.Response @@ -17,20 +18,20 @@ class Teams(client: Client) : Service(client) { * of the project's teams. [Learn more about different API * modes](/docs/admin). * - * @param search - * @param limit - * @param offset - * @param orderType - * @return [Response] + * @param search Search term to filter your list results. Max length: 256 chars. + * @param limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. + * @param offset Results offset. The default value is 0. Use this param to manage pagination. + * @param orderType Order result by ASC or DESC order. + * @return [io.appwrite.models.TeamList] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun list( search: String? = null, - limit: Int? = null, - offset: Int? = null, + limit: Long? = null, + offset: Long? = null, orderType: String? = null - ): Response { + ): io.appwrite.models.TeamList { val path = "/teams" val params = mapOf( "search" to search, @@ -38,12 +39,20 @@ class Teams(client: Client) : Service(client) { "offset" to offset, "orderType" to orderType ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.TeamList = { + io.appwrite.models.TeamList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.TeamList::class.java, + convert = convert + ) } /** @@ -54,27 +63,35 @@ class Teams(client: Client) : Service(client) { * who will be able add new owners and update or delete the team from your * project. * - * @param name - * @param roles - * @return [Response] + * @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). Max length for each role is 32 chars. + * @return [io.appwrite.models.Team] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun create( name: String, roles: List? = null - ): Response { + ): io.appwrite.models.Team { val path = "/teams" val params = mapOf( "name" to name, "roles" to roles ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("POST", path, headers, params) + val convert: (Map) -> io.appwrite.models.Team = { + io.appwrite.models.Team.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Team::class.java, + convert = convert + ) } /** @@ -83,23 +100,31 @@ class Teams(client: Client) : Service(client) { * Get a team by its unique ID. All team members have read access for this * resource. * - * @param teamId - * @return [Response] + * @param teamId Team unique ID. + * @return [io.appwrite.models.Team] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun get( teamId: String - ): Response { + ): io.appwrite.models.Team { val path = "/teams/{teamId}".replace("{teamId}", teamId) val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.Team = { + io.appwrite.models.Team.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.Team::class.java, + convert = convert + ) } /** @@ -108,26 +133,34 @@ class Teams(client: Client) : Service(client) { * Update a team by its unique ID. Only team owners have write access for this * resource. * - * @param teamId - * @param name - * @return [Response] + * @param teamId Team unique ID. + * @param name Team name. Max length: 128 chars. + * @return [io.appwrite.models.Team] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun update( teamId: String, name: String - ): Response { + ): io.appwrite.models.Team { val path = "/teams/{teamId}".replace("{teamId}", teamId) val params = mapOf( "name" to name ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("PUT", path, headers, params) + val convert: (Map) -> io.appwrite.models.Team = { + io.appwrite.models.Team.from(map = it) + } + return client.call( + "PUT", + path, + headers, + params, + responseType = io.appwrite.models.Team::class.java, + convert = convert + ) } /** @@ -136,23 +169,27 @@ class Teams(client: Client) : Service(client) { * Delete a team by its unique ID. Only team owners have write access for this * resource. * - * @param teamId - * @return [Response] + * @param teamId Team unique ID. + * @return [Any] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun delete( teamId: String - ): Response { + ): Any { val path = "/teams/{teamId}".replace("{teamId}", teamId) val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("DELETE", path, headers, params) + return client.call( + "DELETE", + path, + headers, + params, + responseType = Any::class.java, + ) } /** @@ -161,22 +198,22 @@ class Teams(client: Client) : Service(client) { * Get a team members by the team unique ID. All team members have read access * for this list of resources. * - * @param teamId - * @param search - * @param limit - * @param offset - * @param orderType - * @return [Response] + * @param teamId Team unique ID. + * @param search Search term to filter your list results. Max length: 256 chars. + * @param limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. + * @param offset Results offset. The default value is 0. Use this param to manage pagination. + * @param orderType Order result by ASC or DESC order. + * @return [io.appwrite.models.MembershipList] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getMemberships( teamId: String, search: String? = null, - limit: Int? = null, - offset: Int? = null, + limit: Long? = null, + offset: Long? = null, orderType: String? = null - ): Response { + ): io.appwrite.models.MembershipList { val path = "/teams/{teamId}/memberships".replace("{teamId}", teamId) val params = mapOf( "search" to search, @@ -184,12 +221,20 @@ class Teams(client: Client) : Service(client) { "offset" to offset, "orderType" to orderType ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.MembershipList = { + io.appwrite.models.MembershipList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.MembershipList::class.java, + convert = convert + ) } /** @@ -212,12 +257,12 @@ class Teams(client: Client) : Service(client) { * the only valid redirect URL's are the once from domains you have set when * added your platforms in the console interface. * - * @param teamId - * @param email - * @param roles - * @param url - * @param name - * @return [Response] + * @param teamId Team unique ID. + * @param email New team member email. + * @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). Max length for each role is 32 chars. + * @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 New team member name. Max length: 128 chars. + * @return [io.appwrite.models.Membership] */ @JvmOverloads @Throws(AppwriteException::class) @@ -227,7 +272,7 @@ class Teams(client: Client) : Service(client) { roles: List, url: String, name: String? = null - ): Response { + ): io.appwrite.models.Membership { val path = "/teams/{teamId}/memberships".replace("{teamId}", teamId) val params = mapOf( "email" to email, @@ -235,21 +280,29 @@ class Teams(client: Client) : Service(client) { "url" to url, "name" to name ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("POST", path, headers, params) + val convert: (Map) -> io.appwrite.models.Membership = { + io.appwrite.models.Membership.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Membership::class.java, + convert = convert + ) } /** * Update Membership Roles * - * @param teamId - * @param membershipId - * @param roles - * @return [Response] + * @param teamId Team unique ID. + * @param membershipId Membership ID. + * @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). Max length for each role is 32 chars. + * @return [io.appwrite.models.Membership] */ @JvmOverloads @Throws(AppwriteException::class) @@ -257,17 +310,25 @@ class Teams(client: Client) : Service(client) { teamId: String, membershipId: String, roles: List - ): Response { + ): io.appwrite.models.Membership { val path = "/teams/{teamId}/memberships/{membershipId}".replace("{teamId}", teamId).replace("{membershipId}", membershipId) val params = mapOf( "roles" to roles ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("PATCH", path, headers, params) + val convert: (Map) -> io.appwrite.models.Membership = { + io.appwrite.models.Membership.from(map = it) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.Membership::class.java, + convert = convert + ) } /** @@ -277,25 +338,29 @@ class Teams(client: Client) : Service(client) { * 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 - * @param membershipId - * @return [Response] + * @param teamId Team unique ID. + * @param membershipId Membership ID. + * @return [Any] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun deleteMembership( teamId: String, membershipId: String - ): Response { + ): Any { val path = "/teams/{teamId}/memberships/{membershipId}".replace("{teamId}", teamId).replace("{membershipId}", membershipId) val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("DELETE", path, headers, params) + return client.call( + "DELETE", + path, + headers, + params, + responseType = Any::class.java, + ) } /** @@ -305,11 +370,11 @@ class Teams(client: Client) : Service(client) { * after being redirected back to your app from the invitation email recieved * by the user. * - * @param teamId - * @param membershipId - * @param userId - * @param secret - * @return [Response] + * @param teamId Team unique ID. + * @param membershipId Membership ID. + * @param userId User unique ID. + * @param secret Secret key. + * @return [io.appwrite.models.Membership] */ @JvmOverloads @Throws(AppwriteException::class) @@ -318,18 +383,26 @@ class Teams(client: Client) : Service(client) { membershipId: String, userId: String, secret: String - ): Response { + ): io.appwrite.models.Membership { val path = "/teams/{teamId}/memberships/{membershipId}/status".replace("{teamId}", teamId).replace("{membershipId}", membershipId) val params = mapOf( "userId" to userId, "secret" to secret ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("PATCH", path, headers, params) + val convert: (Map) -> io.appwrite.models.Membership = { + io.appwrite.models.Membership.from(map = it) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.Membership::class.java, + convert = convert + ) } } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Users.kt b/library/src/main/java/io/appwrite/services/Users.kt deleted file mode 100644 index 0241d2d..0000000 --- a/library/src/main/java/io/appwrite/services/Users.kt +++ /dev/null @@ -1,303 +0,0 @@ -package io.appwrite.services - -import android.net.Uri -import io.appwrite.Client -import io.appwrite.exceptions.AppwriteException -import okhttp3.Cookie -import okhttp3.Response -import java.io.File - -class Users(client: Client) : Service(client) { - - /** - * List Users - * - * Get a list of all the project's users. You can use the query params to - * filter your results. - * - * @param search - * @param limit - * @param offset - * @param orderType - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun list( - search: String? = null, - limit: Int? = null, - offset: Int? = null, - orderType: String? = null - ): Response { - val path = "/users" - val params = mapOf( - "search" to search, - "limit" to limit, - "offset" to offset, - "orderType" to orderType - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Create User - * - * Create a new user. - * - * @param email - * @param password - * @param name - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun create( - email: String, - password: String, - name: String? = null - ): Response { - val path = "/users" - val params = mapOf( - "email" to email, - "password" to password, - "name" to name - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("POST", path, headers, params) - } - - /** - * Get User - * - * Get a user by its unique ID. - * - * @param userId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun get( - userId: String - ): Response { - val path = "/users/{userId}".replace("{userId}", userId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Delete User - * - * Delete a user by its unique ID. - * - * @param userId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun delete( - userId: String - ): Response { - val path = "/users/{userId}".replace("{userId}", userId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("DELETE", path, headers, params) - } - - /** - * Get User Logs - * - * Get a user activity logs list by its unique ID. - * - * @param userId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getLogs( - userId: String - ): Response { - val path = "/users/{userId}/logs".replace("{userId}", userId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Get User Preferences - * - * Get the user preferences by its unique ID. - * - * @param userId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getPrefs( - userId: String - ): Response { - val path = "/users/{userId}/prefs".replace("{userId}", userId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Update User Preferences - * - * Update the user preferences by its unique ID. You can pass only the - * specific settings you wish to update. - * - * @param userId - * @param prefs - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun updatePrefs( - userId: String, - prefs: Any - ): Response { - val path = "/users/{userId}/prefs".replace("{userId}", userId) - val params = mapOf( - "prefs" to prefs - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("PATCH", path, headers, params) - } - - /** - * Get User Sessions - * - * Get the user sessions list by its unique ID. - * - * @param userId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getSessions( - userId: String - ): Response { - val path = "/users/{userId}/sessions".replace("{userId}", userId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("GET", path, headers, params) - } - - /** - * Delete User Sessions - * - * Delete all user's sessions by using the user's unique ID. - * - * @param userId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun deleteSessions( - userId: String - ): Response { - val path = "/users/{userId}/sessions".replace("{userId}", userId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("DELETE", path, headers, params) - } - - /** - * Delete User Session - * - * Delete a user sessions by its unique ID. - * - * @param userId - * @param sessionId - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun deleteSession( - userId: String, - sessionId: String - ): Response { - val path = "/users/{userId}/sessions/{sessionId}".replace("{userId}", userId).replace("{sessionId}", sessionId) - val params = mapOf( - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("DELETE", path, headers, params) - } - - /** - * Update User Status - * - * Update the user status by its unique ID. - * - * @param userId - * @param status - * @return [Response] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun updateStatus( - userId: String, - status: Int - ): Response { - val path = "/users/{userId}/status".replace("{userId}", userId) - val params = mapOf( - "status" to status - ) - - val headers = mapOf( - "content-type" to "application/json" - ) - - return client.call("PATCH", path, headers, params) - } - -} \ No newline at end of file From 61ac4949db66d1436f7341f0e50292c8a4763463 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 2 Nov 2021 20:04:25 +1300 Subject: [PATCH 010/118] Update publish to Java 11 --- .github/workflows/publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 20b880d..fc3d328 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -12,10 +12,10 @@ jobs: steps: - name: Check out code uses: actions/checkout@v2 - - name: Set up JDK 1.8 + - name: Set up JDK 11 uses: actions/setup-java@v1 with: - java-version: 1.8 + java-version: 11 # Base64 decodes and pipes the GPG key content into the secret file - name: Prepare environment env: From f216ac83b56cd79c5a1b638bff6cf29caad47045 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 25 Nov 2021 19:14:26 +0400 Subject: [PATCH 011/118] feat: update android sdk to 0.12.x --- .github/ISSUE_TEMPLATE/bug.yaml | 82 ------------------- .github/ISSUE_TEMPLATE/documentation.yaml | 32 -------- .github/ISSUE_TEMPLATE/feature.yaml | 40 --------- .github/workflows/publish.yml | 2 +- README.md | 4 +- build.gradle | 2 +- .../account/create-magic-u-r-l-session.md | 1 + docs/examples/java/account/create.md | 1 + docs/examples/java/account/get-logs.md | 35 ++++---- .../account/update-magic-u-r-l-session.md | 2 +- .../examples/java/database/create-document.md | 1 + docs/examples/java/storage/create-file.md | 1 + docs/examples/java/teams/create.md | 1 + docs/examples/java/teams/get-membership.md | 49 +++++++++++ .../account/create-magic-u-r-l-session.md | 1 + docs/examples/kotlin/account/create.md | 1 + docs/examples/kotlin/account/get-logs.md | 3 +- .../account/update-magic-u-r-l-session.md | 2 +- .../kotlin/database/create-document.md | 1 + docs/examples/kotlin/storage/create-file.md | 1 + docs/examples/kotlin/teams/create.md | 1 + docs/examples/kotlin/teams/get-membership.md | 27 ++++++ library/src/main/java/io/appwrite/Query.kt | 32 ++++++++ .../main/java/io/appwrite/models/Document.kt | 16 +++- .../main/java/io/appwrite/models/Execution.kt | 8 +- .../src/main/java/io/appwrite/models/File.kt | 16 +++- .../src/main/java/io/appwrite/models/Log.kt | 32 ++++++++ .../main/java/io/appwrite/models/LogList.kt | 8 ++ .../java/io/appwrite/models/Permissions.kt | 31 ------- .../src/main/java/io/appwrite/models/User.kt | 6 +- .../main/java/io/appwrite/services/Account.kt | 15 +++- .../java/io/appwrite/services/Database.kt | 52 ++++++------ .../java/io/appwrite/services/Functions.kt | 15 ++-- .../main/java/io/appwrite/services/Storage.kt | 9 ++ .../main/java/io/appwrite/services/Teams.kt | 50 +++++++++++ 35 files changed, 320 insertions(+), 260 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug.yaml delete mode 100644 .github/ISSUE_TEMPLATE/documentation.yaml delete mode 100644 .github/ISSUE_TEMPLATE/feature.yaml create mode 100644 docs/examples/java/teams/get-membership.md create mode 100644 docs/examples/kotlin/teams/get-membership.md create mode 100644 library/src/main/java/io/appwrite/Query.kt delete mode 100644 library/src/main/java/io/appwrite/models/Permissions.kt diff --git a/.github/ISSUE_TEMPLATE/bug.yaml b/.github/ISSUE_TEMPLATE/bug.yaml deleted file mode 100644 index 175c606..0000000 --- a/.github/ISSUE_TEMPLATE/bug.yaml +++ /dev/null @@ -1,82 +0,0 @@ -name: "🐛 Bug Report" -description: "Submit a bug report to help us improve" -title: "🐛 Bug Report: " -labels: [bug] -body: - - type: markdown - attributes: - value: | - Thanks for taking the time to fill out our bug report form 🙏 - - type: textarea - id: steps-to-reproduce - validations: - required: true - attributes: - label: "👟 Reproduction steps" - description: "How do you trigger this bug? Please walk us through it step by step." - placeholder: "When I ..." - - type: textarea - id: expected-behavior - validations: - required: true - attributes: - label: "👍 Expected behavior" - description: "What did you think would happen?" - placeholder: "It should ..." - - type: textarea - id: actual-behavior - validations: - required: true - attributes: - label: "👎 Actual Behavior" - description: "What did actually happen? Add screenshots, if applicable." - placeholder: "It actually ..." - - type: dropdown - id: appwrite-version - attributes: - label: "🎲 Appwrite version" - description: "What version of Appwrite are you running?" - options: - - Version 0.10.x - - Version 0.9.x - - Version 0.8.x - - Version 0.7.x - - Version 0.6.x - - Different version (specify in environment) - validations: - required: true - - type: dropdown - id: operating-system - attributes: - label: "💻 Operating system" - description: "What OS is your server / device running on?" - options: - - Linux - - MacOS - - Windows - - Something else - validations: - required: true - - type: textarea - id: enviromnemt - validations: - required: false - attributes: - label: "🧱 Your Environment" - description: "Is your environment customized in any way?" - placeholder: "I use Cloudflare for ..." - - type: checkboxes - id: no-duplicate-issues - attributes: - label: "👀 Have you spent some time to check if this issue has been raised before?" - description: "Have you Googled for a similar issue or checked our older issues for a similar bug?" - options: - - label: "I checked and didn't find similar issue" - required: true - - type: checkboxes - id: read-code-of-conduct - attributes: - label: "🏢 Have you read the Code of Conduct?" - options: - - label: "I have read the [Code of Conduct](https://github.com/appwrite/appwrite/blob/HEAD/CODE_OF_CONDUCT.md)" - required: true diff --git a/.github/ISSUE_TEMPLATE/documentation.yaml b/.github/ISSUE_TEMPLATE/documentation.yaml deleted file mode 100644 index b6189b0..0000000 --- a/.github/ISSUE_TEMPLATE/documentation.yaml +++ /dev/null @@ -1,32 +0,0 @@ -name: "📚 Documentation" -description: "Report an issue related to documentation" -title: "📚 Documentation: " -labels: [documentation] -body: - - type: markdown - attributes: - value: | - Thanks for taking the time to make our documentation better 🙏 - - type: textarea - id: issue-description - validations: - required: true - attributes: - label: "💭 Description" - description: "A clear and concise description of what the issue is." - placeholder: "Documentation should not ..." - - type: checkboxes - id: no-duplicate-issues - attributes: - label: "👀 Have you spent some time to check if this issue has been raised before?" - description: "Have you Googled for a similar issue or checked our older issues for a similar bug?" - options: - - label: "I checked and didn't find similar issue" - required: true - - type: checkboxes - id: read-code-of-conduct - attributes: - label: "🏢 Have you read the Code of Conduct?" - options: - - label: "I have read the [Code of Conduct](https://github.com/appwrite/appwrite/blob/HEAD/CODE_OF_CONDUCT.md)" - required: true diff --git a/.github/ISSUE_TEMPLATE/feature.yaml b/.github/ISSUE_TEMPLATE/feature.yaml deleted file mode 100644 index 630af44..0000000 --- a/.github/ISSUE_TEMPLATE/feature.yaml +++ /dev/null @@ -1,40 +0,0 @@ -name: 🚀 Feature -description: "Submit a proposal for a new feature" -title: "🚀 Feature: " -labels: [feature] -body: - - type: markdown - attributes: - value: | - Thanks for taking the time to fill out our feature request form 🙏 - - type: textarea - id: feature-description - validations: - required: true - attributes: - label: "🔖 Feature description" - description: "A clear and concise description of what the feature is." - placeholder: "You should add ..." - - type: textarea - id: pitch - validations: - required: true - attributes: - label: "🎤 Pitch" - description: "Please explain why this feature should be implemented and how it would be used. Add examples, if applicable." - placeholder: "In my use-case, ..." - - type: checkboxes - id: no-duplicate-issues - attributes: - label: "👀 Have you spent some time to check if this issue has been raised before?" - description: "Have you Googled for a similar issue or checked our older issues for a similar bug?" - options: - - label: "I checked and didn't find similar issue" - required: true - - type: checkboxes - id: read-code-of-conduct - attributes: - label: "🏢 Have you read the Code of Conduct?" - options: - - label: "I have read the [Code of Conduct](https://github.com/appwrite/appwrite/blob/HEAD/CODE_OF_CONDUCT.md)" - required: true diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index fc3d328..5b97b1c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -51,4 +51,4 @@ jobs: SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }} SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} - SDK_VERSION: ${{ github.event.release.tag_name }} \ No newline at end of file + SDK_VERSION: ${{ github.event.release.tag_name }} diff --git a/README.md b/README.md index 862d6b8..80451d6 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-0.11.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-0.12.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_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 0.11.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).** +**This SDK is compatible with Appwrite server version 0.12.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) diff --git a/build.gradle b/build.gradle index 5dd7a83..d2f3361 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,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" - version "0.3.0-SNAPSHOT" + version "0.2.1" repositories { maven { url "https://plugins.gradle.org/m2/" } google() 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 36fc58a..de630ad 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 @@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity { Account account = new Account(client); account.createMagicURLSession( + "", "email@example.com", new Continuation() { @NotNull diff --git a/docs/examples/java/account/create.md b/docs/examples/java/account/create.md index 3ff5ab9..1f10de2 100644 --- a/docs/examples/java/account/create.md +++ b/docs/examples/java/account/create.md @@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity { Account account = new Account(client); account.create( + "", "email@example.com", "password", new Continuation() { diff --git a/docs/examples/java/account/get-logs.md b/docs/examples/java/account/get-logs.md index f2dea96..fb83c5d 100644 --- a/docs/examples/java/account/get-logs.md +++ b/docs/examples/java/account/get-logs.md @@ -18,29 +18,30 @@ public class MainActivity extends AppCompatActivity { Account account = new Account(client); - account.getLogs(new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } + 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 { + @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()); } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); } } - }); + ); } } \ No newline at end of file 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..f8375b9 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 @@ -19,7 +19,7 @@ public class MainActivity extends AppCompatActivity { Account account = new Account(client); account.updateMagicURLSession( - "[USER_ID]", + "", "[SECRET]" new Continuation() { @NotNull diff --git a/docs/examples/java/database/create-document.md b/docs/examples/java/database/create-document.md index b3a5b28..7f1ff4c 100644 --- a/docs/examples/java/database/create-document.md +++ b/docs/examples/java/database/create-document.md @@ -20,6 +20,7 @@ public class MainActivity extends AppCompatActivity { database.createDocument( "[COLLECTION_ID]", + "", mapOf( "a" to "b" ), new Continuation() { @NotNull diff --git a/docs/examples/java/storage/create-file.md b/docs/examples/java/storage/create-file.md index 172ef7e..f20ba26 100644 --- a/docs/examples/java/storage/create-file.md +++ b/docs/examples/java/storage/create-file.md @@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity { Storage storage = new Storage(client); storage.createFile( + "", File("./path-to-files/image.jpg"), new Continuation() { @NotNull diff --git a/docs/examples/java/teams/create.md b/docs/examples/java/teams/create.md index a715c0a..c3e3093 100644 --- a/docs/examples/java/teams/create.md +++ b/docs/examples/java/teams/create.md @@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity { Teams teams = new Teams(client); teams.create( + "", "[NAME]", new Continuation() { @NotNull diff --git a/docs/examples/java/teams/get-membership.md b/docs/examples/java/teams/get-membership.md new file mode 100644 index 0000000..87c0160 --- /dev/null +++ b/docs/examples/java/teams/get-membership.md @@ -0,0 +1,49 @@ +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.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 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 c803d1a..7ac9a30 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 @@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = account.createMagicURLSession( + userId = "", email = "email@example.com", ) val json = response.body?.string() diff --git a/docs/examples/kotlin/account/create.md b/docs/examples/kotlin/account/create.md index a8528ec..068fa5f 100644 --- a/docs/examples/kotlin/account/create.md +++ b/docs/examples/kotlin/account/create.md @@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = account.create( + userId = "", email = "email@example.com", password = "password", ) diff --git a/docs/examples/kotlin/account/get-logs.md b/docs/examples/kotlin/account/get-logs.md index 9f79f0a..b8c89f4 100644 --- a/docs/examples/kotlin/account/get-logs.md +++ b/docs/examples/kotlin/account/get-logs.md @@ -17,7 +17,8 @@ class MainActivity : AppCompatActivity() { val account = Account(client) GlobalScope.launch { - val response = account.getLogs() + val response = account.getLogs( + ) val json = response.body?.string() } } 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..923574e 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 @@ -18,7 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = account.updateMagicURLSession( - userId = "[USER_ID]", + userId = "", secret = "[SECRET]" ) val json = response.body?.string() diff --git a/docs/examples/kotlin/database/create-document.md b/docs/examples/kotlin/database/create-document.md index 72ec7ad..89ada64 100644 --- a/docs/examples/kotlin/database/create-document.md +++ b/docs/examples/kotlin/database/create-document.md @@ -19,6 +19,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = database.createDocument( collectionId = "[COLLECTION_ID]", + documentId = "", data = mapOf( "a" to "b" ), ) val json = response.body?.string() diff --git a/docs/examples/kotlin/storage/create-file.md b/docs/examples/kotlin/storage/create-file.md index 92a5e95..f4f36c9 100644 --- a/docs/examples/kotlin/storage/create-file.md +++ b/docs/examples/kotlin/storage/create-file.md @@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = storage.createFile( + fileId = "", file = File("./path-to-files/image.jpg"), ) val json = response.body?.string() diff --git a/docs/examples/kotlin/teams/create.md b/docs/examples/kotlin/teams/create.md index 068fbd6..fcce1e0 100644 --- a/docs/examples/kotlin/teams/create.md +++ b/docs/examples/kotlin/teams/create.md @@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = teams.create( + teamId = "", name = "[NAME]", ) val json = response.body?.string() diff --git a/docs/examples/kotlin/teams/get-membership.md b/docs/examples/kotlin/teams/get-membership.md new file mode 100644 index 0000000..aa3f29e --- /dev/null +++ b/docs/examples/kotlin/teams/get-membership.md @@ -0,0 +1,27 @@ +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.getMembership( + teamId = "[TEAM_ID]", + membershipId = "[MEMBERSHIP_ID]" + ) + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/Query.kt b/library/src/main/java/io/appwrite/Query.kt new file mode 100644 index 0000000..1b3098d --- /dev/null +++ b/library/src/main/java/io/appwrite/Query.kt @@ -0,0 +1,32 @@ +package io.appwrite + +class Query { + companion object { + fun equal(attribute: String, value: Any) = addQuery(attribute, "equal", value) + + fun notEqual(attribute: String, value: Any) = Query.addQuery(attribute, "notEqual", value) + + fun lesser(attribute: String, value: Any) = Query.addQuery(attribute, "lesser", value) + + fun lesserEqual(attribute: String, value: Any) = Query.addQuery(attribute, "lesserEqual", value) + + fun greater(attribute: String, value: Any) = Query.addQuery(attribute, "greater", value) + + fun greaterEqual(attribute: String, value: Any) = Query.addQuery(attribute, "greaterEqual", value) + + fun contains(attribute: String, value: List) = Query.addQuery(attribute, "contains", value) + + private fun addQuery(attribute: String, oper: String, value: Any): String { + return when (value) { + is List<*> -> "${attribute}.${oper}(${value.map{it -> parseValues(it!!)}.joinToString(",")})" + else -> "${attribute}.${oper}(${Query.parseValues(value)})" + } + } + private fun parseValues(value: Any): String { + return when (value) { + is String -> "\"${value}\"" + else -> "${value}" + } + } + } +} diff --git a/library/src/main/java/io/appwrite/models/Document.kt b/library/src/main/java/io/appwrite/models/Document.kt index 0941dfe..f443676 100644 --- a/library/src/main/java/io/appwrite/models/Document.kt +++ b/library/src/main/java/io/appwrite/models/Document.kt @@ -17,10 +17,16 @@ data class Document( val collection: String, /** - * Document permissions. + * Document read permissions. * */ - val permissions: Permissions, + val read: List, + + /** + * Document write permissions. + * + */ + val write: List, val data: Map ) { @@ -29,7 +35,8 @@ data class Document( fun from(map: Map) = Document( id = map["\$id"] as String, collection = map["\$collection"] as String, - permissions = Permissions.from(map = map["\$permissions"] as Map), + read = map["\$read"] as List, + write = map["\$write"] as List, data = map ) } @@ -37,7 +44,8 @@ data class Document( fun toMap(): Map = mapOf( "\$id" to id as Any, "\$collection" to collection as Any, - "\$permissions" to permissions.toMap() as Any, + "\$read" to read as Any, + "\$write" to write as Any, "data" to data ) diff --git a/library/src/main/java/io/appwrite/models/Execution.kt b/library/src/main/java/io/appwrite/models/Execution.kt index e9e8d8f..2d25a73 100644 --- a/library/src/main/java/io/appwrite/models/Execution.kt +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -11,10 +11,10 @@ data class Execution( val id: String, /** - * Execution permissions. + * Execution read permissions. * */ - val permissions: Permissions, + val read: List, /** * Function ID. @@ -68,7 +68,7 @@ data class Execution( @Suppress("UNCHECKED_CAST") fun from(map: Map) = Execution( id = map["\$id"] as String, - permissions = Permissions.from(map = map["\$permissions"] as Map), + read = map["\$read"] as List, functionId = map["functionId"] as String, dateCreated = map["dateCreated"] as Long, trigger = map["trigger"] as String, @@ -82,7 +82,7 @@ data class Execution( fun toMap(): Map = mapOf( "\$id" to id as Any, - "\$permissions" to permissions.toMap() as Any, + "\$read" to read as Any, "functionId" to functionId as Any, "dateCreated" to dateCreated as Any, "trigger" to trigger as Any, diff --git a/library/src/main/java/io/appwrite/models/File.kt b/library/src/main/java/io/appwrite/models/File.kt index daa35c2..1546c61 100644 --- a/library/src/main/java/io/appwrite/models/File.kt +++ b/library/src/main/java/io/appwrite/models/File.kt @@ -11,10 +11,16 @@ data class File( val id: String, /** - * File permissions. + * File read permissions. * */ - val permissions: Permissions, + val read: List, + + /** + * File write permissions. + * + */ + val write: List, /** * File name. @@ -50,7 +56,8 @@ data class File( @Suppress("UNCHECKED_CAST") fun from(map: Map) = File( id = map["\$id"] as String, - permissions = Permissions.from(map = map["\$permissions"] as Map), + read = map["\$read"] as List, + write = map["\$write"] as List, name = map["name"] as String, dateCreated = map["dateCreated"] as Long, signature = map["signature"] as String, @@ -61,7 +68,8 @@ data class File( fun toMap(): Map = mapOf( "\$id" to id as Any, - "\$permissions" to permissions.toMap() as Any, + "\$read" to read as Any, + "\$write" to write as Any, "name" to name as Any, "dateCreated" to dateCreated as Any, "signature" to signature as Any, diff --git a/library/src/main/java/io/appwrite/models/Log.kt b/library/src/main/java/io/appwrite/models/Log.kt index 028aa71..05a0786 100644 --- a/library/src/main/java/io/appwrite/models/Log.kt +++ b/library/src/main/java/io/appwrite/models/Log.kt @@ -10,6 +10,30 @@ data class Log( */ val event: String, + /** + * User ID. + * + */ + val userId: String, + + /** + * User Email. + * + */ + val userEmail: String, + + /** + * User Name. + * + */ + val userName: String, + + /** + * API mode when event triggered. + * + */ + val mode: String, + /** * IP session in use when the session was created. * @@ -110,6 +134,10 @@ data class Log( @Suppress("UNCHECKED_CAST") fun from(map: Map) = Log( event = map["event"] as String, + userId = map["userId"] as String, + userEmail = map["userEmail"] as String, + userName = map["userName"] as String, + mode = map["mode"] as String, ip = map["ip"] as String, time = map["time"] as Long, osCode = map["osCode"] as String, @@ -131,6 +159,10 @@ data class Log( 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, diff --git a/library/src/main/java/io/appwrite/models/LogList.kt b/library/src/main/java/io/appwrite/models/LogList.kt index a741ae4..a6bbd4a 100644 --- a/library/src/main/java/io/appwrite/models/LogList.kt +++ b/library/src/main/java/io/appwrite/models/LogList.kt @@ -4,6 +4,12 @@ package io.appwrite.models * Logs List */ data class LogList( + /** + * Total number of items available on the server. + * + */ + val sum: Long, + /** * List of logs. * @@ -13,11 +19,13 @@ data class LogList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = LogList( + sum = map["sum"] as Long, logs = (map["logs"] as List>).map { Log.from(map = it) } ) } fun toMap(): Map = mapOf( + "sum" to sum 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/Permissions.kt b/library/src/main/java/io/appwrite/models/Permissions.kt deleted file mode 100644 index 81cd07d..0000000 --- a/library/src/main/java/io/appwrite/models/Permissions.kt +++ /dev/null @@ -1,31 +0,0 @@ -package io.appwrite.models - -/** - * Permissions - */ -data class Permissions( - /** - * Read permissions. - * - */ - val read: List, - - /** - * Write permissions. - * - */ - val write: List -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Permissions( - read = map["read"] as List, - write = map["write"] as List - ) - } - - fun toMap(): Map = mapOf( - "read" to read as Any, - "write" to write as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/User.kt b/library/src/main/java/io/appwrite/models/User.kt index 82039e4..0af27cc 100644 --- a/library/src/main/java/io/appwrite/models/User.kt +++ b/library/src/main/java/io/appwrite/models/User.kt @@ -23,10 +23,10 @@ data class User( val registration: Long, /** - * User status. 0 for Unactivated, 1 for active and 2 is blocked. + * User status. Pass `true` for enabled and `false` for disabled. * */ - val status: Long, + val status: Boolean, /** * Unix timestamp of the most recent password update @@ -58,7 +58,7 @@ data class User( id = map["\$id"] as String, name = map["name"] as String, registration = map["registration"] as Long, - status = map["status"] as Long, + status = map["status"] as Boolean, passwordUpdate = map["passwordUpdate"] as Long, email = map["email"] as String, emailVerification = map["emailVerification"] as Boolean, diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 063d602..521c741 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -53,6 +53,7 @@ class Account(client: Client) : Service(client) { * 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 email User email. * @param password User password. Must be between 6 to 32 chars. * @param name User name. Max length: 128 chars. @@ -61,12 +62,14 @@ class Account(client: Client) : Service(client) { @JvmOverloads @Throws(AppwriteException::class) suspend fun create( + userId: String, email: String, password: String, name: String? = null ): io.appwrite.models.User { val path = "/account" val params = mapOf( + "userId" to userId, "email" to email, "password" to password, "name" to name @@ -196,13 +199,20 @@ class Account(client: Client) : Service(client) { * 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 limit Maximum number of logs to return in response. Use this value to manage pagination. By default will return maximum 25 results. Maximum of 100 results allowed per request. + * @param offset Offset value. The default value is 0. Use this param to manage pagination. * @return [io.appwrite.models.LogList] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getLogs(): io.appwrite.models.LogList { + suspend fun getLogs( + limit: Long? = null, + offset: Long? = null + ): io.appwrite.models.LogList { val path = "/account/logs" val params = mapOf( + "limit" to limit, + "offset" to offset ) val headers = mapOf( "content-type" to "application/json" @@ -588,6 +598,7 @@ class Account(client: Client) : Service(client) { * 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. * @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] @@ -595,11 +606,13 @@ class Account(client: Client) : Service(client) { @JvmOverloads @Throws(AppwriteException::class) suspend fun createMagicURLSession( + userId: String, email: String, url: String? = null ): io.appwrite.models.Token { val path = "/account/sessions/magic-url" val params = mapOf( + "userId" to userId, "email" to email, "url" to url ) diff --git a/library/src/main/java/io/appwrite/services/Database.kt b/library/src/main/java/io/appwrite/services/Database.kt index 6baecdc..357796a 100644 --- a/library/src/main/java/io/appwrite/services/Database.kt +++ b/library/src/main/java/io/appwrite/services/Database.kt @@ -18,37 +18,37 @@ class Database(client: Client) : Service(client) { * of the project's documents. [Learn more about different API * modes](/docs/admin). * - * @param collectionId Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection). - * @param filters Array of filter strings. Each filter is constructed from a key name, comparison operator (=, !=, >, <, <=, >=) and a value. You can also use a dot (.) separator in attribute names to filter by child document attributes. Examples: 'name=John Doe' or 'category.$id>=5bed2d152c362'. + * @param collectionId Collection unique ID. You can create a new collection using the Database service [server integration](/docs/server/database#createCollection). + * @param queries Array of query strings. * @param limit Maximum number of documents to return in response. Use this value to manage pagination. By default will return maximum 25 results. Maximum of 100 results allowed per request. * @param offset Offset value. The default value is 0. Use this param to manage pagination. - * @param orderField Document field that results will be sorted by. - * @param orderType Order direction. Possible values are DESC for descending order, or ASC for ascending order. - * @param orderCast Order field type casting. Possible values are int, string, date, time or datetime. The database will attempt to cast the order field to the value you pass here. The default value is a string. - * @param search Search query. Enter any free text search. The database will try to find a match against all document attributes and children. Max length: 256 chars. + * @param cursor ID of the document used as the starting point for the query, excluding the document itself. Should be used for efficient pagination when working with large sets of data. + * @param cursorDirection Direction of the cursor. + * @param orderAttributes Array of attributes used to sort results. + * @param orderTypes Array of order directions for sorting attribtues. Possible values are DESC for descending order, or ASC for ascending order. * @return [io.appwrite.models.DocumentList] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun listDocuments( collectionId: String, - filters: List? = null, + queries: List? = null, limit: Long? = null, offset: Long? = null, - orderField: String? = null, - orderType: String? = null, - orderCast: String? = null, - search: String? = null + cursor: String? = null, + cursorDirection: String? = null, + orderAttributes: List? = null, + orderTypes: List? = null ): io.appwrite.models.DocumentList { val path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId) val params = mapOf( - "filters" to filters, + "queries" to queries, "limit" to limit, "offset" to offset, - "orderField" to orderField, - "orderType" to orderType, - "orderCast" to orderCast, - "search" to search + "cursor" to cursor, + "cursorDirection" to cursorDirection, + "orderAttributes" to orderAttributes, + "orderTypes" to orderTypes ) val headers = mapOf( "content-type" to "application/json" @@ -75,33 +75,27 @@ class Database(client: Client) : Service(client) { * directly from your database console. * * @param collectionId Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection). + * @param documentId 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 data Document data as JSON object. * @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. * @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. - * @param parentDocument Parent document unique ID. Use when you want your new document to be a child of a parent document. - * @param parentProperty Parent document property name. Use when you want your new document to be a child of a parent document. - * @param parentPropertyType Parent document property connection type. You can set this value to **assign**, **append** or **prepend**, default value is assign. Use when you want your new document to be a child of a parent document. * @return [io.appwrite.models.Document] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun createDocument( collectionId: String, + documentId: String, data: Any, read: List? = null, - write: List? = null, - parentDocument: String? = null, - parentProperty: String? = null, - parentPropertyType: String? = null + write: List? = null ): io.appwrite.models.Document { val path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId) val params = mapOf( + "documentId" to documentId, "data" to data, "read" to read, - "write" to write, - "parentDocument" to parentDocument, - "parentProperty" to parentProperty, - "parentPropertyType" to parentPropertyType + "write" to write ) val headers = mapOf( "content-type" to "application/json" @@ -125,7 +119,7 @@ class Database(client: Client) : Service(client) { * Get a document by its unique ID. This endpoint response returns a JSON * object with the document data. * - * @param collectionId Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection). + * @param collectionId Collection unique ID. You can create a new collection using the Database service [server integration](/docs/server/database#createCollection). * @param documentId Document unique ID. * @return [io.appwrite.models.Document] */ @@ -205,7 +199,7 @@ class Database(client: Client) : Service(client) { * documents, its attributes and relations to other documents. Child documents * **will not** be deleted. * - * @param collectionId Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection). + * @param collectionId Collection unique ID. You can create a new collection using the Database service [server integration](/docs/server/database#createCollection). * @param documentId Document unique ID. * @return [Any] */ diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index 83ac165..742f2b4 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -19,27 +19,30 @@ class Functions(client: Client) : Service(client) { * different API modes](/docs/admin). * * @param functionId Function unique ID. - * @param search Search term to filter your list results. Max length: 256 chars. * @param limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. * @param offset Results offset. The default value is 0. Use this param to manage pagination. - * @param orderType Order result by ASC or DESC order. + * @param search Search term to filter your list results. Max length: 256 chars. + * @param cursor ID of the execution used as the starting point for the query, excluding the execution itself. Should be used for efficient pagination when working with large sets of data. + * @param cursorDirection Direction of the cursor. * @return [io.appwrite.models.ExecutionList] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun listExecutions( functionId: String, - search: String? = null, limit: Long? = null, offset: Long? = null, - orderType: String? = null + search: String? = null, + cursor: String? = null, + cursorDirection: String? = null ): io.appwrite.models.ExecutionList { val path = "/functions/{functionId}/executions".replace("{functionId}", functionId) val params = mapOf( - "search" to search, "limit" to limit, "offset" to offset, - "orderType" to orderType + "search" to search, + "cursor" to cursor, + "cursorDirection" to cursorDirection ) val headers = mapOf( "content-type" to "application/json" diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index 1b1941e..8e68487 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -22,6 +22,8 @@ class Storage(client: Client) : Service(client) { * @param search Search term to filter your list results. Max length: 256 chars. * @param limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. * @param offset Results offset. The default value is 0. Use this param to manage pagination. + * @param cursor ID of the file used as the starting point for the query, excluding the file itself. Should be used for efficient pagination when working with large sets of data. + * @param cursorDirection Direction of the cursor. * @param orderType Order result by ASC or DESC order. * @return [io.appwrite.models.FileList] */ @@ -31,6 +33,8 @@ class Storage(client: Client) : Service(client) { search: String? = null, limit: Long? = null, offset: Long? = null, + cursor: String? = null, + cursorDirection: String? = null, orderType: String? = null ): io.appwrite.models.FileList { val path = "/storage/files" @@ -38,6 +42,8 @@ class Storage(client: Client) : Service(client) { "search" to search, "limit" to limit, "offset" to offset, + "cursor" to cursor, + "cursorDirection" to cursorDirection, "orderType" to orderType ) val headers = mapOf( @@ -63,6 +69,7 @@ class Storage(client: Client) : Service(client) { * assigned to read and write access unless he has passed custom values for * read and write arguments. * + * @param fileId 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 file Binary file. * @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. * @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. @@ -71,12 +78,14 @@ class Storage(client: Client) : Service(client) { @JvmOverloads @Throws(AppwriteException::class) suspend fun createFile( + fileId: String, file: File, read: List? = null, write: List? = null ): io.appwrite.models.File { val path = "/storage/files" val params = mapOf( + "fileId" to fileId, "file" to file, "read" to read, "write" to write diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 90dcba1..53bd147 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -21,6 +21,8 @@ class Teams(client: Client) : Service(client) { * @param search Search term to filter your list results. Max length: 256 chars. * @param limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. * @param offset Results offset. The default value is 0. Use this param to manage pagination. + * @param cursor ID of the team used as the starting point for the query, excluding the team itself. Should be used for efficient pagination when working with large sets of data. + * @param cursorDirection Direction of the cursor. * @param orderType Order result by ASC or DESC order. * @return [io.appwrite.models.TeamList] */ @@ -30,6 +32,8 @@ class Teams(client: Client) : Service(client) { search: String? = null, limit: Long? = null, offset: Long? = null, + cursor: String? = null, + cursorDirection: String? = null, orderType: String? = null ): io.appwrite.models.TeamList { val path = "/teams" @@ -37,6 +41,8 @@ class Teams(client: Client) : Service(client) { "search" to search, "limit" to limit, "offset" to offset, + "cursor" to cursor, + "cursorDirection" to cursorDirection, "orderType" to orderType ) val headers = mapOf( @@ -63,6 +69,7 @@ class Teams(client: Client) : Service(client) { * who will be able add new owners and update or delete the team from your * project. * + * @param teamId 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 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). Max length for each role is 32 chars. * @return [io.appwrite.models.Team] @@ -70,11 +77,13 @@ class Teams(client: Client) : Service(client) { @JvmOverloads @Throws(AppwriteException::class) suspend fun create( + teamId: String, name: String, roles: List? = null ): io.appwrite.models.Team { val path = "/teams" val params = mapOf( + "teamId" to teamId, "name" to name, "roles" to roles ) @@ -202,6 +211,8 @@ class Teams(client: Client) : Service(client) { * @param search Search term to filter your list results. Max length: 256 chars. * @param limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. * @param offset Results offset. The default value is 0. Use this param to manage pagination. + * @param cursor ID of the membership used as the starting point for the query, excluding the membership itself. Should be used for efficient pagination when working with large sets of data. + * @param cursorDirection Direction of the cursor. * @param orderType Order result by ASC or DESC order. * @return [io.appwrite.models.MembershipList] */ @@ -212,6 +223,8 @@ class Teams(client: Client) : Service(client) { search: String? = null, limit: Long? = null, offset: Long? = null, + cursor: String? = null, + cursorDirection: String? = null, orderType: String? = null ): io.appwrite.models.MembershipList { val path = "/teams/{teamId}/memberships".replace("{teamId}", teamId) @@ -219,6 +232,8 @@ class Teams(client: Client) : Service(client) { "search" to search, "limit" to limit, "offset" to offset, + "cursor" to cursor, + "cursorDirection" to cursorDirection, "orderType" to orderType ) val headers = mapOf( @@ -296,6 +311,41 @@ class Teams(client: Client) : Service(client) { ) } + /** + * Get Team Membership + * + * Get a team member by the membership unique id. All team members have read + * access for this resource. + * + * @param teamId Team unique ID. + * @param membershipId membership unique ID. + * @return [io.appwrite.models.MembershipList] + */ + @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) + val params = mapOf( + ) + val headers = mapOf( + "content-type" to "application/json" + ) + val convert: (Map) -> io.appwrite.models.MembershipList = { + io.appwrite.models.MembershipList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.MembershipList::class.java, + convert = convert + ) + } + /** * Update Membership Roles * From c8d232565211955a15edc462e165193492452484 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 25 Nov 2021 19:35:19 +0400 Subject: [PATCH 012/118] feat: update android sdk to 0.12.x --- README.md | 4 ++-- build.gradle | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 80451d6..82d13c1 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:0.2.1") +implementation("io.appwrite:sdk-for-android:0.3.0-SNAPSHOT") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 0.2.1 + 0.3.0-SNAPSHOT ``` diff --git a/build.gradle b/build.gradle index d2f3361..5dd7a83 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,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" - version "0.2.1" + version "0.3.0-SNAPSHOT" repositories { maven { url "https://plugins.gradle.org/m2/" } google() From df55095c54c96e6b9ee6911692db07a275bc0548 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Fri, 17 Dec 2021 17:28:28 +0545 Subject: [PATCH 013/118] update twitter link --- README.md | 2 +- build.gradle | 6 +- example-java/build.gradle | 7 +- example-java/src/main/AndroidManifest.xml | 2 +- .../appwrite/example_java/MainActivity.java | 13 +- example/build.gradle | 25 +- example/src/main/AndroidManifest.xml | 4 +- .../android/ui/accounts/AccountsViewModel.kt | 40 +- gradle/wrapper/gradle-wrapper.properties | 2 +- library/build.gradle | 11 +- library/src/main/java/io/appwrite/Client.kt | 106 +++-- .../appwrite/exceptions/AppwriteException.kt | 2 +- .../io/appwrite/json/PreciseNumberAdapter.kt | 64 +++ .../main/java/io/appwrite/models/Continent.kt | 31 ++ .../java/io/appwrite/models/ContinentList.kt | 31 ++ .../main/java/io/appwrite/models/Country.kt | 31 ++ .../java/io/appwrite/models/CountryList.kt | 31 ++ .../main/java/io/appwrite/models/Currency.kt | 71 +++ .../java/io/appwrite/models/CurrencyList.kt | 31 ++ .../main/java/io/appwrite/models/Document.kt | 47 ++ .../java/io/appwrite/models/DocumentList.kt | 34 ++ .../main/java/io/appwrite/models/Execution.kt | 95 ++++ .../java/io/appwrite/models/ExecutionList.kt | 31 ++ .../src/main/java/io/appwrite/models/File.kt | 71 +++ .../main/java/io/appwrite/models/FileList.kt | 31 ++ .../src/main/java/io/appwrite/models/Jwt.kt | 23 + .../main/java/io/appwrite/models/Language.kt | 39 ++ .../java/io/appwrite/models/LanguageList.kt | 31 ++ .../main/java/io/appwrite/models/Locale.kt | 71 +++ .../src/main/java/io/appwrite/models/Log.kt | 151 ++++++ .../main/java/io/appwrite/models/LogList.kt | 23 + .../java/io/appwrite/models/Membership.kt | 87 ++++ .../java/io/appwrite/models/MembershipList.kt | 31 ++ .../java/io/appwrite/models/Permissions.kt | 31 ++ .../src/main/java/io/appwrite/models/Phone.kt | 39 ++ .../main/java/io/appwrite/models/PhoneList.kt | 31 ++ .../java/io/appwrite/models/Preferences.kt | 23 + .../java/io/appwrite/models/RealtimeModels.kt | 1 + .../main/java/io/appwrite/models/Session.kt | 191 ++++++++ .../java/io/appwrite/models/SessionList.kt | 31 ++ .../src/main/java/io/appwrite/models/Team.kt | 47 ++ .../main/java/io/appwrite/models/TeamList.kt | 31 ++ .../src/main/java/io/appwrite/models/Token.kt | 47 ++ .../src/main/java/io/appwrite/models/User.kt | 79 ++++ .../main/java/io/appwrite/services/Account.kt | 447 ++++++++++++------ .../main/java/io/appwrite/services/Avatars.kt | 165 ++++--- .../java/io/appwrite/services/Database.kt | 139 ++++-- .../java/io/appwrite/services/Functions.kt | 77 ++- .../main/java/io/appwrite/services/Locale.kt | 127 +++-- .../java/io/appwrite/services/Realtime.kt | 106 +++-- .../main/java/io/appwrite/services/Storage.kt | 191 +++++--- .../main/java/io/appwrite/services/Teams.kt | 239 ++++++---- 52 files changed, 2710 insertions(+), 607 deletions(-) create mode 100644 library/src/main/java/io/appwrite/json/PreciseNumberAdapter.kt create mode 100644 library/src/main/java/io/appwrite/models/Continent.kt create mode 100644 library/src/main/java/io/appwrite/models/ContinentList.kt create mode 100644 library/src/main/java/io/appwrite/models/Country.kt create mode 100644 library/src/main/java/io/appwrite/models/CountryList.kt create mode 100644 library/src/main/java/io/appwrite/models/Currency.kt create mode 100644 library/src/main/java/io/appwrite/models/CurrencyList.kt create mode 100644 library/src/main/java/io/appwrite/models/Document.kt create mode 100644 library/src/main/java/io/appwrite/models/DocumentList.kt create mode 100644 library/src/main/java/io/appwrite/models/Execution.kt create mode 100644 library/src/main/java/io/appwrite/models/ExecutionList.kt create mode 100644 library/src/main/java/io/appwrite/models/File.kt create mode 100644 library/src/main/java/io/appwrite/models/FileList.kt create mode 100644 library/src/main/java/io/appwrite/models/Jwt.kt create mode 100644 library/src/main/java/io/appwrite/models/Language.kt create mode 100644 library/src/main/java/io/appwrite/models/LanguageList.kt create mode 100644 library/src/main/java/io/appwrite/models/Locale.kt create mode 100644 library/src/main/java/io/appwrite/models/Log.kt create mode 100644 library/src/main/java/io/appwrite/models/LogList.kt create mode 100644 library/src/main/java/io/appwrite/models/Membership.kt create mode 100644 library/src/main/java/io/appwrite/models/MembershipList.kt create mode 100644 library/src/main/java/io/appwrite/models/Permissions.kt create mode 100644 library/src/main/java/io/appwrite/models/Phone.kt create mode 100644 library/src/main/java/io/appwrite/models/PhoneList.kt create mode 100644 library/src/main/java/io/appwrite/models/Preferences.kt create mode 100644 library/src/main/java/io/appwrite/models/Session.kt create mode 100644 library/src/main/java/io/appwrite/models/SessionList.kt create mode 100644 library/src/main/java/io/appwrite/models/Team.kt create mode 100644 library/src/main/java/io/appwrite/models/TeamList.kt create mode 100644 library/src/main/java/io/appwrite/models/Token.kt create mode 100644 library/src/main/java/io/appwrite/models/User.kt diff --git a/README.md b/README.md index 862d6b8..0580a7a 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ![License](https://img.shields.io/github/license/appwrite/sdk-for-android.svg?style=flat-square) ![Version](https://img.shields.io/badge/api%20version-0.11.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_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io) +[![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 0.11.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).** diff --git a/build.gradle b/build.gradle index 4df4d35..d2f3361 100644 --- a/build.gradle +++ b/build.gradle @@ -2,15 +2,15 @@ apply plugin: 'io.github.gradle-nexus.publish-plugin' // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = "1.4.31" - version '0.2.1' + ext.kotlin_version = "1.5.31" + version "0.2.1" repositories { maven { url "https://plugins.gradle.org/m2/" } google() mavenCentral() } dependencies { - classpath "com.android.tools.build:gradle:4.2.0" + classpath "com.android.tools.build:gradle:7.0.3" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'io.github.gradle-nexus:publish-plugin:1.1.0' diff --git a/example-java/build.gradle b/example-java/build.gradle index fb49677..fb916fa 100644 --- a/example-java/build.gradle +++ b/example-java/build.gradle @@ -3,13 +3,12 @@ plugins { } android { - compileSdkVersion 30 - buildToolsVersion "30.0.3" + compileSdkVersion 31 defaultConfig { applicationId "io.appwrite.example_java" minSdkVersion 23 - targetSdkVersion 30 + targetSdkVersion 31 versionCode 1 versionName "1.0" @@ -29,8 +28,8 @@ android { } dependencies { - implementation project(path: ':library') + implementation 'androidx.appcompat:appcompat:1.3.0' implementation 'com.google.android.material:material:1.3.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' diff --git a/example-java/src/main/AndroidManifest.xml b/example-java/src/main/AndroidManifest.xml index 1fd3789..0276c9c 100644 --- a/example-java/src/main/AndroidManifest.xml +++ b/example-java/src/main/AndroidManifest.xml @@ -9,7 +9,7 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.AppwriteAndroidSDK"> - + 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 5b0d09b..28e3222 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 @@ -4,15 +4,15 @@ import android.os.Bundle; import android.util.Log; import org.jetbrains.annotations.NotNull; -import org.json.JSONObject; import io.appwrite.Client; import io.appwrite.exceptions.AppwriteException; +import io.appwrite.extensions.JsonExtensionsKt; +import io.appwrite.models.Session; import io.appwrite.services.Account; import kotlin.Result; import kotlin.coroutines.Continuation; import kotlin.coroutines.CoroutineContext; import kotlin.coroutines.EmptyCoroutineContext; -import okhttp3.Response; public class MainActivity extends AppCompatActivity { @@ -28,7 +28,7 @@ protected void onCreate(Bundle savedInstanceState) { Account account = new Account(client); try { - account.createSession("test7@test.com","password", new Continuation() { + account.createSession("test7@test.com","password", new Continuation() { @NotNull @Override public CoroutineContext getContext() { @@ -37,16 +37,13 @@ public CoroutineContext getContext() { @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(); - json = new JSONObject(json).toString(8); - Log.d("RESPONSE", json); + Session session = (Session) o; + Log.d("RESPONSE", JsonExtensionsKt.toJson(session)); } } catch (Throwable th) { Log.e("ERROR", th.toString()); diff --git a/example/build.gradle b/example/build.gradle index 6057427..6c5e1f5 100644 --- a/example/build.gradle +++ b/example/build.gradle @@ -4,13 +4,12 @@ plugins { } android { - compileSdkVersion 30 - buildToolsVersion "30.0.3" + compileSdkVersion 31 defaultConfig { applicationId "io.appwrite.android" minSdkVersion 21 - targetSdkVersion 30 + targetSdkVersion 31 versionCode 1 versionName "1.0" @@ -37,23 +36,23 @@ android { } dependencies { - implementation project(path: ':library') + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.core:core-ktx:1.5.0' - implementation 'androidx.appcompat:appcompat:1.3.0' - implementation 'com.google.android.material:material:1.3.0' - implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + implementation 'androidx.core:core-ktx:1.6.0' + implementation 'androidx.appcompat:appcompat:1.3.1' + implementation 'com.google.android.material:material:1.4.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.1' implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5' - implementation "androidx.fragment:fragment-ktx:1.3.2" + implementation "androidx.fragment:fragment-ktx:1.3.6" implementation 'androidx.navigation:navigation-ui-ktx:2.3.5' implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1' implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1' implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5' implementation 'androidx.navigation:navigation-ui-ktx:2.3.5' - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2" testImplementation 'junit:junit:4.+' - androidTestImplementation 'androidx.test.ext:junit:1.1.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' } \ No newline at end of file diff --git a/example/src/main/AndroidManifest.xml b/example/src/main/AndroidManifest.xml index 91f2179..e3c2421 100644 --- a/example/src/main/AndroidManifest.xml +++ b/example/src/main/AndroidManifest.xml @@ -9,14 +9,14 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.AppwriteAndroidSDK"> - + - + 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 2d812e8..1e7b084 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 @@ -6,10 +6,9 @@ import androidx.lifecycle.* import io.appwrite.android.utils.Client.client import io.appwrite.android.utils.Event import io.appwrite.exceptions.AppwriteException +import io.appwrite.extensions.toJson import io.appwrite.services.Account import kotlinx.coroutines.launch -import org.json.JSONObject - class AccountsViewModel : ViewModel() { @@ -27,13 +26,11 @@ class AccountsViewModel : ViewModel() { Account(client) } - fun onLogin(email: Editable , password : Editable) { + fun onLogin(email: Editable, password: Editable) { viewModelScope.launch { try { - var response = accountService.createSession(email.toString(), password.toString()) - var json = response.body?.string() ?: "" - json = JSONObject(json).toString(8) - _response.postValue(Event(json)) + val session = accountService.createSession(email.toString(), password.toString()) + _response.postValue(Event(session.toJson())) } catch (e: AppwriteException) { _error.postValue(Event(e)) } @@ -41,13 +38,12 @@ class AccountsViewModel : ViewModel() { } - fun onSignup(email: Editable , password : Editable, name: Editable) { + fun onSignup(email: Editable, password: Editable, name: Editable) { viewModelScope.launch { try { - var response = accountService.create(email.toString(), password.toString(), name.toString()) - var json = response.body?.string() ?: "" - json = JSONObject(json).toString(2) - _response.postValue(Event(json)) + val user = + accountService.create(email.toString(), password.toString(), name.toString()) + _response.postValue(Event(user.toJson())) } catch (e: AppwriteException) { _error.postValue(Event(e)) } @@ -58,7 +54,12 @@ class AccountsViewModel : ViewModel() { fun oAuthLogin(activity: ComponentActivity) { viewModelScope.launch { try { - accountService.createOAuth2Session(activity, "facebook", "appwrite-callback-6070749e6acd4://demo.appwrite.io/auth/oauth2/success", "appwrite-callback-6070749e6acd4://demo.appwrite.io/auth/oauth2/failure") + accountService.createOAuth2Session( + activity, + "facebook", + "appwrite-callback-6070749e6acd4://demo.appwrite.io/auth/oauth2/success", + "appwrite-callback-6070749e6acd4://demo.appwrite.io/auth/oauth2/failure" + ) } catch (e: Exception) { _error.postValue(Event(e)) } catch (e: AppwriteException) { @@ -70,10 +71,8 @@ class AccountsViewModel : ViewModel() { fun getUser() { viewModelScope.launch { try { - var response = accountService.get() - var json = response.body?.string() ?: "" - json = JSONObject(json).toString(2) - _response.postValue(Event(json)) + val account = accountService.get() + _response.postValue(Event(account.toJson())) } catch (e: AppwriteException) { _error.postValue(Event(e)) } @@ -83,14 +82,11 @@ class AccountsViewModel : ViewModel() { fun logout() { viewModelScope.launch { try { - var response = accountService.deleteSession("current") - var json = response.body?.string()?.ifEmpty { "{}" } - json = JSONObject(json).toString(4) - _response.postValue(Event(json)) + val result = accountService.deleteSession("current") + _response.postValue(Event(result.toJson())) } catch (e: AppwriteException) { _error.postValue(Event(e)) } } } - } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2dadb9d..710f6bd 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Tue Jun 01 15:55:54 IST 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/library/build.gradle b/library/build.gradle index 9ae290e..cb15537 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,4 +1,3 @@ -import org.jetbrains.kotlin.config.KotlinCompilerVersion plugins { id("com.android.library") id("kotlin-android") @@ -21,11 +20,11 @@ ext { } android { - compileSdkVersion(30) + compileSdkVersion(31) defaultConfig { minSdkVersion(21) - targetSdkVersion(30) + targetSdkVersion(31) versionCode = 1 versionName = "1.0" buildConfigField "String", "SDK_VERSION", "\"${PUBLISH_VERSION}\"" @@ -52,9 +51,9 @@ android { } dependencies { - implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${KotlinCompilerVersion.VERSION}") - api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1") - api("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0") + 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(platform("com.squareup.okhttp3:okhttp-bom:4.9.0")) api("com.squareup.okhttp3:okhttp") diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 4dba7e5..162357e 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -2,10 +2,12 @@ package io.appwrite import android.content.Context import android.content.pm.PackageManager -import com.google.gson.Gson +import com.google.gson.GsonBuilder +import com.google.gson.reflect.TypeToken import io.appwrite.appwrite.BuildConfig import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.fromJson +import io.appwrite.json.PreciseNumberAdapter import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -17,6 +19,7 @@ import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.MediaType.Companion.toMediaType import okhttp3.RequestBody.Companion.asRequestBody import okhttp3.RequestBody.Companion.toRequestBody +import java.io.BufferedInputStream import java.io.BufferedReader import java.io.File import java.io.IOException @@ -44,6 +47,11 @@ class Client @JvmOverloads constructor( private val job = Job() + private val gson = GsonBuilder().registerTypeAdapter( + object : TypeToken>(){}.type, + PreciseNumberAdapter() + ).create() + lateinit var http: OkHttpClient private val headers: MutableMap @@ -143,9 +151,12 @@ class Client @JvmOverloads constructor( try { // Create a trust manager that does not validate certificate chains val trustAllCerts = arrayOf( + @Suppress("CustomX509TrustManager") object : X509TrustManager { + @Suppress("TrustAllX509TrustManager") override fun checkClientTrusted(chain: Array, authType: String) { } + @Suppress("TrustAllX509TrustManager") override fun checkServerTrusted(chain: Array, authType: String) { } override fun getAcceptedIssuers(): Array { @@ -223,13 +234,14 @@ class Client @JvmOverloads constructor( * @return [Response] */ @Throws(AppwriteException::class) - suspend fun call( + suspend fun call( method: String, path: String, headers: Map = mapOf(), - params: Map = mapOf() - ): Response { - + params: Map = mapOf(), + responseType: Class, + convert: ((Map) -> T)? = null + ): T { val filteredParams = params.filterValues { it != null } val requestHeaders = this.headers.toHeaders().newBuilder() @@ -264,7 +276,7 @@ class Client @JvmOverloads constructor( .get() .build() - return awaitResponse(request) + return awaitResponse(request, responseType, convert) } val body = if (MultipartBody.FORM.toString() == headers["content-type"]) { @@ -292,7 +304,7 @@ class Client @JvmOverloads constructor( } builder.build() } else { - Gson().toJson(filteredParams) + gson.toJson(filteredParams) .toRequestBody("application/json".toMediaType()) } @@ -302,21 +314,24 @@ class Client @JvmOverloads constructor( .method(method, body) .build() - return awaitResponse(request) + return awaitResponse(request, responseType, convert) } /** * Await Response - * - * @param method - * @param path - * @param headers - * @param params * - * @return [Response] + * @param request + * @param responseType + * @param convert + * + * @return [T] */ @Throws(AppwriteException::class) - private suspend fun awaitResponse(request: Request) = suspendCancellableCoroutine { + private suspend fun awaitResponse( + request: Request, + responseType: Class, + convert: ((Map) -> T)? = null + ) = suspendCancellableCoroutine { http.newCall(request).enqueue(object : Callback { override fun onFailure(call: Call, e: IOException) { if (it.isCancelled) { @@ -325,27 +340,54 @@ class Client @JvmOverloads constructor( it.cancel(e) } + @Suppress("UNCHECKED_CAST") override fun onResponse(call: Call, response: Response) { - if (response.code >= 400) { - val bodyString = response.body - ?.charStream() - ?.buffered() - ?.use(BufferedReader::readText) ?: "" - - val contentType: String = response.headers["content-type"] ?: "" - val error = if (contentType.contains("application/json", ignoreCase = true)) { - bodyString.fromJson() + if (!response.isSuccessful) { + val body = response.body!! + .charStream() + .buffered() + .use(BufferedReader::readText) + val error = if (response.headers["content-type"]?.contains("application/json") == true) { + body.fromJson() } else { - AppwriteException(bodyString, response.code) + AppwriteException(body, response.code) } - - it.cancel(AppwriteException( - error.message, - error.code, - bodyString - )) + it.cancel(error) + return + } + when { + responseType == Boolean::class.java -> { + it.resume(true as T) + return + } + responseType == ByteArray::class.java -> { + it.resume(response.body!! + .byteStream() + .buffered() + .use(BufferedInputStream::readBytes) as T + ) + return + } + response.body == null -> { + it.resume(true as T) + return + } + } + val body = response.body!! + .charStream() + .buffered() + .use(BufferedReader::readText) + if (body.isEmpty()) { + it.resume(true as T) + return } - it.resume(response) + val map = gson.fromJson>( + body, + object : TypeToken>(){}.type + ) + it.resume( + convert?.invoke(map) ?: map as T + ) } }) } diff --git a/library/src/main/java/io/appwrite/exceptions/AppwriteException.kt b/library/src/main/java/io/appwrite/exceptions/AppwriteException.kt index d7d4fbc..1d22595 100644 --- a/library/src/main/java/io/appwrite/exceptions/AppwriteException.kt +++ b/library/src/main/java/io/appwrite/exceptions/AppwriteException.kt @@ -3,7 +3,7 @@ package io.appwrite.exceptions import java.lang.Exception class AppwriteException( - message: String? = null, + override val message: String? = null, val code: Int? = null, val response: String? = null ) : Exception(message) \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/json/PreciseNumberAdapter.kt b/library/src/main/java/io/appwrite/json/PreciseNumberAdapter.kt new file mode 100644 index 0000000..6d408ac --- /dev/null +++ b/library/src/main/java/io/appwrite/json/PreciseNumberAdapter.kt @@ -0,0 +1,64 @@ +package io.appwrite.json + +import com.google.gson.Gson +import com.google.gson.TypeAdapter +import com.google.gson.stream.JsonReader +import com.google.gson.stream.JsonToken.* +import com.google.gson.stream.JsonWriter +import java.io.IOException + +internal class PreciseNumberAdapter : TypeAdapter() { + + private val delegate = Gson() + .getAdapter(Any::class.java) + + @Throws(IOException::class) + override fun write(out: JsonWriter?, value: Any?) { + delegate.write(out, value) + } + + @Throws(IOException::class) + override fun read(input: JsonReader): Any? { + return when (input.peek()) { + BEGIN_ARRAY -> { + val list = mutableListOf() + input.beginArray() + while (input.hasNext()) { + list.add(read(input)) + } + input.endArray() + list + } + BEGIN_OBJECT -> { + val map = mutableMapOf() + input.beginObject() + while (input.hasNext()) { + map[input.nextName()] = read(input) + } + input.endObject() + map + } + STRING -> { + input.nextString() + } + NUMBER -> { + val numberString = input.nextString() + if (numberString.indexOf('.') != -1) { + numberString.toDouble() + } else { + numberString.toLong() + } + } + BOOLEAN -> { + input.nextBoolean() + } + NULL -> { + input.nextNull() + null + } + else -> { + throw IllegalStateException() + } + } + } +} \ 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 new file mode 100644 index 0000000..da6eca6 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Continent.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Continent + */ +data class Continent( + /** + * Continent name. + * + */ + val name: String, + + /** + * Continent two letter code. + * + */ + val code: String +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Continent( + name = map["name"] 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 new file mode 100644 index 0000000..9b076c4 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/ContinentList.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Continents List + */ +data class ContinentList( + /** + * Total number of items available on the server. + * + */ + val sum: Long, + + /** + * List of continents. + * + */ + val continents: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = ContinentList( + sum = map["sum"] as Long, + continents = (map["continents"] as List>).map { Continent.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "sum" to sum 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 new file mode 100644 index 0000000..8c1d608 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Country.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Country + */ +data class Country( + /** + * Country name. + * + */ + val name: String, + + /** + * Country two-character ISO 3166-1 alpha code. + * + */ + val code: String +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Country( + name = map["name"] 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 new file mode 100644 index 0000000..a1476a1 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/CountryList.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Countries List + */ +data class CountryList( + /** + * Total number of items available on the server. + * + */ + val sum: Long, + + /** + * List of countries. + * + */ + val countries: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = CountryList( + sum = map["sum"] as Long, + countries = (map["countries"] as List>).map { Country.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "sum" to sum 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 new file mode 100644 index 0000000..58002c2 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Currency.kt @@ -0,0 +1,71 @@ +package io.appwrite.models + +/** + * Currency + */ +data class Currency( + /** + * Currency symbol. + * + */ + val symbol: String, + + /** + * Currency name. + * + */ + val name: String, + + /** + * Currency native symbol. + * + */ + val symbolNative: String, + + /** + * Number of decimal digits. + * + */ + val decimalDigits: Long, + + /** + * Currency digit rounding. + * + */ + val rounding: Double, + + /** + * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. + * + */ + val code: String, + + /** + * Currency plural name + * + */ + val namePlural: String +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Currency( + symbol = map["symbol"] as String, + name = map["name"] as String, + symbolNative = map["symbolNative"] as String, + decimalDigits = map["decimalDigits"] as Long, + rounding = map["rounding"] as Double, + code = map["code"] 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 new file mode 100644 index 0000000..d2863d9 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/CurrencyList.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Currencies List + */ +data class CurrencyList( + /** + * Total number of items available on the server. + * + */ + val sum: Long, + + /** + * List of currencies. + * + */ + val currencies: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = CurrencyList( + sum = map["sum"] as Long, + currencies = (map["currencies"] as List>).map { Currency.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "sum" to sum 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 new file mode 100644 index 0000000..0941dfe --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Document.kt @@ -0,0 +1,47 @@ +package io.appwrite.models + +/** + * Document + */ +data class Document( + /** + * Document ID. + * + */ + val id: String, + + /** + * Collection ID. + * + */ + val collection: String, + + /** + * Document permissions. + * + */ + val permissions: Permissions, + + val data: Map +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Document( + id = map["\$id"] as String, + collection = map["\$collection"] as String, + permissions = Permissions.from(map = map["\$permissions"] as Map), + data = map + ) + } + + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$collection" to collection as Any, + "\$permissions" to permissions.toMap() as Any, + "data" to data + ) + + fun convertTo(fromJson: (Map) -> T): T { + return fromJson(data) + } +} \ 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 new file mode 100644 index 0000000..c05899f --- /dev/null +++ b/library/src/main/java/io/appwrite/models/DocumentList.kt @@ -0,0 +1,34 @@ +package io.appwrite.models + +/** + * Documents List + */ +data class DocumentList( + /** + * Total number of items available on the server. + * + */ + val sum: Long, + + /** + * List of documents. + * + */ + val documents: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = DocumentList( + sum = map["sum"] as Long, + documents = (map["documents"] as List>).map { Document.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "sum" to sum 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 new file mode 100644 index 0000000..e9e8d8f --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -0,0 +1,95 @@ +package io.appwrite.models + +/** + * Execution + */ +data class Execution( + /** + * Execution ID. + * + */ + val id: String, + + /** + * Execution permissions. + * + */ + val permissions: Permissions, + + /** + * Function ID. + * + */ + val functionId: String, + + /** + * The execution creation date in Unix timestamp. + * + */ + val dateCreated: Long, + + /** + * The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. + * + */ + val trigger: String, + + /** + * The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`. + * + */ + val status: String, + + /** + * The script exit code. + * + */ + val exitCode: Long, + + /** + * The script stdout output string. Logs the last 4,000 characters of the execution stdout output. + * + */ + val stdout: String, + + /** + * The script stderr output string. Logs the last 4,000 characters of the execution stderr output + * + */ + val stderr: String, + + /** + * The script execution time in seconds. + * + */ + val time: Double +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Execution( + id = map["\$id"] as String, + permissions = Permissions.from(map = map["\$permissions"] as Map), + functionId = map["functionId"] as String, + dateCreated = map["dateCreated"] as Long, + trigger = map["trigger"] as String, + status = map["status"] as String, + exitCode = map["exitCode"] as Long, + stdout = map["stdout"] as String, + stderr = map["stderr"] as String, + time = map["time"] as Double + ) + } + + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$permissions" to permissions.toMap() as Any, + "functionId" to functionId as Any, + "dateCreated" to dateCreated as Any, + "trigger" to trigger as Any, + "status" to status as Any, + "exitCode" to exitCode as Any, + "stdout" to stdout as Any, + "stderr" to stderr as Any, + "time" to time 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 new file mode 100644 index 0000000..5ab06b7 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/ExecutionList.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Executions List + */ +data class ExecutionList( + /** + * Total number of items available on the server. + * + */ + val sum: Long, + + /** + * List of executions. + * + */ + val executions: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = ExecutionList( + sum = map["sum"] as Long, + executions = (map["executions"] as List>).map { Execution.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "sum" to sum 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 new file mode 100644 index 0000000..daa35c2 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/File.kt @@ -0,0 +1,71 @@ +package io.appwrite.models + +/** + * File + */ +data class File( + /** + * File ID. + * + */ + val id: String, + + /** + * File permissions. + * + */ + val permissions: Permissions, + + /** + * File name. + * + */ + val name: String, + + /** + * File creation date in Unix timestamp. + * + */ + val dateCreated: Long, + + /** + * File MD5 signature. + * + */ + val signature: String, + + /** + * File mime type. + * + */ + val mimeType: String, + + /** + * File original size in bytes. + * + */ + val sizeOriginal: Long +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = File( + id = map["\$id"] as String, + permissions = Permissions.from(map = map["\$permissions"] as Map), + name = map["name"] as String, + dateCreated = map["dateCreated"] as Long, + signature = map["signature"] as String, + mimeType = map["mimeType"] as String, + sizeOriginal = map["sizeOriginal"] as Long + ) + } + + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$permissions" to permissions.toMap() as Any, + "name" to name as Any, + "dateCreated" to dateCreated as Any, + "signature" to signature as Any, + "mimeType" to mimeType as Any, + "sizeOriginal" to sizeOriginal 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 new file mode 100644 index 0000000..4c9cf1c --- /dev/null +++ b/library/src/main/java/io/appwrite/models/FileList.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Files List + */ +data class FileList( + /** + * Total number of items available on the server. + * + */ + val sum: Long, + + /** + * List of files. + * + */ + val files: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = FileList( + sum = map["sum"] as Long, + files = (map["files"] as List>).map { File.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "sum" to sum 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 new file mode 100644 index 0000000..4012643 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Jwt.kt @@ -0,0 +1,23 @@ +package io.appwrite.models + +/** + * JWT + */ +data class Jwt( + /** + * JWT encoded string. + * + */ + val jwt: String +) { + companion object { + @Suppress("UNCHECKED_CAST") + 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 new file mode 100644 index 0000000..0f050a8 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Language.kt @@ -0,0 +1,39 @@ +package io.appwrite.models + +/** + * Language + */ +data class Language( + /** + * Language name. + * + */ + val name: String, + + /** + * Language two-character ISO 639-1 codes. + * + */ + val code: String, + + /** + * Language native name. + * + */ + val nativeName: String +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Language( + name = map["name"] as String, + code = map["code"] 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 new file mode 100644 index 0000000..813c99b --- /dev/null +++ b/library/src/main/java/io/appwrite/models/LanguageList.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Languages List + */ +data class LanguageList( + /** + * Total number of items available on the server. + * + */ + val sum: Long, + + /** + * List of languages. + * + */ + val languages: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = LanguageList( + sum = map["sum"] as Long, + languages = (map["languages"] as List>).map { Language.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "sum" to sum 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 new file mode 100644 index 0000000..6e812c5 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Locale.kt @@ -0,0 +1,71 @@ +package io.appwrite.models + +/** + * Locale + */ +data class Locale( + /** + * User IP address. + * + */ + val ip: String, + + /** + * Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format + * + */ + val countryCode: String, + + /** + * Country name. This field support localization. + * + */ + 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. + * + */ + val continentCode: String, + + /** + * Continent name. This field support localization. + * + */ + val continent: String, + + /** + * True if country is part of the Europian Union. + * + */ + val eu: Boolean, + + /** + * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format + * + */ + val currency: String +) { + companion object { + @Suppress("UNCHECKED_CAST") + 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 + ) + } + + 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 new file mode 100644 index 0000000..028aa71 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Log.kt @@ -0,0 +1,151 @@ +package io.appwrite.models + +/** + * Log + */ +data class Log( + /** + * Event name. + * + */ + val event: String, + + /** + * IP session in use when the session was created. + * + */ + val ip: String, + + /** + * Log creation time in Unix timestamp. + * + */ + val time: Long, + + /** + * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + * + */ + val osCode: String, + + /** + * Operating system name. + * + */ + val osName: String, + + /** + * Operating system version. + * + */ + val osVersion: String, + + /** + * Client type. + * + */ + val clientType: String, + + /** + * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + * + */ + val clientCode: String, + + /** + * Client name. + * + */ + val clientName: String, + + /** + * Client version. + * + */ + val clientVersion: String, + + /** + * Client engine name. + * + */ + val clientEngine: String, + + /** + * Client engine name. + * + */ + val clientEngineVersion: String, + + /** + * Device name. + * + */ + val deviceName: String, + + /** + * Device brand name. + * + */ + val deviceBrand: String, + + /** + * Device model name. + * + */ + val deviceModel: String, + + /** + * Country two-character ISO 3166-1 alpha code. + * + */ + val countryCode: String, + + /** + * Country name. + * + */ + val countryName: String +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Log( + event = map["event"] as String, + ip = map["ip"] as String, + time = map["time"] as Long, + osCode = map["osCode"] as String, + osName = map["osName"] as String, + osVersion = map["osVersion"] as String, + clientType = map["clientType"] as String, + clientCode = map["clientCode"] as String, + clientName = map["clientName"] as String, + clientVersion = map["clientVersion"] as String, + clientEngine = map["clientEngine"] as String, + clientEngineVersion = map["clientEngineVersion"] as String, + deviceName = map["deviceName"] as String, + deviceBrand = map["deviceBrand"] as String, + deviceModel = map["deviceModel"] as String, + countryCode = map["countryCode"] as String, + countryName = map["countryName"] as String + ) + } + + fun toMap(): Map = mapOf( + "event" to event 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 new file mode 100644 index 0000000..a741ae4 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/LogList.kt @@ -0,0 +1,23 @@ +package io.appwrite.models + +/** + * Logs List + */ +data class LogList( + /** + * List of logs. + * + */ + val logs: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = LogList( + logs = (map["logs"] as List>).map { Log.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "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 new file mode 100644 index 0000000..9e0266f --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Membership.kt @@ -0,0 +1,87 @@ +package io.appwrite.models + +/** + * Membership + */ +data class Membership( + /** + * Membership ID. + * + */ + val id: String, + + /** + * User ID. + * + */ + val userId: String, + + /** + * Team ID. + * + */ + val teamId: String, + + /** + * User name. + * + */ + val name: String, + + /** + * User email address. + * + */ + val email: String, + + /** + * Date, the user has been invited to join the team in Unix timestamp. + * + */ + val invited: Long, + + /** + * Date, the user has accepted the invitation to join the team in Unix timestamp. + * + */ + val joined: Long, + + /** + * User confirmation status, true if the user has joined the team or false otherwise. + * + */ + val confirm: Boolean, + + /** + * User list of roles + * + */ + val roles: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Membership( + id = map["\$id"] as String, + userId = map["userId"] as String, + teamId = map["teamId"] as String, + name = map["name"] as String, + email = map["email"] as String, + invited = map["invited"] as Long, + joined = map["joined"] as Long, + confirm = map["confirm"] as Boolean, + roles = map["roles"] as List + ) + } + + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "userId" to userId as Any, + "teamId" to teamId as Any, + "name" to name as Any, + "email" to email 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 new file mode 100644 index 0000000..3935263 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/MembershipList.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Memberships List + */ +data class MembershipList( + /** + * Total number of items available on the server. + * + */ + val sum: Long, + + /** + * List of memberships. + * + */ + val memberships: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = MembershipList( + sum = map["sum"] as Long, + memberships = (map["memberships"] as List>).map { Membership.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "sum" to sum 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/Permissions.kt b/library/src/main/java/io/appwrite/models/Permissions.kt new file mode 100644 index 0000000..81cd07d --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Permissions.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Permissions + */ +data class Permissions( + /** + * Read permissions. + * + */ + val read: List, + + /** + * Write permissions. + * + */ + val write: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Permissions( + read = map["read"] as List, + write = map["write"] as List + ) + } + + fun toMap(): Map = mapOf( + "read" to read as Any, + "write" to write 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 new file mode 100644 index 0000000..a11de9d --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Phone.kt @@ -0,0 +1,39 @@ +package io.appwrite.models + +/** + * Phone + */ +data class Phone( + /** + * Phone code. + * + */ + val code: String, + + /** + * Country two-character ISO 3166-1 alpha code. + * + */ + val countryCode: String, + + /** + * Country name. + * + */ + val countryName: String +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Phone( + code = map["code"] as String, + countryCode = map["countryCode"] 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 new file mode 100644 index 0000000..a7b92d0 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/PhoneList.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Phones List + */ +data class PhoneList( + /** + * Total number of items available on the server. + * + */ + val sum: Long, + + /** + * List of phones. + * + */ + val phones: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = PhoneList( + sum = map["sum"] as Long, + phones = (map["phones"] as List>).map { Phone.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "sum" to sum 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 new file mode 100644 index 0000000..a95850f --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Preferences.kt @@ -0,0 +1,23 @@ +package io.appwrite.models + +/** + * Preferences + */ +data class Preferences( + val data: Map +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Preferences( + data = map + ) + } + + fun toMap(): Map = mapOf( + "data" to data + ) + + fun convertTo(fromJson: (Map) -> T): T { + return fromJson(data) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/RealtimeModels.kt b/library/src/main/java/io/appwrite/models/RealtimeModels.kt index b4990c8..e2b012a 100644 --- a/library/src/main/java/io/appwrite/models/RealtimeModels.kt +++ b/library/src/main/java/io/appwrite/models/RealtimeModels.kt @@ -9,6 +9,7 @@ data class RealtimeSubscription( } data class RealtimeCallback( + val channels: Collection, val payloadClass: Class<*>, val callback: (RealtimeResponseEvent<*>) -> Unit ) diff --git a/library/src/main/java/io/appwrite/models/Session.kt b/library/src/main/java/io/appwrite/models/Session.kt new file mode 100644 index 0000000..fa8a91f --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Session.kt @@ -0,0 +1,191 @@ +package io.appwrite.models + +/** + * Session + */ +data class Session( + /** + * Session ID. + * + */ + val id: String, + + /** + * User ID. + * + */ + val userId: String, + + /** + * Session expiration date in Unix timestamp. + * + */ + val expire: Long, + + /** + * Session Provider. + * + */ + val provider: String, + + /** + * Session Provider User ID. + * + */ + val providerUid: String, + + /** + * Session Provider Token. + * + */ + val providerToken: String, + + /** + * IP in use when the session was created. + * + */ + val ip: String, + + /** + * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + * + */ + val osCode: String, + + /** + * Operating system name. + * + */ + val osName: String, + + /** + * Operating system version. + * + */ + val osVersion: String, + + /** + * Client type. + * + */ + val clientType: String, + + /** + * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + * + */ + val clientCode: String, + + /** + * Client name. + * + */ + val clientName: String, + + /** + * Client version. + * + */ + val clientVersion: String, + + /** + * Client engine name. + * + */ + val clientEngine: String, + + /** + * Client engine name. + * + */ + val clientEngineVersion: String, + + /** + * Device name. + * + */ + val deviceName: String, + + /** + * Device brand name. + * + */ + val deviceBrand: String, + + /** + * Device model name. + * + */ + val deviceModel: String, + + /** + * Country two-character ISO 3166-1 alpha code. + * + */ + val countryCode: String, + + /** + * Country name. + * + */ + val countryName: String, + + /** + * Returns true if this the current user session. + * + */ + val current: Boolean +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Session( + id = map["\$id"] as String, + userId = map["userId"] as String, + expire = map["expire"] as Long, + provider = map["provider"] as String, + providerUid = map["providerUid"] as String, + providerToken = map["providerToken"] as String, + ip = map["ip"] as String, + osCode = map["osCode"] as String, + osName = map["osName"] as String, + osVersion = map["osVersion"] as String, + clientType = map["clientType"] as String, + clientCode = map["clientCode"] as String, + clientName = map["clientName"] as String, + clientVersion = map["clientVersion"] as String, + clientEngine = map["clientEngine"] as String, + clientEngineVersion = map["clientEngineVersion"] as String, + deviceName = map["deviceName"] as String, + deviceBrand = map["deviceBrand"] as String, + deviceModel = map["deviceModel"] as String, + countryCode = map["countryCode"] as String, + countryName = map["countryName"] as String, + current = map["current"] as Boolean + ) + } + + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "userId" to userId as Any, + "expire" to expire as Any, + "provider" to provider as Any, + "providerUid" to providerUid as Any, + "providerToken" to providerToken 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 new file mode 100644 index 0000000..655701d --- /dev/null +++ b/library/src/main/java/io/appwrite/models/SessionList.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Sessions List + */ +data class SessionList( + /** + * Total number of items available on the server. + * + */ + val sum: Long, + + /** + * List of sessions. + * + */ + val sessions: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = SessionList( + sum = map["sum"] as Long, + sessions = (map["sessions"] as List>).map { Session.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "sum" to sum 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 new file mode 100644 index 0000000..414886a --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Team.kt @@ -0,0 +1,47 @@ +package io.appwrite.models + +/** + * Team + */ +data class Team( + /** + * Team ID. + * + */ + val id: String, + + /** + * Team name. + * + */ + val name: String, + + /** + * Team creation date in Unix timestamp. + * + */ + val dateCreated: Long, + + /** + * Total sum of team members. + * + */ + val sum: Long +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Team( + id = map["\$id"] as String, + name = map["name"] as String, + dateCreated = map["dateCreated"] as Long, + sum = map["sum"] as Long + ) + } + + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "name" to name as Any, + "dateCreated" to dateCreated as Any, + "sum" to sum 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 new file mode 100644 index 0000000..3adca8d --- /dev/null +++ b/library/src/main/java/io/appwrite/models/TeamList.kt @@ -0,0 +1,31 @@ +package io.appwrite.models + +/** + * Teams List + */ +data class TeamList( + /** + * Total number of items available on the server. + * + */ + val sum: Long, + + /** + * List of teams. + * + */ + val teams: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = TeamList( + sum = map["sum"] as Long, + teams = (map["teams"] as List>).map { Team.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "sum" to sum 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 new file mode 100644 index 0000000..5041d1a --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Token.kt @@ -0,0 +1,47 @@ +package io.appwrite.models + +/** + * Token + */ +data class Token( + /** + * Token ID. + * + */ + val id: String, + + /** + * User ID. + * + */ + 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. + * + */ + val secret: String, + + /** + * Token expiration date in Unix timestamp. + * + */ + val expire: Long +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Token( + id = map["\$id"] as String, + userId = map["userId"] as String, + secret = map["secret"] as String, + expire = map["expire"] as Long + ) + } + + fun toMap(): Map = mapOf( + "\$id" to id 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/models/User.kt b/library/src/main/java/io/appwrite/models/User.kt new file mode 100644 index 0000000..82039e4 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/User.kt @@ -0,0 +1,79 @@ +package io.appwrite.models + +/** + * User + */ +data class User( + /** + * User ID. + * + */ + val id: String, + + /** + * User name. + * + */ + val name: String, + + /** + * User registration date in Unix timestamp. + * + */ + val registration: Long, + + /** + * User status. 0 for Unactivated, 1 for active and 2 is blocked. + * + */ + val status: Long, + + /** + * Unix timestamp of the most recent password update + * + */ + val passwordUpdate: Long, + + /** + * User email address. + * + */ + val email: String, + + /** + * Email verification status. + * + */ + val emailVerification: Boolean, + + /** + * User preferences as a key-value object + * + */ + val prefs: Preferences +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = User( + id = map["\$id"] as String, + name = map["name"] as String, + registration = map["registration"] as Long, + status = map["status"] as Long, + passwordUpdate = map["passwordUpdate"] as Long, + email = map["email"] as String, + emailVerification = map["emailVerification"] as Boolean, + prefs = Preferences.from(map = map["prefs"] as Map) + ) + } + + fun toMap(): Map = mapOf( + "\$id" to id 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, + "emailVerification" to emailVerification as Any, + "prefs" to prefs.toMap() 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 89206d3..063d602 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -2,6 +2,7 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client +import io.appwrite.models.* import io.appwrite.WebAuthComponent import androidx.activity.ComponentActivity import io.appwrite.exceptions.AppwriteException @@ -18,20 +19,28 @@ class Account(client: Client) : Service(client) { * * Get currently logged in user data as JSON object. * - * @return [Response] + * @return [io.appwrite.models.User] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun get(): Response { + suspend fun get(): io.appwrite.models.User { val path = "/account" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.User::class.java, + convert = convert + ) } /** @@ -44,10 +53,10 @@ class Account(client: Client) : Service(client) { * login to their new account, you need to create a new [account * session](/docs/client/account#accountCreateSession). * - * @param email - * @param password - * @param name - * @return [Response] + * @param email User email. + * @param password User password. Must be between 6 to 32 chars. + * @param name User name. Max length: 128 chars. + * @return [io.appwrite.models.User] */ @JvmOverloads @Throws(AppwriteException::class) @@ -55,19 +64,27 @@ class Account(client: Client) : Service(client) { email: String, password: String, name: String? = null - ): Response { + ): io.appwrite.models.User { val path = "/account" val params = mapOf( "email" to email, "password" to password, "name" to name ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("POST", path, headers, params) + val convert: (Map) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.User::class.java, + convert = convert + ) } /** @@ -79,20 +96,24 @@ class Account(client: Client) : Service(client) { * address. Any user-related resources like documents or storage files should * be deleted separately. * - * @return [Response] + * @return [Any] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun delete(): Response { + suspend fun delete(): Any { val path = "/account" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("DELETE", path, headers, params) + return client.call( + "DELETE", + path, + headers, + params, + responseType = Any::class.java, + ) } /** @@ -105,27 +126,35 @@ class Account(client: Client) : Service(client) { * 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 - * @param password - * @return [Response] + * @param email User email. + * @param password User password. Must be between 6 to 32 chars. + * @return [io.appwrite.models.User] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun updateEmail( email: String, password: String - ): Response { + ): io.appwrite.models.User { val path = "/account/email" val params = mapOf( "email" to email, "password" to password ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("PATCH", path, headers, params) + val convert: (Map) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.User::class.java, + convert = convert + ) } /** @@ -137,20 +166,28 @@ class Account(client: Client) : Service(client) { * from its creation and will be invalid if the user will logout in that time * frame. * - * @return [Response] + * @return [io.appwrite.models.Jwt] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun createJWT(): Response { + suspend fun createJWT(): io.appwrite.models.Jwt { val path = "/account/jwt" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("POST", path, headers, params) + val convert: (Map) -> io.appwrite.models.Jwt = { + io.appwrite.models.Jwt.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Jwt::class.java, + convert = convert + ) } /** @@ -159,20 +196,28 @@ class Account(client: Client) : Service(client) { * Get currently logged in user list of latest security activity logs. Each * log returns user IP address, location and date and time of log. * - * @return [Response] + * @return [io.appwrite.models.LogList] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getLogs(): Response { + suspend fun getLogs(): io.appwrite.models.LogList { val path = "/account/logs" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.LogList = { + io.appwrite.models.LogList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.LogList::class.java, + convert = convert + ) } /** @@ -180,24 +225,32 @@ class Account(client: Client) : Service(client) { * * Update currently logged in user account name. * - * @param name - * @return [Response] + * @param name User name. Max length: 128 chars. + * @return [io.appwrite.models.User] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun updateName( name: String - ): Response { + ): io.appwrite.models.User { val path = "/account/name" val params = mapOf( "name" to name ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("PATCH", path, headers, params) + val convert: (Map) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.User::class.java, + convert = convert + ) } /** @@ -207,27 +260,35 @@ class Account(client: Client) : Service(client) { * to pass in the new password, and the old password. For users created with * OAuth and Team Invites, oldPassword is optional. * - * @param password - * @param oldPassword - * @return [Response] + * @param password New user password. Must be between 6 to 32 chars. + * @param oldPassword Old user password. Must be between 6 to 32 chars. + * @return [io.appwrite.models.User] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun updatePassword( password: String, oldPassword: String? = null - ): Response { + ): io.appwrite.models.User { val path = "/account/password" val params = mapOf( "password" to password, "oldPassword" to oldPassword ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("PATCH", path, headers, params) + val convert: (Map) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.User::class.java, + convert = convert + ) } /** @@ -235,20 +296,28 @@ class Account(client: Client) : Service(client) { * * Get currently logged in user preferences as a key-value object. * - * @return [Response] + * @return [io.appwrite.models.Preferences] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getPrefs(): Response { + suspend fun getPrefs(): io.appwrite.models.Preferences { val path = "/account/prefs" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.Preferences = { + io.appwrite.models.Preferences.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.Preferences::class.java, + convert = convert + ) } /** @@ -257,24 +326,32 @@ class Account(client: Client) : Service(client) { * Update currently logged in user account preferences. You can pass only the * specific settings you wish to update. * - * @param prefs - * @return [Response] + * @param prefs Prefs key-value JSON object. + * @return [io.appwrite.models.User] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun updatePrefs( prefs: Any - ): Response { + ): io.appwrite.models.User { val path = "/account/prefs" val params = mapOf( "prefs" to prefs ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("PATCH", path, headers, params) + val convert: (Map) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.User::class.java, + convert = convert + ) } /** @@ -289,27 +366,35 @@ class Account(client: Client) : Service(client) { * complete the process. The verification link sent to the user's email * address is valid for 1 hour. * - * @param email - * @param url - * @return [Response] + * @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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun createRecovery( email: String, url: String - ): Response { + ): io.appwrite.models.Token { val path = "/account/recovery" val params = mapOf( "email" to email, "url" to url ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("POST", path, headers, params) + val convert: (Map) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Token::class.java, + convert = convert + ) } /** @@ -325,11 +410,11 @@ class Account(client: Client) : Service(client) { * the only valid redirect URLs are the ones from domains you have set when * adding your platforms in the console interface. * - * @param userId - * @param secret - * @param password - * @param passwordAgain - * @return [Response] + * @param userId User account UID address. + * @param secret Valid reset token. + * @param password New password. Must be between 6 to 32 chars. + * @param passwordAgain New password again. Must be between 6 to 32 chars. + * @return [io.appwrite.models.Token] */ @JvmOverloads @Throws(AppwriteException::class) @@ -338,7 +423,7 @@ class Account(client: Client) : Service(client) { secret: String, password: String, passwordAgain: String - ): Response { + ): io.appwrite.models.Token { val path = "/account/recovery" val params = mapOf( "userId" to userId, @@ -346,12 +431,20 @@ class Account(client: Client) : Service(client) { "password" to password, "passwordAgain" to passwordAgain ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("PUT", path, headers, params) + val convert: (Map) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it) + } + return client.call( + "PUT", + path, + headers, + params, + responseType = io.appwrite.models.Token::class.java, + convert = convert + ) } /** @@ -360,20 +453,28 @@ class Account(client: Client) : Service(client) { * Get currently logged in user list of active sessions across different * devices. * - * @return [Response] + * @return [io.appwrite.models.SessionList] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getSessions(): Response { + suspend fun getSessions(): io.appwrite.models.SessionList { val path = "/account/sessions" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.SessionList = { + io.appwrite.models.SessionList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.SessionList::class.java, + convert = convert + ) } /** @@ -382,27 +483,35 @@ class Account(client: Client) : Service(client) { * 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. * - * @param email - * @param password - * @return [Response] + * @param email User email. + * @param password User password. Must be between 6 to 32 chars. + * @return [io.appwrite.models.Session] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun createSession( email: String, password: String - ): Response { + ): io.appwrite.models.Session { val path = "/account/sessions" val params = mapOf( "email" to email, "password" to password ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("POST", path, headers, params) + val convert: (Map) -> io.appwrite.models.Session = { + io.appwrite.models.Session.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Session::class.java, + convert = convert + ) } /** @@ -411,20 +520,24 @@ class Account(client: Client) : Service(client) { * Delete all sessions from the user account and remove any sessions cookies * from the end client. * - * @return [Response] + * @return [Any] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun deleteSessions(): Response { + suspend fun deleteSessions(): Any { val path = "/account/sessions" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("DELETE", path, headers, params) + return client.call( + "DELETE", + path, + headers, + params, + responseType = Any::class.java, + ) } /** @@ -437,20 +550,28 @@ class Account(client: Client) : Service(client) { * password](/docs/client/account#accountUpdateEmail) or create an [OAuth2 * session](/docs/client/account#accountCreateOAuth2Session). * - * @return [Response] + * @return [io.appwrite.models.Session] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun createAnonymousSession(): Response { + suspend fun createAnonymousSession(): io.appwrite.models.Session { val path = "/account/sessions/anonymous" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("POST", path, headers, params) + val convert: (Map) -> io.appwrite.models.Session = { + io.appwrite.models.Session.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Session::class.java, + convert = convert + ) } /** @@ -467,27 +588,35 @@ class Account(client: Client) : Service(client) { * the URL parameter empty, so that the login completion will be handled by * your Appwrite instance by default. * - * @param email - * @param url - * @return [Response] + * @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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun createMagicURLSession( email: String, url: String? = null - ): Response { + ): io.appwrite.models.Token { val path = "/account/sessions/magic-url" val params = mapOf( "email" to email, "url" to url ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("POST", path, headers, params) + val convert: (Map) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Token::class.java, + convert = convert + ) } /** @@ -505,27 +634,35 @@ class Account(client: Client) : Service(client) { * the only valid redirect URLs are the ones from domains you have set when * adding your platforms in the console interface. * - * @param userId - * @param secret - * @return [Response] + * @param userId User unique ID. + * @param secret Valid verification token. + * @return [io.appwrite.models.Session] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun updateMagicURLSession( userId: String, secret: String - ): Response { + ): io.appwrite.models.Session { val path = "/account/sessions/magic-url" val params = mapOf( "userId" to userId, "secret" to secret ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("PUT", path, headers, params) + val convert: (Map) -> io.appwrite.models.Session = { + io.appwrite.models.Session.from(map = it) + } + return client.call( + "PUT", + path, + headers, + params, + responseType = io.appwrite.models.Session::class.java, + convert = convert + ) } /** @@ -544,10 +681,10 @@ class Account(client: Client) : Service(client) { * user.. * * - * @param provider - * @param success - * @param failure - * @param scopes + * @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, bitbucket, bitly, box, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, paypal, paypalSandbox, salesforce, slack, spotify, tradeshift, tradeshiftBox, twitch, vk, yahoo, yandex, wordpress. + * @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. * */ @JvmOverloads @@ -566,7 +703,6 @@ class Account(client: Client) : Service(client) { "scopes" to scopes, "project" to client.config["project"] ) - val query = mutableListOf() params.forEach { when (it.value) { @@ -609,7 +745,6 @@ class Account(client: Client) : Service(client) { listOf(cookie) ) } - } /** @@ -618,23 +753,31 @@ class Account(client: Client) : Service(client) { * 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 - * @return [Response] + * @param sessionId Session unique ID. Use the string 'current' to get the current device session. + * @return [io.appwrite.models.Session] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getSession( sessionId: String - ): Response { + ): io.appwrite.models.Session { val path = "/account/sessions/{sessionId}".replace("{sessionId}", sessionId) val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.Session = { + io.appwrite.models.Session.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.Session::class.java, + convert = convert + ) } /** @@ -644,23 +787,27 @@ class Account(client: Client) : Service(client) { * account sessions across all of their different devices. When using the * option id argument, only the session unique ID provider will be deleted. * - * @param sessionId - * @return [Response] + * @param sessionId Session unique ID. Use the string 'current' to delete the current device session. + * @return [Any] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun deleteSession( sessionId: String - ): Response { + ): Any { val path = "/account/sessions/{sessionId}".replace("{sessionId}", sessionId) val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("DELETE", path, headers, params) + return client.call( + "DELETE", + path, + headers, + params, + responseType = Any::class.java, + ) } /** @@ -682,24 +829,32 @@ class Account(client: Client) : Service(client) { * adding your platforms in the console interface. * * - * @param url - * @return [Response] + * @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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun createVerification( url: String - ): Response { + ): io.appwrite.models.Token { val path = "/account/verification" val params = mapOf( "url" to url ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("POST", path, headers, params) + val convert: (Map) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Token::class.java, + convert = convert + ) } /** @@ -710,27 +865,35 @@ class Account(client: Client) : Service(client) { * to verify the user email ownership. If confirmed this route will return a * 200 status code. * - * @param userId - * @param secret - * @return [Response] + * @param userId User unique ID. + * @param secret Valid verification token. + * @return [io.appwrite.models.Token] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun updateVerification( userId: String, secret: String - ): Response { + ): io.appwrite.models.Token { val path = "/account/verification" val params = mapOf( "userId" to userId, "secret" to secret ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("PUT", path, headers, params) + val convert: (Map) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it) + } + return client.call( + "PUT", + path, + headers, + params, + responseType = io.appwrite.models.Token::class.java, + convert = convert + ) } } \ 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 3e0432f..912b1e5 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -2,6 +2,7 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client +import io.appwrite.models.* import io.appwrite.exceptions.AppwriteException import okhttp3.Cookie import okhttp3.Response @@ -19,20 +20,20 @@ class Avatars(client: Client) : Service(client) { * /account/sessions endpoint. Use width, height and quality arguments to * change the output settings. * - * @param code - * @param width - * @param height - * @param quality - * @return [Response] + * @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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getBrowser( code: String, - width: Int? = null, - height: Int? = null, - quality: Int? = null - ): Response { + width: Long? = null, + height: Long? = null, + quality: Long? = null + ): ByteArray { val path = "/avatars/browsers/{code}".replace("{code}", code) val params = mapOf( "width" to width, @@ -40,8 +41,12 @@ class Avatars(client: Client) : Service(client) { "quality" to quality, "project" to client.config["project"] ) - - return client.call("GET", path, params = params) + return client.call( + "GET", + path, + params = params, + responseType = ByteArray::class.java + ) } /** @@ -51,20 +56,20 @@ class Avatars(client: Client) : Service(client) { * provider you need. Use width, height and quality arguments to change the * output settings. * - * @param code - * @param width - * @param height - * @param quality - * @return [Response] + * @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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getCreditCard( code: String, - width: Int? = null, - height: Int? = null, - quality: Int? = null - ): Response { + width: Long? = null, + height: Long? = null, + quality: Long? = null + ): ByteArray { val path = "/avatars/credit-cards/{code}".replace("{code}", code) val params = mapOf( "width" to width, @@ -72,8 +77,12 @@ class Avatars(client: Client) : Service(client) { "quality" to quality, "project" to client.config["project"] ) - - return client.call("GET", path, params = params) + return client.call( + "GET", + path, + params = params, + responseType = ByteArray::class.java + ) } /** @@ -83,21 +92,25 @@ class Avatars(client: Client) : Service(client) { * website URL. * * - * @param url - * @return [Response] + * @param url Website URL which you want to fetch the favicon from. + * @return [ByteArray] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getFavicon( url: String - ): Response { + ): ByteArray { val path = "/avatars/favicon" val params = mapOf( "url" to url, "project" to client.config["project"] ) - - return client.call("GET", path, params = params) + return client.call( + "GET", + path, + params = params, + responseType = ByteArray::class.java + ) } /** @@ -107,20 +120,20 @@ class Avatars(client: Client) : Service(client) { * users. The code argument receives the 2 letter country code. Use width, * height and quality arguments to change the output settings. * - * @param code - * @param width - * @param height - * @param quality - * @return [Response] + * @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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getFlag( code: String, - width: Int? = null, - height: Int? = null, - quality: Int? = null - ): Response { + width: Long? = null, + height: Long? = null, + quality: Long? = null + ): ByteArray { val path = "/avatars/flags/{code}".replace("{code}", code) val params = mapOf( "width" to width, @@ -128,8 +141,12 @@ class Avatars(client: Client) : Service(client) { "quality" to quality, "project" to client.config["project"] ) - - return client.call("GET", path, params = params) + return client.call( + "GET", + path, + params = params, + responseType = ByteArray::class.java + ) } /** @@ -140,18 +157,18 @@ class Avatars(client: Client) : Service(client) { * remote images in your app or in case you want to make sure a 3rd party * image is properly served using a TLS protocol. * - * @param url - * @param width - * @param height - * @return [Response] + * @param url Image URL which you want to crop. + * @param width Resize preview image width, Pass an integer between 0 to 2000. + * @param height Resize preview image height, Pass an integer between 0 to 2000. + * @return [ByteArray] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getImage( url: String, - width: Int? = null, - height: Int? = null - ): Response { + width: Long? = null, + height: Long? = null + ): ByteArray { val path = "/avatars/image" val params = mapOf( "url" to url, @@ -159,8 +176,12 @@ class Avatars(client: Client) : Service(client) { "height" to height, "project" to client.config["project"] ) - - return client.call("GET", path, params = params) + return client.call( + "GET", + path, + params = params, + responseType = ByteArray::class.java + ) } /** @@ -177,22 +198,22 @@ class Avatars(client: Client) : Service(client) { * the user's initials when reloading the same theme will always return for * the same initials. * - * @param name - * @param width - * @param height - * @param color - * @param background - * @return [Response] + * @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 color Changes text color. By default a random color will be picked and stay will persistent to the given name. + * @param background Changes background color. By default a random color will be picked and stay will persistent to the given name. + * @return [ByteArray] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getInitials( name: String? = null, - width: Int? = null, - height: Int? = null, + width: Long? = null, + height: Long? = null, color: String? = null, background: String? = null - ): Response { + ): ByteArray { val path = "/avatars/initials" val params = mapOf( "name" to name, @@ -202,8 +223,12 @@ class Avatars(client: Client) : Service(client) { "background" to background, "project" to client.config["project"] ) - - return client.call("GET", path, params = params) + return client.call( + "GET", + path, + params = params, + responseType = ByteArray::class.java + ) } /** @@ -212,20 +237,20 @@ class Avatars(client: Client) : Service(client) { * 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 - * @param size - * @param margin - * @param download - * @return [Response] + * @param text Plain text to be converted to QR code image. + * @param size QR code size. Pass an integer between 0 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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getQR( text: String, - size: Int? = null, - margin: Int? = null, + size: Long? = null, + margin: Long? = null, download: Boolean? = null - ): Response { + ): ByteArray { val path = "/avatars/qr" val params = mapOf( "text" to text, @@ -234,8 +259,12 @@ class Avatars(client: Client) : Service(client) { "download" to download, "project" to client.config["project"] ) - - return client.call("GET", path, params = params) + return client.call( + "GET", + path, + params = params, + responseType = ByteArray::class.java + ) } } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Database.kt b/library/src/main/java/io/appwrite/services/Database.kt index 6333532..6baecdc 100644 --- a/library/src/main/java/io/appwrite/services/Database.kt +++ b/library/src/main/java/io/appwrite/services/Database.kt @@ -2,6 +2,7 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client +import io.appwrite.models.* import io.appwrite.exceptions.AppwriteException import okhttp3.Cookie import okhttp3.Response @@ -17,28 +18,28 @@ class Database(client: Client) : Service(client) { * of the project's documents. [Learn more about different API * modes](/docs/admin). * - * @param collectionId - * @param filters - * @param limit - * @param offset - * @param orderField - * @param orderType - * @param orderCast - * @param search - * @return [Response] + * @param collectionId Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection). + * @param filters Array of filter strings. Each filter is constructed from a key name, comparison operator (=, !=, >, <, <=, >=) and a value. You can also use a dot (.) separator in attribute names to filter by child document attributes. Examples: 'name=John Doe' or 'category.$id>=5bed2d152c362'. + * @param limit Maximum number of documents to return in response. Use this value to manage pagination. By default will return maximum 25 results. Maximum of 100 results allowed per request. + * @param offset Offset value. The default value is 0. Use this param to manage pagination. + * @param orderField Document field that results will be sorted by. + * @param orderType Order direction. Possible values are DESC for descending order, or ASC for ascending order. + * @param orderCast Order field type casting. Possible values are int, string, date, time or datetime. The database will attempt to cast the order field to the value you pass here. The default value is a string. + * @param search Search query. Enter any free text search. The database will try to find a match against all document attributes and children. Max length: 256 chars. + * @return [io.appwrite.models.DocumentList] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun listDocuments( collectionId: String, filters: List? = null, - limit: Int? = null, - offset: Int? = null, + limit: Long? = null, + offset: Long? = null, orderField: String? = null, orderType: String? = null, orderCast: String? = null, search: String? = null - ): Response { + ): io.appwrite.models.DocumentList { val path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId) val params = mapOf( "filters" to filters, @@ -49,12 +50,20 @@ class Database(client: Client) : Service(client) { "orderCast" to orderCast, "search" to search ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.DocumentList = { + io.appwrite.models.DocumentList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.DocumentList::class.java, + convert = convert + ) } /** @@ -65,14 +74,14 @@ class Database(client: Client) : Service(client) { * integration](/docs/server/database#databaseCreateCollection) API or * directly from your database console. * - * @param collectionId - * @param data - * @param read - * @param write - * @param parentDocument - * @param parentProperty - * @param parentPropertyType - * @return [Response] + * @param collectionId Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection). + * @param data Document data as JSON object. + * @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. + * @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. + * @param parentDocument Parent document unique ID. Use when you want your new document to be a child of a parent document. + * @param parentProperty Parent document property name. Use when you want your new document to be a child of a parent document. + * @param parentPropertyType Parent document property connection type. You can set this value to **assign**, **append** or **prepend**, default value is assign. Use when you want your new document to be a child of a parent document. + * @return [io.appwrite.models.Document] */ @JvmOverloads @Throws(AppwriteException::class) @@ -84,7 +93,7 @@ class Database(client: Client) : Service(client) { parentDocument: String? = null, parentProperty: String? = null, parentPropertyType: String? = null - ): Response { + ): io.appwrite.models.Document { val path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId) val params = mapOf( "data" to data, @@ -94,12 +103,20 @@ class Database(client: Client) : Service(client) { "parentProperty" to parentProperty, "parentPropertyType" to parentPropertyType ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("POST", path, headers, params) + val convert: (Map) -> io.appwrite.models.Document = { + io.appwrite.models.Document.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Document::class.java, + convert = convert + ) } /** @@ -108,25 +125,33 @@ class Database(client: Client) : Service(client) { * Get a document by its unique ID. This endpoint response returns a JSON * object with the document data. * - * @param collectionId - * @param documentId - * @return [Response] + * @param collectionId Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection). + * @param documentId Document unique ID. + * @return [io.appwrite.models.Document] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getDocument( collectionId: String, documentId: String - ): Response { + ): io.appwrite.models.Document { val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId) val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.Document = { + io.appwrite.models.Document.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.Document::class.java, + convert = convert + ) } /** @@ -135,12 +160,12 @@ class Database(client: Client) : Service(client) { * Update a document by its unique ID. Using the patch method you can pass * only specific fields that will get updated. * - * @param collectionId - * @param documentId - * @param data - * @param read - * @param write - * @return [Response] + * @param collectionId Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection). + * @param documentId Document unique ID. + * @param data Document data as JSON object. + * @param read An array of strings with read permissions. By default inherits the existing read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. + * @param write An array of strings with write permissions. By default inherits the existing write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. + * @return [io.appwrite.models.Document] */ @JvmOverloads @Throws(AppwriteException::class) @@ -150,19 +175,27 @@ class Database(client: Client) : Service(client) { data: Any, read: List? = null, write: List? = null - ): Response { + ): io.appwrite.models.Document { val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId) val params = mapOf( "data" to data, "read" to read, "write" to write ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("PATCH", path, headers, params) + val convert: (Map) -> io.appwrite.models.Document = { + io.appwrite.models.Document.from(map = it) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.Document::class.java, + convert = convert + ) } /** @@ -172,25 +205,29 @@ class Database(client: Client) : Service(client) { * documents, its attributes and relations to other documents. Child documents * **will not** be deleted. * - * @param collectionId - * @param documentId - * @return [Response] + * @param collectionId Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection). + * @param documentId Document unique ID. + * @return [Any] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun deleteDocument( collectionId: String, documentId: String - ): Response { + ): Any { val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId) val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("DELETE", path, headers, params) + return client.call( + "DELETE", + path, + headers, + params, + 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 95a915f..83ac165 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -2,6 +2,7 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client +import io.appwrite.models.* import io.appwrite.exceptions.AppwriteException import okhttp3.Cookie import okhttp3.Response @@ -17,22 +18,22 @@ class Functions(client: Client) : Service(client) { * return a list of all of the project's executions. [Learn more about * different API modes](/docs/admin). * - * @param functionId - * @param search - * @param limit - * @param offset - * @param orderType - * @return [Response] + * @param functionId Function unique ID. + * @param search Search term to filter your list results. Max length: 256 chars. + * @param limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. + * @param offset Results offset. The default value is 0. Use this param to manage pagination. + * @param orderType Order result by ASC or DESC order. + * @return [io.appwrite.models.ExecutionList] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun listExecutions( functionId: String, search: String? = null, - limit: Int? = null, - offset: Int? = null, + limit: Long? = null, + offset: Long? = null, orderType: String? = null - ): Response { + ): io.appwrite.models.ExecutionList { val path = "/functions/{functionId}/executions".replace("{functionId}", functionId) val params = mapOf( "search" to search, @@ -40,12 +41,20 @@ class Functions(client: Client) : Service(client) { "offset" to offset, "orderType" to orderType ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.ExecutionList = { + io.appwrite.models.ExecutionList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.ExecutionList::class.java, + convert = convert + ) } /** @@ -56,26 +65,34 @@ class Functions(client: Client) : Service(client) { * updates on the current execution status. Once this endpoint is called, your * function execution process will start asynchronously. * - * @param functionId - * @param data - * @return [Response] + * @param functionId Function unique ID. + * @param data String of custom data to send to function. + * @return [io.appwrite.models.Execution] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun createExecution( functionId: String, data: String? = null - ): Response { + ): io.appwrite.models.Execution { val path = "/functions/{functionId}/executions".replace("{functionId}", functionId) val params = mapOf( "data" to data ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("POST", path, headers, params) + val convert: (Map) -> io.appwrite.models.Execution = { + io.appwrite.models.Execution.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Execution::class.java, + convert = convert + ) } /** @@ -83,25 +100,33 @@ class Functions(client: Client) : Service(client) { * * Get a function execution log by its unique ID. * - * @param functionId - * @param executionId - * @return [Response] + * @param functionId Function unique ID. + * @param executionId Execution unique ID. + * @return [io.appwrite.models.Execution] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getExecution( functionId: String, executionId: String - ): Response { + ): io.appwrite.models.Execution { val path = "/functions/{functionId}/executions/{executionId}".replace("{functionId}", functionId).replace("{executionId}", executionId) val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.Execution = { + io.appwrite.models.Execution.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.Execution::class.java, + convert = convert + ) } } \ 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 415df78..423a323 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -2,6 +2,7 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client +import io.appwrite.models.* import io.appwrite.exceptions.AppwriteException import okhttp3.Cookie import okhttp3.Response @@ -19,20 +20,28 @@ class Locale(client: Client) : Service(client) { * * ([IP Geolocation by DB-IP](https://db-ip.com)) * - * @return [Response] + * @return [io.appwrite.models.Locale] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun get(): Response { + suspend fun get(): io.appwrite.models.Locale { val path = "/locale" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.Locale = { + io.appwrite.models.Locale.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.Locale::class.java, + convert = convert + ) } /** @@ -41,20 +50,28 @@ class Locale(client: Client) : Service(client) { * List of all continents. You can use the locale header to get the data in a * supported language. * - * @return [Response] + * @return [io.appwrite.models.ContinentList] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getContinents(): Response { + suspend fun getContinents(): io.appwrite.models.ContinentList { val path = "/locale/continents" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.ContinentList = { + io.appwrite.models.ContinentList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.ContinentList::class.java, + convert = convert + ) } /** @@ -63,20 +80,28 @@ class Locale(client: Client) : Service(client) { * List of all countries. You can use the locale header to get the data in a * supported language. * - * @return [Response] + * @return [io.appwrite.models.CountryList] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getCountries(): Response { + suspend fun getCountries(): io.appwrite.models.CountryList { val path = "/locale/countries" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.CountryList = { + io.appwrite.models.CountryList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.CountryList::class.java, + convert = convert + ) } /** @@ -85,20 +110,28 @@ class Locale(client: Client) : Service(client) { * 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 [Response] + * @return [io.appwrite.models.CountryList] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getCountriesEU(): Response { + suspend fun getCountriesEU(): io.appwrite.models.CountryList { val path = "/locale/countries/eu" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.CountryList = { + io.appwrite.models.CountryList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.CountryList::class.java, + convert = convert + ) } /** @@ -107,20 +140,28 @@ class Locale(client: Client) : Service(client) { * List of all countries phone codes. You can use the locale header to get the * data in a supported language. * - * @return [Response] + * @return [io.appwrite.models.PhoneList] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getCountriesPhones(): Response { + suspend fun getCountriesPhones(): io.appwrite.models.PhoneList { val path = "/locale/countries/phones" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.PhoneList = { + io.appwrite.models.PhoneList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.PhoneList::class.java, + convert = convert + ) } /** @@ -130,20 +171,28 @@ class Locale(client: Client) : Service(client) { * decimal digits for all major and minor currencies. You can use the locale * header to get the data in a supported language. * - * @return [Response] + * @return [io.appwrite.models.CurrencyList] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getCurrencies(): Response { + suspend fun getCurrencies(): io.appwrite.models.CurrencyList { val path = "/locale/currencies" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.CurrencyList = { + io.appwrite.models.CurrencyList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.CurrencyList::class.java, + convert = convert + ) } /** @@ -152,20 +201,28 @@ class Locale(client: Client) : Service(client) { * List of all languages classified by ISO 639-1 including 2-letter code, name * in English, and name in the respective language. * - * @return [Response] + * @return [io.appwrite.models.LanguageList] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getLanguages(): Response { + suspend fun getLanguages(): io.appwrite.models.LanguageList { val path = "/locale/languages" val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.LanguageList = { + io.appwrite.models.LanguageList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.LanguageList::class.java, + convert = convert + ) } } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Realtime.kt b/library/src/main/java/io/appwrite/services/Realtime.kt index cec1dad..316054a 100644 --- a/library/src/main/java/io/appwrite/services/Realtime.kt +++ b/library/src/main/java/io/appwrite/services/Realtime.kt @@ -15,6 +15,7 @@ import okhttp3.WebSocketListener import okhttp3.internal.concurrent.TaskRunner import okhttp3.internal.ws.RealWebSocket import java.util.* +import android.util.Log import kotlin.coroutines.CoroutineContext class Realtime(client: Client) : Service(client), CoroutineScope { @@ -31,17 +32,24 @@ class Realtime(client: Client) : Service(client), CoroutineScope { private const val DEBOUNCE_MILLIS = 1L private var socket: RealWebSocket? = null - private var channelCallbacks = mutableMapOf>() - private var errorCallbacks = mutableSetOf<(AppwriteException) -> Unit>() + private var activeChannels = mutableSetOf() + private var activeSubscriptions = mutableMapOf() private var subCallDepth = 0 + private var reconnectAttempts = 0 + private var subscriptionsCounter = 0 + private var reconnect = true } private fun createSocket() { + if (activeChannels.isEmpty()) { + return + } + val queryParamBuilder = StringBuilder() .append("project=${client.config["project"]}") - channelCallbacks.keys.forEach { + activeChannels.forEach { queryParamBuilder .append("&channels[]=$it") } @@ -51,6 +59,7 @@ class Realtime(client: Client) : Service(client), CoroutineScope { .build() if (socket != null) { + reconnect = false closeSocket() } @@ -71,6 +80,13 @@ class Realtime(client: Client) : Service(client), CoroutineScope { socket?.close(RealtimeCode.POLICY_VIOLATION.value, null) } + private fun getTimeout() = when { + reconnectAttempts < 5 -> 1000L + reconnectAttempts < 15 -> 5000L + reconnectAttempts < 100 -> 10000L + else -> 60000L + } + fun subscribe( vararg channels: String, callback: (RealtimeResponseEvent) -> Unit, @@ -85,20 +101,14 @@ class Realtime(client: Client) : Service(client), CoroutineScope { payloadType: Class, callback: (RealtimeResponseEvent) -> Unit, ): RealtimeSubscription { - channels.forEach { - if (!channelCallbacks.containsKey(it)) { - channelCallbacks[it] = mutableListOf( - RealtimeCallback( - payloadType, - callback as (RealtimeResponseEvent<*>) -> Unit - ) - ) - return@forEach - } - channelCallbacks[it]?.add( - RealtimeCallback(payloadType, callback as (RealtimeResponseEvent<*>) -> Unit) - ) - } + val counter = subscriptionsCounter++ + + activeChannels.addAll(channels) + activeSubscriptions[counter] = RealtimeCallback( + channels.toList(), + payloadType, + callback as (RealtimeResponseEvent<*>) -> Unit + ) launch { subCallDepth++ @@ -109,25 +119,31 @@ class Realtime(client: Client) : Service(client), CoroutineScope { subCallDepth-- } - return RealtimeSubscription { unsubscribe(*channels) } - } - - fun unsubscribe(vararg channels: String) { - channels.forEach { - channelCallbacks[it] = mutableListOf() - } - if (channelCallbacks.all { it.value.isEmpty() }) { - errorCallbacks = mutableSetOf() - closeSocket() + return RealtimeSubscription { + activeSubscriptions.remove(counter) + cleanUp(*channels) + createSocket() } } - fun doOnError(callback: (AppwriteException) -> Unit) { - errorCallbacks.add(callback) + private fun cleanUp(vararg channels: String) { + activeChannels.removeAll { channel -> + if (!channels.contains(channel)) { + return@removeAll false + } + activeSubscriptions.values.none { callback -> + callback.channels.contains(channel) + } + } } private inner class AppwriteWebSocketListener : WebSocketListener() { + override fun onOpen(webSocket: WebSocket, response: Response) { + super.onOpen(webSocket, response) + reconnectAttempts = 0 + } + override fun onMessage(webSocket: WebSocket, text: String) { super.onMessage(webSocket, text) @@ -141,27 +157,43 @@ class Realtime(client: Client) : Service(client), CoroutineScope { } private fun handleResponseError(message: RealtimeResponse) { - val error = message.data.jsonCast() - errorCallbacks.forEach { it.invoke(error) } + throw message.data.jsonCast() } private suspend fun handleResponseEvent(message: RealtimeResponse) { val event = message.data.jsonCast>() - event.channels.forEachAsync { channel -> - channelCallbacks[channel]?.forEachAsync { callbackWrapper -> - event.payload = event.payload.jsonCast(callbackWrapper.payloadClass) - callbackWrapper.callback.invoke(event) + if (event.channels.isEmpty()) { + return + } + if (!event.channels.any { activeChannels.contains(it) }) { + return + } + activeSubscriptions.values.forEachAsync { subscription -> + if (event.channels.any { subscription.channels.contains(it) }) { + event.payload = event.payload.jsonCast(subscription.payloadClass) + subscription.callback(event) } } } override fun onClosing(webSocket: WebSocket, code: Int, reason: String) { super.onClosing(webSocket, code, reason) - if (code == RealtimeCode.POLICY_VIOLATION.value) { + if (!reconnect || code == RealtimeCode.POLICY_VIOLATION.value) { + reconnect = true return } + + val timeout = getTimeout() + + Log.e( + this@Realtime::class.java.name, + "Realtime disconnected. Re-connecting in ${timeout / 1000} seconds.", + AppwriteException(reason, code) + ) + launch { - delay(1000) + delay(timeout) + reconnectAttempts++ createSocket() } } diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index 777b759..1b1941e 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -2,6 +2,7 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client +import io.appwrite.models.* import io.appwrite.exceptions.AppwriteException import okhttp3.Cookie import okhttp3.Response @@ -18,20 +19,20 @@ class Storage(client: Client) : Service(client) { * 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). * - * @param search - * @param limit - * @param offset - * @param orderType - * @return [Response] + * @param search Search term to filter your list results. Max length: 256 chars. + * @param limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. + * @param offset Results offset. The default value is 0. Use this param to manage pagination. + * @param orderType Order result by ASC or DESC order. + * @return [io.appwrite.models.FileList] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun listFiles( search: String? = null, - limit: Int? = null, - offset: Int? = null, + limit: Long? = null, + offset: Long? = null, orderType: String? = null - ): Response { + ): io.appwrite.models.FileList { val path = "/storage/files" val params = mapOf( "search" to search, @@ -39,12 +40,20 @@ class Storage(client: Client) : Service(client) { "offset" to offset, "orderType" to orderType ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.FileList = { + io.appwrite.models.FileList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.FileList::class.java, + convert = convert + ) } /** @@ -54,10 +63,10 @@ class Storage(client: Client) : Service(client) { * assigned to read and write access unless he has passed custom values for * read and write arguments. * - * @param file - * @param read - * @param write - * @return [Response] + * @param file Binary file. + * @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. + * @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. + * @return [io.appwrite.models.File] */ @JvmOverloads @Throws(AppwriteException::class) @@ -65,19 +74,27 @@ class Storage(client: Client) : Service(client) { file: File, read: List? = null, write: List? = null - ): Response { + ): io.appwrite.models.File { val path = "/storage/files" val params = mapOf( "file" to file, "read" to read, "write" to write ) - val headers = mapOf( "content-type" to "multipart/form-data" ) - - return client.call("POST", path, headers, params) + val convert: (Map) -> io.appwrite.models.File = { + io.appwrite.models.File.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.File::class.java, + convert = convert + ) } /** @@ -86,23 +103,31 @@ class Storage(client: Client) : Service(client) { * Get a file by its unique ID. This endpoint response returns a JSON object * with the file metadata. * - * @param fileId - * @return [Response] + * @param fileId File unique ID. + * @return [io.appwrite.models.File] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getFile( fileId: String - ): Response { + ): io.appwrite.models.File { val path = "/storage/files/{fileId}".replace("{fileId}", fileId) val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.File = { + io.appwrite.models.File.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.File::class.java, + convert = convert + ) } /** @@ -111,10 +136,10 @@ class Storage(client: Client) : Service(client) { * Update a file by its unique ID. Only users with write permissions have * access to update this resource. * - * @param fileId - * @param read - * @param write - * @return [Response] + * @param fileId File unique ID. + * @param read An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. + * @param write An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. + * @return [io.appwrite.models.File] */ @JvmOverloads @Throws(AppwriteException::class) @@ -122,18 +147,26 @@ class Storage(client: Client) : Service(client) { fileId: String, read: List, write: List - ): Response { + ): io.appwrite.models.File { val path = "/storage/files/{fileId}".replace("{fileId}", fileId) val params = mapOf( "read" to read, "write" to write ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("PUT", path, headers, params) + val convert: (Map) -> io.appwrite.models.File = { + io.appwrite.models.File.from(map = it) + } + return client.call( + "PUT", + path, + headers, + params, + responseType = io.appwrite.models.File::class.java, + convert = convert + ) } /** @@ -142,23 +175,27 @@ class Storage(client: Client) : Service(client) { * Delete a file by its unique ID. Only users with write permissions have * access to delete this resource. * - * @param fileId - * @return [Response] + * @param fileId File unique ID. + * @return [Any] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun deleteFile( fileId: String - ): Response { + ): Any { val path = "/storage/files/{fileId}".replace("{fileId}", fileId) val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("DELETE", path, headers, params) + return client.call( + "DELETE", + path, + headers, + params, + responseType = Any::class.java, + ) } /** @@ -168,20 +205,24 @@ class Storage(client: Client) : Service(client) { * 'Content-Disposition: attachment' header that tells the browser to start * downloading the file to user downloads directory. * - * @param fileId - * @return [Response] + * @param fileId File unique ID. + * @return [ByteArray] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getFileDownload( fileId: String - ): Response { + ): ByteArray { val path = "/storage/files/{fileId}/download".replace("{fileId}", fileId) val params = mapOf( "project" to client.config["project"] ) - - return client.call("GET", path, params = params) + return client.call( + "GET", + path, + params = params, + responseType = ByteArray::class.java + ) } /** @@ -192,36 +233,36 @@ class Storage(client: Client) : Service(client) { * and spreadsheets, will return the file icon image. You can also pass query * string arguments for cutting and resizing your preview image. * - * @param fileId - * @param width - * @param height - * @param gravity - * @param quality - * @param borderWidth - * @param borderColor - * @param borderRadius - * @param opacity - * @param rotation - * @param background - * @param output - * @return [Response] + * @param fileId File unique ID + * @param width Resize preview image width, Pass an integer between 0 to 4000. + * @param height Resize preview image height, Pass an integer between 0 to 4000. + * @param gravity Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right + * @param quality Preview image quality. Pass an integer between 0 to 100. Defaults to 100. + * @param borderWidth Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0. + * @param borderColor Preview image border color. Use a valid HEX color, no # is needed for prefix. + * @param borderRadius Preview image border radius in pixels. Pass an integer between 0 to 4000. + * @param opacity Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1. + * @param rotation Preview image rotation in degrees. Pass an integer between 0 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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getFilePreview( fileId: String, - width: Int? = null, - height: Int? = null, + width: Long? = null, + height: Long? = null, gravity: String? = null, - quality: Int? = null, - borderWidth: Int? = null, + quality: Long? = null, + borderWidth: Long? = null, borderColor: String? = null, - borderRadius: Int? = null, + borderRadius: Long? = null, opacity: Double? = null, - rotation: Int? = null, + rotation: Long? = null, background: String? = null, output: String? = null - ): Response { + ): ByteArray { val path = "/storage/files/{fileId}/preview".replace("{fileId}", fileId) val params = mapOf( "width" to width, @@ -237,8 +278,12 @@ class Storage(client: Client) : Service(client) { "output" to output, "project" to client.config["project"] ) - - return client.call("GET", path, params = params) + return client.call( + "GET", + path, + params = params, + responseType = ByteArray::class.java + ) } /** @@ -248,20 +293,24 @@ class Storage(client: Client) : Service(client) { * download method but returns with no 'Content-Disposition: attachment' * header. * - * @param fileId - * @return [Response] + * @param fileId File unique ID. + * @return [ByteArray] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getFileView( fileId: String - ): Response { + ): ByteArray { val path = "/storage/files/{fileId}/view".replace("{fileId}", fileId) val params = mapOf( "project" to client.config["project"] ) - - return client.call("GET", path, params = params) + return client.call( + "GET", + path, + params = params, + 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 741fd03..90dcba1 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -2,6 +2,7 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client +import io.appwrite.models.* import io.appwrite.exceptions.AppwriteException import okhttp3.Cookie import okhttp3.Response @@ -17,20 +18,20 @@ class Teams(client: Client) : Service(client) { * of the project's teams. [Learn more about different API * modes](/docs/admin). * - * @param search - * @param limit - * @param offset - * @param orderType - * @return [Response] + * @param search Search term to filter your list results. Max length: 256 chars. + * @param limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. + * @param offset Results offset. The default value is 0. Use this param to manage pagination. + * @param orderType Order result by ASC or DESC order. + * @return [io.appwrite.models.TeamList] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun list( search: String? = null, - limit: Int? = null, - offset: Int? = null, + limit: Long? = null, + offset: Long? = null, orderType: String? = null - ): Response { + ): io.appwrite.models.TeamList { val path = "/teams" val params = mapOf( "search" to search, @@ -38,12 +39,20 @@ class Teams(client: Client) : Service(client) { "offset" to offset, "orderType" to orderType ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.TeamList = { + io.appwrite.models.TeamList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.TeamList::class.java, + convert = convert + ) } /** @@ -54,27 +63,35 @@ class Teams(client: Client) : Service(client) { * who will be able add new owners and update or delete the team from your * project. * - * @param name - * @param roles - * @return [Response] + * @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). Max length for each role is 32 chars. + * @return [io.appwrite.models.Team] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun create( name: String, roles: List? = null - ): Response { + ): io.appwrite.models.Team { val path = "/teams" val params = mapOf( "name" to name, "roles" to roles ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("POST", path, headers, params) + val convert: (Map) -> io.appwrite.models.Team = { + io.appwrite.models.Team.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Team::class.java, + convert = convert + ) } /** @@ -83,23 +100,31 @@ class Teams(client: Client) : Service(client) { * Get a team by its unique ID. All team members have read access for this * resource. * - * @param teamId - * @return [Response] + * @param teamId Team unique ID. + * @return [io.appwrite.models.Team] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun get( teamId: String - ): Response { + ): io.appwrite.models.Team { val path = "/teams/{teamId}".replace("{teamId}", teamId) val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.Team = { + io.appwrite.models.Team.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.Team::class.java, + convert = convert + ) } /** @@ -108,26 +133,34 @@ class Teams(client: Client) : Service(client) { * Update a team by its unique ID. Only team owners have write access for this * resource. * - * @param teamId - * @param name - * @return [Response] + * @param teamId Team unique ID. + * @param name Team name. Max length: 128 chars. + * @return [io.appwrite.models.Team] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun update( teamId: String, name: String - ): Response { + ): io.appwrite.models.Team { val path = "/teams/{teamId}".replace("{teamId}", teamId) val params = mapOf( "name" to name ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("PUT", path, headers, params) + val convert: (Map) -> io.appwrite.models.Team = { + io.appwrite.models.Team.from(map = it) + } + return client.call( + "PUT", + path, + headers, + params, + responseType = io.appwrite.models.Team::class.java, + convert = convert + ) } /** @@ -136,23 +169,27 @@ class Teams(client: Client) : Service(client) { * Delete a team by its unique ID. Only team owners have write access for this * resource. * - * @param teamId - * @return [Response] + * @param teamId Team unique ID. + * @return [Any] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun delete( teamId: String - ): Response { + ): Any { val path = "/teams/{teamId}".replace("{teamId}", teamId) val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("DELETE", path, headers, params) + return client.call( + "DELETE", + path, + headers, + params, + responseType = Any::class.java, + ) } /** @@ -161,22 +198,22 @@ class Teams(client: Client) : Service(client) { * Get a team members by the team unique ID. All team members have read access * for this list of resources. * - * @param teamId - * @param search - * @param limit - * @param offset - * @param orderType - * @return [Response] + * @param teamId Team unique ID. + * @param search Search term to filter your list results. Max length: 256 chars. + * @param limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. + * @param offset Results offset. The default value is 0. Use this param to manage pagination. + * @param orderType Order result by ASC or DESC order. + * @return [io.appwrite.models.MembershipList] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getMemberships( teamId: String, search: String? = null, - limit: Int? = null, - offset: Int? = null, + limit: Long? = null, + offset: Long? = null, orderType: String? = null - ): Response { + ): io.appwrite.models.MembershipList { val path = "/teams/{teamId}/memberships".replace("{teamId}", teamId) val params = mapOf( "search" to search, @@ -184,12 +221,20 @@ class Teams(client: Client) : Service(client) { "offset" to offset, "orderType" to orderType ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("GET", path, headers, params) + val convert: (Map) -> io.appwrite.models.MembershipList = { + io.appwrite.models.MembershipList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.MembershipList::class.java, + convert = convert + ) } /** @@ -212,12 +257,12 @@ class Teams(client: Client) : Service(client) { * the only valid redirect URL's are the once from domains you have set when * added your platforms in the console interface. * - * @param teamId - * @param email - * @param roles - * @param url - * @param name - * @return [Response] + * @param teamId Team unique ID. + * @param email New team member email. + * @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). Max length for each role is 32 chars. + * @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 New team member name. Max length: 128 chars. + * @return [io.appwrite.models.Membership] */ @JvmOverloads @Throws(AppwriteException::class) @@ -227,7 +272,7 @@ class Teams(client: Client) : Service(client) { roles: List, url: String, name: String? = null - ): Response { + ): io.appwrite.models.Membership { val path = "/teams/{teamId}/memberships".replace("{teamId}", teamId) val params = mapOf( "email" to email, @@ -235,21 +280,29 @@ class Teams(client: Client) : Service(client) { "url" to url, "name" to name ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("POST", path, headers, params) + val convert: (Map) -> io.appwrite.models.Membership = { + io.appwrite.models.Membership.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Membership::class.java, + convert = convert + ) } /** * Update Membership Roles * - * @param teamId - * @param membershipId - * @param roles - * @return [Response] + * @param teamId Team unique ID. + * @param membershipId Membership ID. + * @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). Max length for each role is 32 chars. + * @return [io.appwrite.models.Membership] */ @JvmOverloads @Throws(AppwriteException::class) @@ -257,17 +310,25 @@ class Teams(client: Client) : Service(client) { teamId: String, membershipId: String, roles: List - ): Response { + ): io.appwrite.models.Membership { val path = "/teams/{teamId}/memberships/{membershipId}".replace("{teamId}", teamId).replace("{membershipId}", membershipId) val params = mapOf( "roles" to roles ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("PATCH", path, headers, params) + val convert: (Map) -> io.appwrite.models.Membership = { + io.appwrite.models.Membership.from(map = it) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.Membership::class.java, + convert = convert + ) } /** @@ -277,25 +338,29 @@ class Teams(client: Client) : Service(client) { * 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 - * @param membershipId - * @return [Response] + * @param teamId Team unique ID. + * @param membershipId Membership ID. + * @return [Any] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun deleteMembership( teamId: String, membershipId: String - ): Response { + ): Any { val path = "/teams/{teamId}/memberships/{membershipId}".replace("{teamId}", teamId).replace("{membershipId}", membershipId) val params = mapOf( ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("DELETE", path, headers, params) + return client.call( + "DELETE", + path, + headers, + params, + responseType = Any::class.java, + ) } /** @@ -305,11 +370,11 @@ class Teams(client: Client) : Service(client) { * after being redirected back to your app from the invitation email recieved * by the user. * - * @param teamId - * @param membershipId - * @param userId - * @param secret - * @return [Response] + * @param teamId Team unique ID. + * @param membershipId Membership ID. + * @param userId User unique ID. + * @param secret Secret key. + * @return [io.appwrite.models.Membership] */ @JvmOverloads @Throws(AppwriteException::class) @@ -318,18 +383,26 @@ class Teams(client: Client) : Service(client) { membershipId: String, userId: String, secret: String - ): Response { + ): io.appwrite.models.Membership { val path = "/teams/{teamId}/memberships/{membershipId}/status".replace("{teamId}", teamId).replace("{membershipId}", membershipId) val params = mapOf( "userId" to userId, "secret" to secret ) - val headers = mapOf( "content-type" to "application/json" ) - - return client.call("PATCH", path, headers, params) + val convert: (Map) -> io.appwrite.models.Membership = { + io.appwrite.models.Membership.from(map = it) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.Membership::class.java, + convert = convert + ) } } \ No newline at end of file From 3b0b656831e7cebea80e5bd405711b3b46015471 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 4 Jan 2022 15:18:09 +0545 Subject: [PATCH 014/118] feat(version): support 0.12.0 --- LICENSE.md | 2 +- README.md | 4 +- .../account/create-magic-u-r-l-session.md | 1 + docs/examples/java/account/create.md | 1 + docs/examples/java/account/get-logs.md | 35 ++--- .../account/update-magic-u-r-l-session.md | 2 +- .../examples/java/database/create-document.md | 1 + docs/examples/java/storage/create-file.md | 1 + docs/examples/java/teams/create.md | 1 + docs/examples/java/teams/get-membership.md | 49 ++++++ .../account/create-magic-u-r-l-session.md | 1 + docs/examples/kotlin/account/create.md | 1 + docs/examples/kotlin/account/get-logs.md | 3 +- .../account/update-magic-u-r-l-session.md | 2 +- .../kotlin/database/create-document.md | 1 + docs/examples/kotlin/storage/create-file.md | 1 + docs/examples/kotlin/teams/create.md | 1 + docs/examples/kotlin/teams/get-membership.md | 27 ++++ library/src/main/java/io/appwrite/Client.kt | 2 +- library/src/main/java/io/appwrite/Query.kt | 32 ++++ .../io/appwrite/models/AttributeBoolean.kt | 63 ++++++++ .../java/io/appwrite/models/AttributeEmail.kt | 71 +++++++++ .../java/io/appwrite/models/AttributeEnum.kt | 79 ++++++++++ .../java/io/appwrite/models/AttributeFloat.kt | 79 ++++++++++ .../io/appwrite/models/AttributeInteger.kt | 79 ++++++++++ .../java/io/appwrite/models/AttributeIp.kt | 71 +++++++++ .../io/appwrite/models/AttributeString.kt | 71 +++++++++ .../java/io/appwrite/models/AttributeUrl.kt | 71 +++++++++ .../java/io/appwrite/models/Collection.kt | 79 ++++++++++ .../main/java/io/appwrite/models/Document.kt | 16 +- .../main/java/io/appwrite/models/Execution.kt | 8 +- .../src/main/java/io/appwrite/models/File.kt | 16 +- .../main/java/io/appwrite/models/Function.kt | 127 ++++++++++++++++ .../src/main/java/io/appwrite/models/Index.kt | 55 +++++++ .../src/main/java/io/appwrite/models/Log.kt | 32 ++++ .../main/java/io/appwrite/models/LogList.kt | 8 + .../java/io/appwrite/models/Permissions.kt | 31 ---- .../main/java/io/appwrite/models/Runtime.kt | 71 +++++++++ .../src/main/java/io/appwrite/models/Tag.kt | 55 +++++++ .../src/main/java/io/appwrite/models/User.kt | 6 +- .../main/java/io/appwrite/services/Account.kt | 49 +++--- .../java/io/appwrite/services/Database.kt | 74 +++++---- .../java/io/appwrite/services/Functions.kt | 25 ++-- .../main/java/io/appwrite/services/Storage.kt | 35 +++-- .../main/java/io/appwrite/services/Teams.kt | 140 ++++++++++++------ 45 files changed, 1384 insertions(+), 195 deletions(-) create mode 100644 docs/examples/java/teams/get-membership.md create mode 100644 docs/examples/kotlin/teams/get-membership.md create mode 100644 library/src/main/java/io/appwrite/Query.kt create mode 100644 library/src/main/java/io/appwrite/models/AttributeBoolean.kt create mode 100644 library/src/main/java/io/appwrite/models/AttributeEmail.kt create mode 100644 library/src/main/java/io/appwrite/models/AttributeEnum.kt create mode 100644 library/src/main/java/io/appwrite/models/AttributeFloat.kt create mode 100644 library/src/main/java/io/appwrite/models/AttributeInteger.kt create mode 100644 library/src/main/java/io/appwrite/models/AttributeIp.kt create mode 100644 library/src/main/java/io/appwrite/models/AttributeString.kt create mode 100644 library/src/main/java/io/appwrite/models/AttributeUrl.kt create mode 100644 library/src/main/java/io/appwrite/models/Collection.kt create mode 100644 library/src/main/java/io/appwrite/models/Function.kt create mode 100644 library/src/main/java/io/appwrite/models/Index.kt delete mode 100644 library/src/main/java/io/appwrite/models/Permissions.kt create mode 100644 library/src/main/java/io/appwrite/models/Runtime.kt create mode 100644 library/src/main/java/io/appwrite/models/Tag.kt diff --git a/LICENSE.md b/LICENSE.md index d73a6e9..96201c4 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2021 Appwrite (https://appwrite.io) and individual contributors. +Copyright (c) 2022 Appwrite (https://appwrite.io) and individual contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/README.md b/README.md index 0580a7a..66c0e17 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-0.11.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-0.12.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 0.11.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).** +**This SDK is compatible with Appwrite server version 0.12.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) 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 36fc58a..de630ad 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 @@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity { Account account = new Account(client); account.createMagicURLSession( + "", "email@example.com", new Continuation() { @NotNull diff --git a/docs/examples/java/account/create.md b/docs/examples/java/account/create.md index 3ff5ab9..1f10de2 100644 --- a/docs/examples/java/account/create.md +++ b/docs/examples/java/account/create.md @@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity { Account account = new Account(client); account.create( + "", "email@example.com", "password", new Continuation() { diff --git a/docs/examples/java/account/get-logs.md b/docs/examples/java/account/get-logs.md index f2dea96..fb83c5d 100644 --- a/docs/examples/java/account/get-logs.md +++ b/docs/examples/java/account/get-logs.md @@ -18,29 +18,30 @@ public class MainActivity extends AppCompatActivity { Account account = new Account(client); - account.getLogs(new Continuation() { - @NotNull - @Override - public CoroutineContext getContext() { - return EmptyCoroutineContext.INSTANCE; - } + 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 { + @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()); } - } catch (Throwable th) { - Log.e("ERROR", th.toString()); } } - }); + ); } } \ No newline at end of file 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..f8375b9 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 @@ -19,7 +19,7 @@ public class MainActivity extends AppCompatActivity { Account account = new Account(client); account.updateMagicURLSession( - "[USER_ID]", + "", "[SECRET]" new Continuation() { @NotNull diff --git a/docs/examples/java/database/create-document.md b/docs/examples/java/database/create-document.md index b3a5b28..7f1ff4c 100644 --- a/docs/examples/java/database/create-document.md +++ b/docs/examples/java/database/create-document.md @@ -20,6 +20,7 @@ public class MainActivity extends AppCompatActivity { database.createDocument( "[COLLECTION_ID]", + "", mapOf( "a" to "b" ), new Continuation() { @NotNull diff --git a/docs/examples/java/storage/create-file.md b/docs/examples/java/storage/create-file.md index 172ef7e..f20ba26 100644 --- a/docs/examples/java/storage/create-file.md +++ b/docs/examples/java/storage/create-file.md @@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity { Storage storage = new Storage(client); storage.createFile( + "", File("./path-to-files/image.jpg"), new Continuation() { @NotNull diff --git a/docs/examples/java/teams/create.md b/docs/examples/java/teams/create.md index a715c0a..c3e3093 100644 --- a/docs/examples/java/teams/create.md +++ b/docs/examples/java/teams/create.md @@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity { Teams teams = new Teams(client); teams.create( + "", "[NAME]", new Continuation() { @NotNull diff --git a/docs/examples/java/teams/get-membership.md b/docs/examples/java/teams/get-membership.md new file mode 100644 index 0000000..87c0160 --- /dev/null +++ b/docs/examples/java/teams/get-membership.md @@ -0,0 +1,49 @@ +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.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 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 c803d1a..7ac9a30 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 @@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = account.createMagicURLSession( + userId = "", email = "email@example.com", ) val json = response.body?.string() diff --git a/docs/examples/kotlin/account/create.md b/docs/examples/kotlin/account/create.md index a8528ec..068fa5f 100644 --- a/docs/examples/kotlin/account/create.md +++ b/docs/examples/kotlin/account/create.md @@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = account.create( + userId = "", email = "email@example.com", password = "password", ) diff --git a/docs/examples/kotlin/account/get-logs.md b/docs/examples/kotlin/account/get-logs.md index 9f79f0a..b8c89f4 100644 --- a/docs/examples/kotlin/account/get-logs.md +++ b/docs/examples/kotlin/account/get-logs.md @@ -17,7 +17,8 @@ class MainActivity : AppCompatActivity() { val account = Account(client) GlobalScope.launch { - val response = account.getLogs() + val response = account.getLogs( + ) val json = response.body?.string() } } 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..923574e 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 @@ -18,7 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = account.updateMagicURLSession( - userId = "[USER_ID]", + userId = "", secret = "[SECRET]" ) val json = response.body?.string() diff --git a/docs/examples/kotlin/database/create-document.md b/docs/examples/kotlin/database/create-document.md index 72ec7ad..89ada64 100644 --- a/docs/examples/kotlin/database/create-document.md +++ b/docs/examples/kotlin/database/create-document.md @@ -19,6 +19,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = database.createDocument( collectionId = "[COLLECTION_ID]", + documentId = "", data = mapOf( "a" to "b" ), ) val json = response.body?.string() diff --git a/docs/examples/kotlin/storage/create-file.md b/docs/examples/kotlin/storage/create-file.md index 92a5e95..f4f36c9 100644 --- a/docs/examples/kotlin/storage/create-file.md +++ b/docs/examples/kotlin/storage/create-file.md @@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = storage.createFile( + fileId = "", file = File("./path-to-files/image.jpg"), ) val json = response.body?.string() diff --git a/docs/examples/kotlin/teams/create.md b/docs/examples/kotlin/teams/create.md index 068fbd6..fcce1e0 100644 --- a/docs/examples/kotlin/teams/create.md +++ b/docs/examples/kotlin/teams/create.md @@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = teams.create( + teamId = "", name = "[NAME]", ) val json = response.body?.string() diff --git a/docs/examples/kotlin/teams/get-membership.md b/docs/examples/kotlin/teams/get-membership.md new file mode 100644 index 0000000..aa3f29e --- /dev/null +++ b/docs/examples/kotlin/teams/get-membership.md @@ -0,0 +1,27 @@ +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.getMembership( + teamId = "[TEAM_ID]", + membershipId = "[MEMBERSHIP_ID]" + ) + val json = response.body?.string() + } + } +} \ 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 162357e..352294d 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -79,7 +79,7 @@ class Client @JvmOverloads constructor( "origin" to "appwrite-android://${context.packageName}", "user-agent" to "${context.packageName}/${appVersion}, ${System.getProperty("http.agent")}", "x-sdk-version" to "appwrite:android:${BuildConfig.SDK_VERSION}", - "x-appwrite-response-format" to "0.11.0" + "x-appwrite-response-format" to "0.12.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/Query.kt b/library/src/main/java/io/appwrite/Query.kt new file mode 100644 index 0000000..b86507b --- /dev/null +++ b/library/src/main/java/io/appwrite/Query.kt @@ -0,0 +1,32 @@ +package io.appwrite + +class Query { + companion object { + fun equal(attribute: String, value: Any) = addQuery(attribute, "equal", value) + + fun notEqual(attribute: String, value: Any) = Query.addQuery(attribute, "notEqual", value) + + fun lesser(attribute: String, value: Any) = Query.addQuery(attribute, "lesser", value) + + fun lesserEqual(attribute: String, value: Any) = Query.addQuery(attribute, "lesserEqual", value) + + fun greater(attribute: String, value: Any) = Query.addQuery(attribute, "greater", value) + + fun greaterEqual(attribute: String, value: Any) = Query.addQuery(attribute, "greaterEqual", value) + + fun search(attribute: String, value: String) = Query.addQuery(attribute, "search", value) + + private fun addQuery(attribute: String, oper: String, value: Any): String { + return when (value) { + is List<*> -> "${attribute}.${oper}(${value.map{it -> parseValues(it!!)}.joinToString(",")})" + else -> "${attribute}.${oper}(${Query.parseValues(value)})" + } + } + private fun parseValues(value: Any): String { + return when (value) { + is String -> "\"${value}\"" + else -> "${value}" + } + } + } +} diff --git a/library/src/main/java/io/appwrite/models/AttributeBoolean.kt b/library/src/main/java/io/appwrite/models/AttributeBoolean.kt new file mode 100644 index 0000000..dc1ea40 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AttributeBoolean.kt @@ -0,0 +1,63 @@ +package io.appwrite.models + +/** + * AttributeBoolean + */ +data class AttributeBoolean( + /** + * Attribute Key. + * + */ + val key: String, + + /** + * Attribute type. + * + */ + val type: String, + + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * + */ + val status: String, + + /** + * Is attribute required? + * + */ + val required: Boolean, + + /** + * Is attribute an array? + * + */ + var array: Boolean? = , + + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + * + */ + var default: Boolean? = +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = AttributeBoolean( + key = map["key"] as String, + type = map["type"] as String, + status = map["status"] as String, + required = map["required"] as Boolean, + array = map["array"] as? Boolean, + default = map["default"] as? Boolean + ) + } + + fun toMap(): Map = mapOf( + "key" to key as Any, + "type" to type as Any, + "status" to status as Any, + "required" to required as Any, + "array" to array as Any, + "default" to default as Any + ) +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeEmail.kt b/library/src/main/java/io/appwrite/models/AttributeEmail.kt new file mode 100644 index 0000000..890b40f --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AttributeEmail.kt @@ -0,0 +1,71 @@ +package io.appwrite.models + +/** + * AttributeEmail + */ +data class AttributeEmail( + /** + * Attribute Key. + * + */ + val key: String, + + /** + * Attribute type. + * + */ + val type: String, + + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * + */ + val status: String, + + /** + * Is attribute required? + * + */ + val required: Boolean, + + /** + * Is attribute an array? + * + */ + var array: Boolean? = , + + /** + * String format. + * + */ + val format: String, + + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + * + */ + var default: String? = +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = AttributeEmail( + key = map["key"] as String, + type = map["type"] as String, + status = map["status"] as String, + required = map["required"] as Boolean, + array = map["array"] as? Boolean, + format = map["format"] as String, + default = map["default"] as? String + ) + } + + fun toMap(): Map = mapOf( + "key" to key as Any, + "type" to type as Any, + "status" to status as Any, + "required" to required as Any, + "array" to array as Any, + "format" to format as Any, + "default" to default as Any + ) +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeEnum.kt b/library/src/main/java/io/appwrite/models/AttributeEnum.kt new file mode 100644 index 0000000..e700277 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AttributeEnum.kt @@ -0,0 +1,79 @@ +package io.appwrite.models + +/** + * AttributeEnum + */ +data class AttributeEnum( + /** + * Attribute Key. + * + */ + val key: String, + + /** + * Attribute type. + * + */ + val type: String, + + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * + */ + val status: String, + + /** + * Is attribute required? + * + */ + val required: Boolean, + + /** + * Is attribute an array? + * + */ + var array: Boolean? = , + + /** + * Array of elements in enumerated type. + * + */ + val elements: List, + + /** + * String format. + * + */ + val format: String, + + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + * + */ + var default: String? = +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = AttributeEnum( + key = map["key"] as String, + type = map["type"] as String, + status = map["status"] as String, + required = map["required"] as Boolean, + array = map["array"] as? Boolean, + elements = map["elements"] as List, + format = map["format"] as String, + default = map["default"] as? String + ) + } + + fun toMap(): Map = mapOf( + "key" to key as Any, + "type" to type as Any, + "status" to status as Any, + "required" to required as Any, + "array" to array as Any, + "elements" to elements as Any, + "format" to format as Any, + "default" to default as Any + ) +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeFloat.kt b/library/src/main/java/io/appwrite/models/AttributeFloat.kt new file mode 100644 index 0000000..ae7b985 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AttributeFloat.kt @@ -0,0 +1,79 @@ +package io.appwrite.models + +/** + * AttributeFloat + */ +data class AttributeFloat( + /** + * Attribute Key. + * + */ + val key: String, + + /** + * Attribute type. + * + */ + val type: String, + + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * + */ + val status: String, + + /** + * Is attribute required? + * + */ + val required: Boolean, + + /** + * Is attribute an array? + * + */ + var array: Boolean? = , + + /** + * Minimum value to enforce for new documents. + * + */ + var min: Double? = , + + /** + * Maximum value to enforce for new documents. + * + */ + var max: Double? = , + + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + * + */ + var default: Double? = +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = AttributeFloat( + key = map["key"] as String, + type = map["type"] as String, + status = map["status"] as String, + required = map["required"] as Boolean, + array = map["array"] as? Boolean, + min = map["min"] as? Double, + max = map["max"] as? Double, + default = map["default"] as? Double + ) + } + + fun toMap(): Map = mapOf( + "key" to key as Any, + "type" to type as Any, + "status" to status as Any, + "required" to required as Any, + "array" to array as Any, + "min" to min as Any, + "max" to max as Any, + "default" to default as Any + ) +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeInteger.kt b/library/src/main/java/io/appwrite/models/AttributeInteger.kt new file mode 100644 index 0000000..d00f804 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AttributeInteger.kt @@ -0,0 +1,79 @@ +package io.appwrite.models + +/** + * AttributeInteger + */ +data class AttributeInteger( + /** + * Attribute Key. + * + */ + val key: String, + + /** + * Attribute type. + * + */ + val type: String, + + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * + */ + val status: String, + + /** + * Is attribute required? + * + */ + val required: Boolean, + + /** + * Is attribute an array? + * + */ + var array: Boolean? = , + + /** + * Minimum value to enforce for new documents. + * + */ + var min: Long? = , + + /** + * Maximum value to enforce for new documents. + * + */ + var max: Long? = , + + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + * + */ + var default: Long? = +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = AttributeInteger( + key = map["key"] as String, + type = map["type"] as String, + status = map["status"] as String, + required = map["required"] as Boolean, + array = map["array"] as? Boolean, + min = map["min"] as? Long, + max = map["max"] as? Long, + default = map["default"] as? Long + ) + } + + fun toMap(): Map = mapOf( + "key" to key as Any, + "type" to type as Any, + "status" to status as Any, + "required" to required as Any, + "array" to array as Any, + "min" to min as Any, + "max" to max as Any, + "default" to default as Any + ) +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeIp.kt b/library/src/main/java/io/appwrite/models/AttributeIp.kt new file mode 100644 index 0000000..88c1c22 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AttributeIp.kt @@ -0,0 +1,71 @@ +package io.appwrite.models + +/** + * AttributeIP + */ +data class AttributeIp( + /** + * Attribute Key. + * + */ + val key: String, + + /** + * Attribute type. + * + */ + val type: String, + + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * + */ + val status: String, + + /** + * Is attribute required? + * + */ + val required: Boolean, + + /** + * Is attribute an array? + * + */ + var array: Boolean? = , + + /** + * String format. + * + */ + val format: String, + + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + * + */ + var default: String? = +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = AttributeIp( + key = map["key"] as String, + type = map["type"] as String, + status = map["status"] as String, + required = map["required"] as Boolean, + array = map["array"] as? Boolean, + format = map["format"] as String, + default = map["default"] as? String + ) + } + + fun toMap(): Map = mapOf( + "key" to key as Any, + "type" to type as Any, + "status" to status as Any, + "required" to required as Any, + "array" to array as Any, + "format" to format as Any, + "default" to default as Any + ) +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeString.kt b/library/src/main/java/io/appwrite/models/AttributeString.kt new file mode 100644 index 0000000..d383f4a --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AttributeString.kt @@ -0,0 +1,71 @@ +package io.appwrite.models + +/** + * AttributeString + */ +data class AttributeString( + /** + * Attribute Key. + * + */ + val key: String, + + /** + * Attribute type. + * + */ + val type: String, + + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * + */ + val status: String, + + /** + * Is attribute required? + * + */ + val required: Boolean, + + /** + * Is attribute an array? + * + */ + var array: Boolean? = , + + /** + * Attribute size. + * + */ + val size: String, + + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + * + */ + var default: String? = +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = AttributeString( + key = map["key"] as String, + type = map["type"] as String, + status = map["status"] as String, + required = map["required"] as Boolean, + array = map["array"] as? Boolean, + size = map["size"] as String, + default = map["default"] as? String + ) + } + + fun toMap(): Map = mapOf( + "key" to key as Any, + "type" to type as Any, + "status" to status as Any, + "required" to required as Any, + "array" to array as Any, + "size" to size as Any, + "default" to default as Any + ) +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeUrl.kt b/library/src/main/java/io/appwrite/models/AttributeUrl.kt new file mode 100644 index 0000000..5a8cd5f --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AttributeUrl.kt @@ -0,0 +1,71 @@ +package io.appwrite.models + +/** + * AttributeURL + */ +data class AttributeUrl( + /** + * Attribute Key. + * + */ + val key: String, + + /** + * Attribute type. + * + */ + val type: String, + + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * + */ + val status: String, + + /** + * Is attribute required? + * + */ + val required: Boolean, + + /** + * Is attribute an array? + * + */ + var array: Boolean? = , + + /** + * String format. + * + */ + val format: String, + + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + * + */ + var default: String? = +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = AttributeUrl( + key = map["key"] as String, + type = map["type"] as String, + status = map["status"] as String, + required = map["required"] as Boolean, + array = map["array"] as? Boolean, + format = map["format"] as String, + default = map["default"] as? String + ) + } + + fun toMap(): Map = mapOf( + "key" to key as Any, + "type" to type as Any, + "status" to status as Any, + "required" to required as Any, + "array" to array as Any, + "format" to format as Any, + "default" to default as Any + ) +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Collection.kt b/library/src/main/java/io/appwrite/models/Collection.kt new file mode 100644 index 0000000..c16018b --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Collection.kt @@ -0,0 +1,79 @@ +package io.appwrite.models + +/** + * Collection + */ +data class Collection( + /** + * Collection ID. + * + */ + val id: String, + + /** + * Collection read permissions. + * + */ + val read: List, + + /** + * Collection write permissions. + * + */ + val write: List, + + /** + * Collection name. + * + */ + val name: String, + + /** + * Collection enabled. + * + */ + val enabled: Boolean, + + /** + * Collection permission model. Possible values: `document` or `collection` + * + */ + val permission: String, + + /** + * Collection attributes. + * + */ + val attributes: List, + + /** + * Collection indexes. + * + */ + val indexes: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Collection( + id = map["\$id"] as String, + read = map["\$read"] as List, + write = map["\$write"] as List, + name = map["name"] as String, + enabled = map["enabled"] as Boolean, + permission = map["permission"] as String, + attributes = map["attributes"] as List, + indexes = (map["indexes"] as List>).map { Index.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$read" to read as Any, + "\$write" to write as Any, + "name" to name as Any, + "enabled" to enabled as Any, + "permission" to permission as Any, + "attributes" to attributes as Any, + "indexes" to indexes.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 0941dfe..f443676 100644 --- a/library/src/main/java/io/appwrite/models/Document.kt +++ b/library/src/main/java/io/appwrite/models/Document.kt @@ -17,10 +17,16 @@ data class Document( val collection: String, /** - * Document permissions. + * Document read permissions. * */ - val permissions: Permissions, + val read: List, + + /** + * Document write permissions. + * + */ + val write: List, val data: Map ) { @@ -29,7 +35,8 @@ data class Document( fun from(map: Map) = Document( id = map["\$id"] as String, collection = map["\$collection"] as String, - permissions = Permissions.from(map = map["\$permissions"] as Map), + read = map["\$read"] as List, + write = map["\$write"] as List, data = map ) } @@ -37,7 +44,8 @@ data class Document( fun toMap(): Map = mapOf( "\$id" to id as Any, "\$collection" to collection as Any, - "\$permissions" to permissions.toMap() as Any, + "\$read" to read as Any, + "\$write" to write as Any, "data" to data ) diff --git a/library/src/main/java/io/appwrite/models/Execution.kt b/library/src/main/java/io/appwrite/models/Execution.kt index e9e8d8f..2d25a73 100644 --- a/library/src/main/java/io/appwrite/models/Execution.kt +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -11,10 +11,10 @@ data class Execution( val id: String, /** - * Execution permissions. + * Execution read permissions. * */ - val permissions: Permissions, + val read: List, /** * Function ID. @@ -68,7 +68,7 @@ data class Execution( @Suppress("UNCHECKED_CAST") fun from(map: Map) = Execution( id = map["\$id"] as String, - permissions = Permissions.from(map = map["\$permissions"] as Map), + read = map["\$read"] as List, functionId = map["functionId"] as String, dateCreated = map["dateCreated"] as Long, trigger = map["trigger"] as String, @@ -82,7 +82,7 @@ data class Execution( fun toMap(): Map = mapOf( "\$id" to id as Any, - "\$permissions" to permissions.toMap() as Any, + "\$read" to read as Any, "functionId" to functionId as Any, "dateCreated" to dateCreated as Any, "trigger" to trigger as Any, diff --git a/library/src/main/java/io/appwrite/models/File.kt b/library/src/main/java/io/appwrite/models/File.kt index daa35c2..1546c61 100644 --- a/library/src/main/java/io/appwrite/models/File.kt +++ b/library/src/main/java/io/appwrite/models/File.kt @@ -11,10 +11,16 @@ data class File( val id: String, /** - * File permissions. + * File read permissions. * */ - val permissions: Permissions, + val read: List, + + /** + * File write permissions. + * + */ + val write: List, /** * File name. @@ -50,7 +56,8 @@ data class File( @Suppress("UNCHECKED_CAST") fun from(map: Map) = File( id = map["\$id"] as String, - permissions = Permissions.from(map = map["\$permissions"] as Map), + read = map["\$read"] as List, + write = map["\$write"] as List, name = map["name"] as String, dateCreated = map["dateCreated"] as Long, signature = map["signature"] as String, @@ -61,7 +68,8 @@ data class File( fun toMap(): Map = mapOf( "\$id" to id as Any, - "\$permissions" to permissions.toMap() as Any, + "\$read" to read as Any, + "\$write" to write as Any, "name" to name as Any, "dateCreated" to dateCreated as Any, "signature" to signature as Any, diff --git a/library/src/main/java/io/appwrite/models/Function.kt b/library/src/main/java/io/appwrite/models/Function.kt new file mode 100644 index 0000000..bc46e83 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Function.kt @@ -0,0 +1,127 @@ +package io.appwrite.models + +/** + * Function + */ +data class Function( + /** + * Function ID. + * + */ + val id: String, + + /** + * Execution permissions. + * + */ + val execute: String, + + /** + * Function name. + * + */ + val name: String, + + /** + * Function creation date in Unix timestamp. + * + */ + val dateCreated: Long, + + /** + * Function update date in Unix timestamp. + * + */ + val dateUpdated: Long, + + /** + * Function status. Possible values: `disabled`, `enabled` + * + */ + val status: String, + + /** + * Function execution runtime. + * + */ + val runtime: String, + + /** + * Function active tag ID. + * + */ + val tag: String, + + /** + * Function environment variables. + * + */ + val vars: String, + + /** + * Function trigger events. + * + */ + val events: List, + + /** + * Function execution schedult in CRON format. + * + */ + val schedule: String, + + /** + * Function next scheduled execution date in Unix timestamp. + * + */ + val scheduleNext: Long, + + /** + * Function next scheduled execution date in Unix timestamp. + * + */ + val schedulePrevious: Long, + + /** + * Function execution timeout in seconds. + * + */ + val timeout: Long +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Function( + id = map["\$id"] as String, + execute = map["execute"] as String, + name = map["name"] as String, + dateCreated = map["dateCreated"] as Long, + dateUpdated = map["dateUpdated"] as Long, + status = map["status"] as String, + runtime = map["runtime"] as String, + tag = map["tag"] as String, + vars = map["vars"] as String, + events = map["events"] as List, + schedule = map["schedule"] as String, + scheduleNext = map["scheduleNext"] as Long, + schedulePrevious = map["schedulePrevious"] as Long, + timeout = map["timeout"] as Long + ) + } + + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "execute" to execute as Any, + "name" to name as Any, + "dateCreated" to dateCreated as Any, + "dateUpdated" to dateUpdated as Any, + "status" to status as Any, + "runtime" to runtime as Any, + "tag" to tag as Any, + "vars" to vars as Any, + "events" to events as Any, + "schedule" to schedule as Any, + "scheduleNext" to scheduleNext as Any, + "schedulePrevious" to schedulePrevious as Any, + "timeout" to timeout as Any + ) +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Index.kt b/library/src/main/java/io/appwrite/models/Index.kt new file mode 100644 index 0000000..5173b20 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Index.kt @@ -0,0 +1,55 @@ +package io.appwrite.models + +/** + * Index + */ +data class Index( + /** + * Index Key. + * + */ + val key: String, + + /** + * Index type. + * + */ + val type: String, + + /** + * Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * + */ + val status: String, + + /** + * Index attributes. + * + */ + val attributes: List, + + /** + * Index orders. + * + */ + val orders: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Index( + key = map["key"] as String, + type = map["type"] as String, + status = map["status"] as String, + attributes = map["attributes"] as List, + orders = map["orders"] as List + ) + } + + fun toMap(): Map = mapOf( + "key" to key as Any, + "type" to type as Any, + "status" to status as Any, + "attributes" to attributes as Any, + "orders" to orders 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 028aa71..05a0786 100644 --- a/library/src/main/java/io/appwrite/models/Log.kt +++ b/library/src/main/java/io/appwrite/models/Log.kt @@ -10,6 +10,30 @@ data class Log( */ val event: String, + /** + * User ID. + * + */ + val userId: String, + + /** + * User Email. + * + */ + val userEmail: String, + + /** + * User Name. + * + */ + val userName: String, + + /** + * API mode when event triggered. + * + */ + val mode: String, + /** * IP session in use when the session was created. * @@ -110,6 +134,10 @@ data class Log( @Suppress("UNCHECKED_CAST") fun from(map: Map) = Log( event = map["event"] as String, + userId = map["userId"] as String, + userEmail = map["userEmail"] as String, + userName = map["userName"] as String, + mode = map["mode"] as String, ip = map["ip"] as String, time = map["time"] as Long, osCode = map["osCode"] as String, @@ -131,6 +159,10 @@ data class Log( 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, diff --git a/library/src/main/java/io/appwrite/models/LogList.kt b/library/src/main/java/io/appwrite/models/LogList.kt index a741ae4..a6bbd4a 100644 --- a/library/src/main/java/io/appwrite/models/LogList.kt +++ b/library/src/main/java/io/appwrite/models/LogList.kt @@ -4,6 +4,12 @@ package io.appwrite.models * Logs List */ data class LogList( + /** + * Total number of items available on the server. + * + */ + val sum: Long, + /** * List of logs. * @@ -13,11 +19,13 @@ data class LogList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = LogList( + sum = map["sum"] as Long, logs = (map["logs"] as List>).map { Log.from(map = it) } ) } fun toMap(): Map = mapOf( + "sum" to sum 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/Permissions.kt b/library/src/main/java/io/appwrite/models/Permissions.kt deleted file mode 100644 index 81cd07d..0000000 --- a/library/src/main/java/io/appwrite/models/Permissions.kt +++ /dev/null @@ -1,31 +0,0 @@ -package io.appwrite.models - -/** - * Permissions - */ -data class Permissions( - /** - * Read permissions. - * - */ - val read: List, - - /** - * Write permissions. - * - */ - val write: List -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Permissions( - read = map["read"] as List, - write = map["write"] as List - ) - } - - fun toMap(): Map = mapOf( - "read" to read as Any, - "write" to write as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Runtime.kt b/library/src/main/java/io/appwrite/models/Runtime.kt new file mode 100644 index 0000000..664467c --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Runtime.kt @@ -0,0 +1,71 @@ +package io.appwrite.models + +/** + * Runtime + */ +data class Runtime( + /** + * Runtime ID. + * + */ + val id: String, + + /** + * Runtime Name. + * + */ + val name: String, + + /** + * Runtime version. + * + */ + val version: String, + + /** + * Base Docker image used to build the runtime. + * + */ + val base: String, + + /** + * Image name of Docker Hub. + * + */ + val image: String, + + /** + * Name of the logo image. + * + */ + val logo: String, + + /** + * List of supported architectures. + * + */ + val supports: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Runtime( + id = map["\$id"] as String, + name = map["name"] as String, + version = map["version"] as String, + base = map["base"] as String, + image = map["image"] as String, + logo = map["logo"] as String, + supports = map["supports"] as List + ) + } + + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "name" to name as Any, + "version" to version as Any, + "base" to base as Any, + "image" to image as Any, + "logo" to logo as Any, + "supports" to supports as Any + ) +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Tag.kt b/library/src/main/java/io/appwrite/models/Tag.kt new file mode 100644 index 0000000..b2a69b9 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Tag.kt @@ -0,0 +1,55 @@ +package io.appwrite.models + +/** + * Tag + */ +data class Tag( + /** + * Tag ID. + * + */ + val id: String, + + /** + * Function ID. + * + */ + val functionId: String, + + /** + * The tag creation date in Unix timestamp. + * + */ + val dateCreated: Long, + + /** + * The entrypoint command in use to execute the tag code. + * + */ + val command: String, + + /** + * The code size in bytes. + * + */ + val size: String +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Tag( + id = map["\$id"] as String, + functionId = map["functionId"] as String, + dateCreated = map["dateCreated"] as Long, + command = map["command"] as String, + size = map["size"] as String + ) + } + + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "functionId" to functionId as Any, + "dateCreated" to dateCreated as Any, + "command" to command as Any, + "size" to size as Any + ) +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/User.kt b/library/src/main/java/io/appwrite/models/User.kt index 82039e4..0af27cc 100644 --- a/library/src/main/java/io/appwrite/models/User.kt +++ b/library/src/main/java/io/appwrite/models/User.kt @@ -23,10 +23,10 @@ data class User( val registration: Long, /** - * User status. 0 for Unactivated, 1 for active and 2 is blocked. + * User status. Pass `true` for enabled and `false` for disabled. * */ - val status: Long, + val status: Boolean, /** * Unix timestamp of the most recent password update @@ -58,7 +58,7 @@ data class User( id = map["\$id"] as String, name = map["name"] as String, registration = map["registration"] as Long, - status = map["status"] as Long, + status = map["status"] as Boolean, passwordUpdate = map["passwordUpdate"] as Long, email = map["email"] as String, emailVerification = map["emailVerification"] as Boolean, diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 063d602..17344c4 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -53,20 +53,23 @@ class Account(client: Client) : Service(client) { * 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 email User email. - * @param password User password. Must be between 6 to 32 chars. + * @param password User password. Must be at least 8 chars. * @param name User name. Max length: 128 chars. * @return [io.appwrite.models.User] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun create( + userId: String, email: String, password: String, name: String? = null ): io.appwrite.models.User { val path = "/account" val params = mapOf( + "userId" to userId, "email" to email, "password" to password, "name" to name @@ -120,14 +123,16 @@ class Account(client: Client) : Service(client) { * Update Account Email * * Update currently logged in user account email address. After changing user - * address, user confirmation status is being reset and a new confirmation - * mail is sent. For security measures, user password is required to complete - * this request. + * 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 between 6 to 32 chars. + * @param password User password. Must be at least 8 chars. * @return [io.appwrite.models.User] */ @JvmOverloads @@ -196,13 +201,20 @@ class Account(client: Client) : Service(client) { * 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 limit Maximum number of logs to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. + * @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) * @return [io.appwrite.models.LogList] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getLogs(): io.appwrite.models.LogList { + suspend fun getLogs( + limit: Long? = null, + offset: Long? = null + ): io.appwrite.models.LogList { val path = "/account/logs" val params = mapOf( + "limit" to limit, + "offset" to offset ) val headers = mapOf( "content-type" to "application/json" @@ -260,8 +272,8 @@ class Account(client: Client) : Service(client) { * to pass in the new password, and the old password. For users created with * OAuth and Team Invites, oldPassword is optional. * - * @param password New user password. Must be between 6 to 32 chars. - * @param oldPassword Old user password. Must be between 6 to 32 chars. + * @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.User] */ @JvmOverloads @@ -410,10 +422,10 @@ class Account(client: Client) : Service(client) { * the only valid redirect URLs are the ones from domains you have set when * adding your platforms in the console interface. * - * @param userId User account UID address. + * @param userId User ID. * @param secret Valid reset token. - * @param password New password. Must be between 6 to 32 chars. - * @param passwordAgain New password again. Must be between 6 to 32 chars. + * @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] */ @JvmOverloads @@ -484,7 +496,7 @@ class Account(client: Client) : Service(client) { * password combination. This route will create a new session for the user. * * @param email User email. - * @param password User password. Must be between 6 to 32 chars. + * @param password User password. Must be at least 8 chars. * @return [io.appwrite.models.Session] */ @JvmOverloads @@ -588,6 +600,7 @@ class Account(client: Client) : Service(client) { * 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. * @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] @@ -595,11 +608,13 @@ class Account(client: Client) : Service(client) { @JvmOverloads @Throws(AppwriteException::class) suspend fun createMagicURLSession( + userId: String, email: String, url: String? = null ): io.appwrite.models.Token { val path = "/account/sessions/magic-url" val params = mapOf( + "userId" to userId, "email" to email, "url" to url ) @@ -634,7 +649,7 @@ class Account(client: Client) : Service(client) { * the only valid redirect URLs are the ones from domains you have set when * adding your platforms in the console interface. * - * @param userId User unique ID. + * @param userId User ID. * @param secret Valid verification token. * @return [io.appwrite.models.Session] */ @@ -681,7 +696,7 @@ class Account(client: Client) : Service(client) { * user.. * * - * @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, bitbucket, bitly, box, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, paypal, paypalSandbox, salesforce, slack, spotify, tradeshift, tradeshiftBox, twitch, vk, yahoo, yandex, wordpress. + * @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, bitbucket, bitly, box, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, paypal, paypalSandbox, salesforce, slack, spotify, tradeshift, tradeshiftBox, twitch, vk, yahoo, yammer, yandex, wordpress. * @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. @@ -753,7 +768,7 @@ class Account(client: Client) : Service(client) { * 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 unique ID. Use the string 'current' to get the current device session. + * @param sessionId Session ID. Use the string 'current' to get the current device session. * @return [io.appwrite.models.Session] */ @JvmOverloads @@ -787,7 +802,7 @@ class Account(client: Client) : Service(client) { * account sessions across all of their different devices. When using the * option id argument, only the session unique ID provider will be deleted. * - * @param sessionId Session unique ID. Use the string 'current' to delete the current device session. + * @param sessionId Session ID. Use the string 'current' to delete the current device session. * @return [Any] */ @JvmOverloads @@ -865,7 +880,7 @@ class Account(client: Client) : Service(client) { * to verify the user email ownership. If confirmed this route will return a * 200 status code. * - * @param userId User unique ID. + * @param userId User ID. * @param secret Valid verification token. * @return [io.appwrite.models.Token] */ diff --git a/library/src/main/java/io/appwrite/services/Database.kt b/library/src/main/java/io/appwrite/services/Database.kt index 6baecdc..9e7a077 100644 --- a/library/src/main/java/io/appwrite/services/Database.kt +++ b/library/src/main/java/io/appwrite/services/Database.kt @@ -18,37 +18,37 @@ class Database(client: Client) : Service(client) { * of the project's documents. [Learn more about different API * modes](/docs/admin). * - * @param collectionId Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection). - * @param filters Array of filter strings. Each filter is constructed from a key name, comparison operator (=, !=, >, <, <=, >=) and a value. You can also use a dot (.) separator in attribute names to filter by child document attributes. Examples: 'name=John Doe' or 'category.$id>=5bed2d152c362'. - * @param limit Maximum number of documents to return in response. Use this value to manage pagination. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Offset value. The default value is 0. Use this param to manage pagination. - * @param orderField Document field that results will be sorted by. - * @param orderType Order direction. Possible values are DESC for descending order, or ASC for ascending order. - * @param orderCast Order field type casting. Possible values are int, string, date, time or datetime. The database will attempt to cast the order field to the value you pass here. The default value is a string. - * @param search Search query. Enter any free text search. The database will try to find a match against all document attributes and children. Max length: 256 chars. + * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). + * @param queries Array of query strings. + * @param limit Maximum number of documents to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. + * @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) + * @param cursor ID of the document used as the starting point for the query, excluding the document itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) + * @param cursorDirection Direction of the cursor. + * @param orderAttributes Array of attributes used to sort results. + * @param orderTypes Array of order directions for sorting attribtues. Possible values are DESC for descending order, or ASC for ascending order. * @return [io.appwrite.models.DocumentList] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun listDocuments( collectionId: String, - filters: List? = null, + queries: List? = null, limit: Long? = null, offset: Long? = null, - orderField: String? = null, - orderType: String? = null, - orderCast: String? = null, - search: String? = null + cursor: String? = null, + cursorDirection: String? = null, + orderAttributes: List? = null, + orderTypes: List? = null ): io.appwrite.models.DocumentList { val path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId) val params = mapOf( - "filters" to filters, + "queries" to queries, "limit" to limit, "offset" to offset, - "orderField" to orderField, - "orderType" to orderType, - "orderCast" to orderCast, - "search" to search + "cursor" to cursor, + "cursorDirection" to cursorDirection, + "orderAttributes" to orderAttributes, + "orderTypes" to orderTypes ) val headers = mapOf( "content-type" to "application/json" @@ -74,34 +74,28 @@ class Database(client: Client) : Service(client) { * integration](/docs/server/database#databaseCreateCollection) API or * directly from your database console. * - * @param collectionId Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection). + * @param collectionId Collection ID. You can create a new collection with validation rules using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). + * @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 data Document data as JSON object. - * @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. - * @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. - * @param parentDocument Parent document unique ID. Use when you want your new document to be a child of a parent document. - * @param parentProperty Parent document property name. Use when you want your new document to be a child of a parent document. - * @param parentPropertyType Parent document property connection type. You can set this value to **assign**, **append** or **prepend**, default value is assign. Use when you want your new document to be a child of a parent document. + * @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. + * @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. * @return [io.appwrite.models.Document] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun createDocument( collectionId: String, + documentId: String, data: Any, read: List? = null, - write: List? = null, - parentDocument: String? = null, - parentProperty: String? = null, - parentPropertyType: String? = null + write: List? = null ): io.appwrite.models.Document { val path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId) val params = mapOf( + "documentId" to documentId, "data" to data, "read" to read, - "write" to write, - "parentDocument" to parentDocument, - "parentProperty" to parentProperty, - "parentPropertyType" to parentPropertyType + "write" to write ) val headers = mapOf( "content-type" to "application/json" @@ -125,8 +119,8 @@ class Database(client: Client) : Service(client) { * Get a document by its unique ID. This endpoint response returns a JSON * object with the document data. * - * @param collectionId Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection). - * @param documentId Document unique ID. + * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). + * @param documentId Document ID. * @return [io.appwrite.models.Document] */ @JvmOverloads @@ -160,11 +154,11 @@ class Database(client: Client) : Service(client) { * Update a document by its unique ID. Using the patch method you can pass * only specific fields that will get updated. * - * @param collectionId Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection). - * @param documentId Document unique ID. + * @param collectionId Collection ID. You can create a new collection with validation rules using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). + * @param documentId Document ID. * @param data Document data as JSON object. - * @param read An array of strings with read permissions. By default inherits the existing read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. - * @param write An array of strings with write permissions. By default inherits the existing write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. + * @param read An array of strings with read permissions. By default inherits the existing read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. + * @param write An array of strings with write permissions. By default inherits the existing write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. * @return [io.appwrite.models.Document] */ @JvmOverloads @@ -205,8 +199,8 @@ class Database(client: Client) : Service(client) { * documents, its attributes and relations to other documents. Child documents * **will not** be deleted. * - * @param collectionId Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection). - * @param documentId Document unique ID. + * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). + * @param documentId Document ID. * @return [Any] */ @JvmOverloads diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index 83ac165..132e753 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -18,28 +18,31 @@ class Functions(client: Client) : Service(client) { * return a list of all of the project's executions. [Learn more about * different API modes](/docs/admin). * - * @param functionId Function unique ID. + * @param functionId Function ID. + * @param limit Maximum number of executions to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. + * @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) * @param search Search term to filter your list results. Max length: 256 chars. - * @param limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Results offset. The default value is 0. Use this param to manage pagination. - * @param orderType Order result by ASC or DESC order. + * @param cursor ID of the execution used as the starting point for the query, excluding the execution itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) + * @param cursorDirection Direction of the cursor. * @return [io.appwrite.models.ExecutionList] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun listExecutions( functionId: String, - search: String? = null, limit: Long? = null, offset: Long? = null, - orderType: String? = null + search: String? = null, + cursor: String? = null, + cursorDirection: String? = null ): io.appwrite.models.ExecutionList { val path = "/functions/{functionId}/executions".replace("{functionId}", functionId) val params = mapOf( - "search" to search, "limit" to limit, "offset" to offset, - "orderType" to orderType + "search" to search, + "cursor" to cursor, + "cursorDirection" to cursorDirection ) val headers = mapOf( "content-type" to "application/json" @@ -65,7 +68,7 @@ class Functions(client: Client) : Service(client) { * updates on the current execution status. Once this endpoint is called, your * function execution process will start asynchronously. * - * @param functionId Function unique ID. + * @param functionId Function ID. * @param data String of custom data to send to function. * @return [io.appwrite.models.Execution] */ @@ -100,8 +103,8 @@ class Functions(client: Client) : Service(client) { * * Get a function execution log by its unique ID. * - * @param functionId Function unique ID. - * @param executionId Execution unique ID. + * @param functionId Function ID. + * @param executionId Execution ID. * @return [io.appwrite.models.Execution] */ @JvmOverloads diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index 1b1941e..42a0958 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -20,8 +20,10 @@ class Storage(client: Client) : Service(client) { * project's files. [Learn more about different API modes](/docs/admin). * * @param search Search term to filter your list results. Max length: 256 chars. - * @param limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Results offset. The default value is 0. Use this param to manage pagination. + * @param limit Maximum number of files to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. + * @param offset Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) + * @param cursor ID of the file used as the starting point for the query, excluding the file itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) + * @param cursorDirection Direction of the cursor. * @param orderType Order result by ASC or DESC order. * @return [io.appwrite.models.FileList] */ @@ -31,6 +33,8 @@ class Storage(client: Client) : Service(client) { search: String? = null, limit: Long? = null, offset: Long? = null, + cursor: String? = null, + cursorDirection: String? = null, orderType: String? = null ): io.appwrite.models.FileList { val path = "/storage/files" @@ -38,6 +42,8 @@ class Storage(client: Client) : Service(client) { "search" to search, "limit" to limit, "offset" to offset, + "cursor" to cursor, + "cursorDirection" to cursorDirection, "orderType" to orderType ) val headers = mapOf( @@ -63,20 +69,23 @@ class Storage(client: Client) : Service(client) { * assigned to read and write access unless he has passed custom values for * read and write arguments. * + * @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 file Binary file. - * @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. - * @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. + * @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. + * @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. * @return [io.appwrite.models.File] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun createFile( + fileId: String, file: File, read: List? = null, write: List? = null ): io.appwrite.models.File { val path = "/storage/files" val params = mapOf( + "fileId" to fileId, "file" to file, "read" to read, "write" to write @@ -103,7 +112,7 @@ class Storage(client: Client) : Service(client) { * Get a file by its unique ID. This endpoint response returns a JSON object * with the file metadata. * - * @param fileId File unique ID. + * @param fileId File ID. * @return [io.appwrite.models.File] */ @JvmOverloads @@ -136,9 +145,9 @@ class Storage(client: Client) : Service(client) { * Update a file by its unique ID. Only users with write permissions have * access to update this resource. * - * @param fileId File unique ID. - * @param read An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. - * @param write An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. + * @param fileId File ID. + * @param read An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. + * @param write An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. * @return [io.appwrite.models.File] */ @JvmOverloads @@ -175,7 +184,7 @@ class Storage(client: Client) : Service(client) { * Delete a file by its unique ID. Only users with write permissions have * access to delete this resource. * - * @param fileId File unique ID. + * @param fileId File ID. * @return [Any] */ @JvmOverloads @@ -205,7 +214,7 @@ class Storage(client: Client) : Service(client) { * 'Content-Disposition: attachment' header that tells the browser to start * downloading the file to user downloads directory. * - * @param fileId File unique ID. + * @param fileId File ID. * @return [ByteArray] */ @JvmOverloads @@ -233,7 +242,7 @@ class Storage(client: Client) : Service(client) { * and spreadsheets, will return the file icon image. You can also pass query * string arguments for cutting and resizing your preview image. * - * @param fileId File unique ID + * @param fileId File ID. * @param width Resize preview image width, Pass an integer between 0 to 4000. * @param height Resize preview image height, Pass an integer between 0 to 4000. * @param gravity Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right @@ -242,7 +251,7 @@ class Storage(client: Client) : Service(client) { * @param borderColor Preview image border color. Use a valid HEX color, no # is needed for prefix. * @param borderRadius Preview image border radius in pixels. Pass an integer between 0 to 4000. * @param opacity Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1. - * @param rotation Preview image rotation in degrees. Pass an integer between 0 and 360. + * @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] @@ -293,7 +302,7 @@ class Storage(client: Client) : Service(client) { * download method but returns with no 'Content-Disposition: attachment' * header. * - * @param fileId File unique ID. + * @param fileId File ID. * @return [ByteArray] */ @JvmOverloads diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 90dcba1..cc08040 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -13,14 +13,17 @@ class Teams(client: Client) : Service(client) { /** * List Teams * - * Get a list of all the current user teams. 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 teams. [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. + * + * In admin mode, this endpoint returns a list of all the teams in the current + * project. [Learn more about different API modes](/docs/admin). * * @param search Search term to filter your list results. Max length: 256 chars. - * @param limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Results offset. The default value is 0. Use this param to manage pagination. + * @param limit Maximum number of teams to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. + * @param offset Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) + * @param cursor ID of the team used as the starting point for the query, excluding the team itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) + * @param cursorDirection Direction of the cursor. * @param orderType Order result by ASC or DESC order. * @return [io.appwrite.models.TeamList] */ @@ -30,6 +33,8 @@ class Teams(client: Client) : Service(client) { search: String? = null, limit: Long? = null, offset: Long? = null, + cursor: String? = null, + cursorDirection: String? = null, orderType: String? = null ): io.appwrite.models.TeamList { val path = "/teams" @@ -37,6 +42,8 @@ class Teams(client: Client) : Service(client) { "search" to search, "limit" to limit, "offset" to offset, + "cursor" to cursor, + "cursorDirection" to cursorDirection, "orderType" to orderType ) val headers = mapOf( @@ -59,10 +66,10 @@ class Teams(client: Client) : Service(client) { * Create Team * * Create a new team. The user who creates the team will automatically be - * assigned as the owner of the team. The team owner can invite new members, - * who will be able add new owners and update or delete the team from your - * project. + * 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 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). Max length for each role is 32 chars. * @return [io.appwrite.models.Team] @@ -70,11 +77,13 @@ class Teams(client: Client) : Service(client) { @JvmOverloads @Throws(AppwriteException::class) suspend fun create( + teamId: String, name: String, roles: List? = null ): io.appwrite.models.Team { val path = "/teams" val params = mapOf( + "teamId" to teamId, "name" to name, "roles" to roles ) @@ -97,10 +106,9 @@ class Teams(client: Client) : Service(client) { /** * Get Team * - * Get a team by its unique ID. All team members have read access for this - * resource. + * Get a team by its ID. All team members have read access for this resource. * - * @param teamId Team unique ID. + * @param teamId Team ID. * @return [io.appwrite.models.Team] */ @JvmOverloads @@ -130,11 +138,11 @@ class Teams(client: Client) : Service(client) { /** * Update Team * - * Update a team by its unique ID. Only team owners have write access for this - * resource. + * Update a team using its ID. Only members with the owner role can update the + * team. * - * @param teamId Team unique ID. - * @param name Team name. Max length: 128 chars. + * @param teamId Team ID. + * @param name New team name. Max length: 128 chars. * @return [io.appwrite.models.Team] */ @JvmOverloads @@ -166,10 +174,10 @@ class Teams(client: Client) : Service(client) { /** * Delete Team * - * Delete a team by its unique ID. Only team owners have write access for this - * resource. + * Delete a team using its ID. Only team members with the owner role can + * delete the team. * - * @param teamId Team unique ID. + * @param teamId Team ID. * @return [Any] */ @JvmOverloads @@ -195,13 +203,15 @@ class Teams(client: Client) : Service(client) { /** * Get Team Memberships * - * Get a team members by the team unique ID. All team members have read access - * for this list of resources. + * 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 unique ID. + * @param teamId Team ID. * @param search Search term to filter your list results. Max length: 256 chars. - * @param limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Results offset. The default value is 0. Use this param to manage pagination. + * @param limit Maximum number of memberships to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. + * @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) + * @param cursor ID of the membership used as the starting point for the query, excluding the membership itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) + * @param cursorDirection Direction of the cursor. * @param orderType Order result by ASC or DESC order. * @return [io.appwrite.models.MembershipList] */ @@ -212,6 +222,8 @@ class Teams(client: Client) : Service(client) { search: String? = null, limit: Long? = null, offset: Long? = null, + cursor: String? = null, + cursorDirection: String? = null, orderType: String? = null ): io.appwrite.models.MembershipList { val path = "/teams/{teamId}/memberships".replace("{teamId}", teamId) @@ -219,6 +231,8 @@ class Teams(client: Client) : Service(client) { "search" to search, "limit" to limit, "offset" to offset, + "cursor" to cursor, + "cursorDirection" to cursorDirection, "orderType" to orderType ) val headers = mapOf( @@ -240,28 +254,27 @@ class Teams(client: Client) : Service(client) { /** * Create Team Membership * - * Use this endpoint to invite a new member to join your team. If initiated - * from Client SDK, an email with a link to join the team will be sent to the - * new member's email address if the member doesn't exist in the project it - * will be created automatically. If initiated from server side SDKs, new - * member will automatically be added to the team. + * 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 + * 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. While calling from side - * SDKs the redirect url can be empty string. + * the user to accept the invitation to the team. * - * Please note that in order to avoid a [Redirect - * Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) + * 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 - * added your platforms in the console interface. + * adding your platforms in the console interface. * - * @param teamId Team unique ID. - * @param email New team member email. + * @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). Max length for each role is 32 chars. * @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 New team member name. Max length: 128 chars. + * @param name Name of the new team member. Max length: 128 chars. * @return [io.appwrite.models.Membership] */ @JvmOverloads @@ -296,12 +309,51 @@ class Teams(client: Client) : Service(client) { ) } + /** + * Get Team Membership + * + * 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] + */ + @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) + val params = mapOf( + ) + val headers = mapOf( + "content-type" to "application/json" + ) + val convert: (Map) -> io.appwrite.models.MembershipList = { + io.appwrite.models.MembershipList.from(map = it) + } + return client.call( + "GET", + path, + headers, + params, + responseType = io.appwrite.models.MembershipList::class.java, + convert = convert + ) + } + /** * Update Membership Roles * - * @param teamId Team unique ID. + * 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 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). Max length for each role is 32 chars. + * @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). Max length for each role is 32 chars. * @return [io.appwrite.models.Membership] */ @JvmOverloads @@ -338,7 +390,7 @@ class Teams(client: Client) : Service(client) { * 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 unique ID. + * @param teamId Team ID. * @param membershipId Membership ID. * @return [Any] */ @@ -367,12 +419,12 @@ class Teams(client: Client) : Service(client) { * 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 recieved + * after being redirected back to your app from the invitation email received * by the user. * - * @param teamId Team unique ID. + * @param teamId Team ID. * @param membershipId Membership ID. - * @param userId User unique ID. + * @param userId User ID. * @param secret Secret key. * @return [io.appwrite.models.Membership] */ From 2320810b8f5db60ffdcfdbff71516997ef0b885a Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 4 Jan 2022 17:34:02 +0545 Subject: [PATCH 015/118] fix docs --- docs/examples/java/account/create-magic-u-r-l-session.md | 2 +- docs/examples/java/account/create.md | 2 +- docs/examples/java/account/update-magic-u-r-l-session.md | 2 +- docs/examples/java/database/create-document.md | 2 +- docs/examples/java/storage/create-file.md | 2 +- docs/examples/java/teams/create.md | 2 +- docs/examples/kotlin/account/create-magic-u-r-l-session.md | 2 +- docs/examples/kotlin/account/create.md | 2 +- docs/examples/kotlin/account/update-magic-u-r-l-session.md | 2 +- docs/examples/kotlin/database/create-document.md | 2 +- docs/examples/kotlin/storage/create-file.md | 2 +- docs/examples/kotlin/teams/create.md | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) 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 de630ad..6c9fa7c 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 @@ -19,7 +19,7 @@ public class MainActivity extends AppCompatActivity { Account account = new Account(client); account.createMagicURLSession( - "", + "[USER_ID]", "email@example.com", new Continuation() { @NotNull diff --git a/docs/examples/java/account/create.md b/docs/examples/java/account/create.md index 1f10de2..11a5168 100644 --- a/docs/examples/java/account/create.md +++ b/docs/examples/java/account/create.md @@ -19,7 +19,7 @@ public class MainActivity extends AppCompatActivity { Account account = new Account(client); account.create( - "", + "[USER_ID]", "email@example.com", "password", new Continuation() { 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 f8375b9..d0734e1 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 @@ -19,7 +19,7 @@ public class MainActivity extends AppCompatActivity { Account account = new Account(client); account.updateMagicURLSession( - "", + "[USER_ID]", "[SECRET]" new Continuation() { @NotNull diff --git a/docs/examples/java/database/create-document.md b/docs/examples/java/database/create-document.md index 7f1ff4c..059a42e 100644 --- a/docs/examples/java/database/create-document.md +++ b/docs/examples/java/database/create-document.md @@ -20,7 +20,7 @@ public class MainActivity extends AppCompatActivity { database.createDocument( "[COLLECTION_ID]", - "", + "[DOCUMENT_ID]", mapOf( "a" to "b" ), new Continuation() { @NotNull diff --git a/docs/examples/java/storage/create-file.md b/docs/examples/java/storage/create-file.md index f20ba26..420ca3c 100644 --- a/docs/examples/java/storage/create-file.md +++ b/docs/examples/java/storage/create-file.md @@ -19,7 +19,7 @@ public class MainActivity extends AppCompatActivity { Storage storage = new Storage(client); storage.createFile( - "", + "[FILE_ID]", File("./path-to-files/image.jpg"), new Continuation() { @NotNull diff --git a/docs/examples/java/teams/create.md b/docs/examples/java/teams/create.md index c3e3093..3723b30 100644 --- a/docs/examples/java/teams/create.md +++ b/docs/examples/java/teams/create.md @@ -19,7 +19,7 @@ public class MainActivity extends AppCompatActivity { Teams teams = new Teams(client); teams.create( - "", + "[TEAM_ID]", "[NAME]", new Continuation() { @NotNull 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 7ac9a30..15fa1c7 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 @@ -18,7 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = account.createMagicURLSession( - userId = "", + userId = "[USER_ID]", email = "email@example.com", ) val json = response.body?.string() diff --git a/docs/examples/kotlin/account/create.md b/docs/examples/kotlin/account/create.md index 068fa5f..ab2534f 100644 --- a/docs/examples/kotlin/account/create.md +++ b/docs/examples/kotlin/account/create.md @@ -18,7 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = account.create( - userId = "", + userId = "[USER_ID]", 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 923574e..3fe1b7c 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 @@ -18,7 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = account.updateMagicURLSession( - userId = "", + userId = "[USER_ID]", secret = "[SECRET]" ) val json = response.body?.string() diff --git a/docs/examples/kotlin/database/create-document.md b/docs/examples/kotlin/database/create-document.md index 89ada64..d207383 100644 --- a/docs/examples/kotlin/database/create-document.md +++ b/docs/examples/kotlin/database/create-document.md @@ -19,7 +19,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = database.createDocument( collectionId = "[COLLECTION_ID]", - documentId = "", + documentId = "[DOCUMENT_ID]", data = mapOf( "a" to "b" ), ) val json = response.body?.string() diff --git a/docs/examples/kotlin/storage/create-file.md b/docs/examples/kotlin/storage/create-file.md index f4f36c9..1261bda 100644 --- a/docs/examples/kotlin/storage/create-file.md +++ b/docs/examples/kotlin/storage/create-file.md @@ -18,7 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = storage.createFile( - fileId = "", + fileId = "[FILE_ID]", file = File("./path-to-files/image.jpg"), ) val json = response.body?.string() diff --git a/docs/examples/kotlin/teams/create.md b/docs/examples/kotlin/teams/create.md index fcce1e0..73857b8 100644 --- a/docs/examples/kotlin/teams/create.md +++ b/docs/examples/kotlin/teams/create.md @@ -18,7 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = teams.create( - teamId = "", + teamId = "[TEAM_ID]", name = "[NAME]", ) val json = response.body?.string() From 596b8a2840dcd298a57078c2764588cbe6027368 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 4 Jan 2022 18:23:44 +0545 Subject: [PATCH 016/118] fix readmes and changes --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 66c0e17..91414f7 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,7 @@ When trying to connect to Appwrite from an emulator or a mobile device, localhos // Register User val account = Account(client) val response = account.create( + "[USER_ID]", "email@example.com", "password" ) @@ -126,6 +127,7 @@ val client = Client(context) val account = Account(client) val response = account.create( + "[USER_ID]", "email@example.com", "password" ) @@ -136,7 +138,7 @@ The Appwrite Android SDK raises an `AppwriteException` object with `message`, `c ```kotlin try { - var response = account.create("email@example.com", "password") + var response = account.create("[USER_ID]", "email@example.com", "password") Log.d("Appwrite response", response.body?.string()) } catch(e : AppwriteException) { Log.e("AppwriteException",e.message.toString()) From 6c2dc0cd049263b11ab0321cf1ee53e5787b8725 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 4 Jan 2022 18:46:26 +0545 Subject: [PATCH 017/118] fix versions --- README.md | 4 ++-- build.gradle | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 91414f7..3dca835 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:0.2.1") +implementation("io.appwrite:sdk-for-android:0.3.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 0.2.1 + 0.3.0 ``` diff --git a/build.gradle b/build.gradle index d2f3361..be4a0fa 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,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" - version "0.2.1" + version "0.3.0" repositories { maven { url "https://plugins.gradle.org/m2/" } google() From 664c8786e070653b7db02667f28214251b023f0e Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 5 Jan 2022 15:48:02 +0100 Subject: [PATCH 018/118] fix: add query builder --- README.md | 4 +- build.gradle | 2 +- .../io/appwrite/models/AttributeBoolean.kt | 63 --------- .../java/io/appwrite/models/AttributeEmail.kt | 71 ---------- .../java/io/appwrite/models/AttributeEnum.kt | 79 ----------- .../java/io/appwrite/models/AttributeFloat.kt | 79 ----------- .../io/appwrite/models/AttributeInteger.kt | 79 ----------- .../java/io/appwrite/models/AttributeIp.kt | 71 ---------- .../io/appwrite/models/AttributeString.kt | 71 ---------- .../java/io/appwrite/models/AttributeUrl.kt | 71 ---------- .../java/io/appwrite/models/Collection.kt | 79 ----------- .../main/java/io/appwrite/models/Function.kt | 127 ------------------ .../src/main/java/io/appwrite/models/Index.kt | 55 -------- .../main/java/io/appwrite/models/Runtime.kt | 71 ---------- .../src/main/java/io/appwrite/models/Tag.kt | 55 -------- 15 files changed, 3 insertions(+), 974 deletions(-) delete mode 100644 library/src/main/java/io/appwrite/models/AttributeBoolean.kt delete mode 100644 library/src/main/java/io/appwrite/models/AttributeEmail.kt delete mode 100644 library/src/main/java/io/appwrite/models/AttributeEnum.kt delete mode 100644 library/src/main/java/io/appwrite/models/AttributeFloat.kt delete mode 100644 library/src/main/java/io/appwrite/models/AttributeInteger.kt delete mode 100644 library/src/main/java/io/appwrite/models/AttributeIp.kt delete mode 100644 library/src/main/java/io/appwrite/models/AttributeString.kt delete mode 100644 library/src/main/java/io/appwrite/models/AttributeUrl.kt delete mode 100644 library/src/main/java/io/appwrite/models/Collection.kt delete mode 100644 library/src/main/java/io/appwrite/models/Function.kt delete mode 100644 library/src/main/java/io/appwrite/models/Index.kt delete mode 100644 library/src/main/java/io/appwrite/models/Runtime.kt delete mode 100644 library/src/main/java/io/appwrite/models/Tag.kt diff --git a/README.md b/README.md index 3dca835..bc43724 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:0.3.0") +implementation("io.appwrite:sdk-for-android:0.3.1") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 0.3.0 + 0.3.1 ``` diff --git a/build.gradle b/build.gradle index be4a0fa..1c7defb 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,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" - version "0.3.0" + version "0.3.1" repositories { maven { url "https://plugins.gradle.org/m2/" } google() diff --git a/library/src/main/java/io/appwrite/models/AttributeBoolean.kt b/library/src/main/java/io/appwrite/models/AttributeBoolean.kt deleted file mode 100644 index dc1ea40..0000000 --- a/library/src/main/java/io/appwrite/models/AttributeBoolean.kt +++ /dev/null @@ -1,63 +0,0 @@ -package io.appwrite.models - -/** - * AttributeBoolean - */ -data class AttributeBoolean( - /** - * Attribute Key. - * - */ - val key: String, - - /** - * Attribute type. - * - */ - val type: String, - - /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - * - */ - val status: String, - - /** - * Is attribute required? - * - */ - val required: Boolean, - - /** - * Is attribute an array? - * - */ - var array: Boolean? = , - - /** - * Default value for attribute when not provided. Cannot be set when attribute is required. - * - */ - var default: Boolean? = -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = AttributeBoolean( - key = map["key"] as String, - type = map["type"] as String, - status = map["status"] as String, - required = map["required"] as Boolean, - array = map["array"] as? Boolean, - default = map["default"] as? Boolean - ) - } - - fun toMap(): Map = mapOf( - "key" to key as Any, - "type" to type as Any, - "status" to status as Any, - "required" to required as Any, - "array" to array as Any, - "default" to default as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeEmail.kt b/library/src/main/java/io/appwrite/models/AttributeEmail.kt deleted file mode 100644 index 890b40f..0000000 --- a/library/src/main/java/io/appwrite/models/AttributeEmail.kt +++ /dev/null @@ -1,71 +0,0 @@ -package io.appwrite.models - -/** - * AttributeEmail - */ -data class AttributeEmail( - /** - * Attribute Key. - * - */ - val key: String, - - /** - * Attribute type. - * - */ - val type: String, - - /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - * - */ - val status: String, - - /** - * Is attribute required? - * - */ - val required: Boolean, - - /** - * Is attribute an array? - * - */ - var array: Boolean? = , - - /** - * String format. - * - */ - val format: String, - - /** - * Default value for attribute when not provided. Cannot be set when attribute is required. - * - */ - var default: String? = -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = AttributeEmail( - key = map["key"] as String, - type = map["type"] as String, - status = map["status"] as String, - required = map["required"] as Boolean, - array = map["array"] as? Boolean, - format = map["format"] as String, - default = map["default"] as? String - ) - } - - fun toMap(): Map = mapOf( - "key" to key as Any, - "type" to type as Any, - "status" to status as Any, - "required" to required as Any, - "array" to array as Any, - "format" to format as Any, - "default" to default as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeEnum.kt b/library/src/main/java/io/appwrite/models/AttributeEnum.kt deleted file mode 100644 index e700277..0000000 --- a/library/src/main/java/io/appwrite/models/AttributeEnum.kt +++ /dev/null @@ -1,79 +0,0 @@ -package io.appwrite.models - -/** - * AttributeEnum - */ -data class AttributeEnum( - /** - * Attribute Key. - * - */ - val key: String, - - /** - * Attribute type. - * - */ - val type: String, - - /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - * - */ - val status: String, - - /** - * Is attribute required? - * - */ - val required: Boolean, - - /** - * Is attribute an array? - * - */ - var array: Boolean? = , - - /** - * Array of elements in enumerated type. - * - */ - val elements: List, - - /** - * String format. - * - */ - val format: String, - - /** - * Default value for attribute when not provided. Cannot be set when attribute is required. - * - */ - var default: String? = -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = AttributeEnum( - key = map["key"] as String, - type = map["type"] as String, - status = map["status"] as String, - required = map["required"] as Boolean, - array = map["array"] as? Boolean, - elements = map["elements"] as List, - format = map["format"] as String, - default = map["default"] as? String - ) - } - - fun toMap(): Map = mapOf( - "key" to key as Any, - "type" to type as Any, - "status" to status as Any, - "required" to required as Any, - "array" to array as Any, - "elements" to elements as Any, - "format" to format as Any, - "default" to default as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeFloat.kt b/library/src/main/java/io/appwrite/models/AttributeFloat.kt deleted file mode 100644 index ae7b985..0000000 --- a/library/src/main/java/io/appwrite/models/AttributeFloat.kt +++ /dev/null @@ -1,79 +0,0 @@ -package io.appwrite.models - -/** - * AttributeFloat - */ -data class AttributeFloat( - /** - * Attribute Key. - * - */ - val key: String, - - /** - * Attribute type. - * - */ - val type: String, - - /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - * - */ - val status: String, - - /** - * Is attribute required? - * - */ - val required: Boolean, - - /** - * Is attribute an array? - * - */ - var array: Boolean? = , - - /** - * Minimum value to enforce for new documents. - * - */ - var min: Double? = , - - /** - * Maximum value to enforce for new documents. - * - */ - var max: Double? = , - - /** - * Default value for attribute when not provided. Cannot be set when attribute is required. - * - */ - var default: Double? = -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = AttributeFloat( - key = map["key"] as String, - type = map["type"] as String, - status = map["status"] as String, - required = map["required"] as Boolean, - array = map["array"] as? Boolean, - min = map["min"] as? Double, - max = map["max"] as? Double, - default = map["default"] as? Double - ) - } - - fun toMap(): Map = mapOf( - "key" to key as Any, - "type" to type as Any, - "status" to status as Any, - "required" to required as Any, - "array" to array as Any, - "min" to min as Any, - "max" to max as Any, - "default" to default as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeInteger.kt b/library/src/main/java/io/appwrite/models/AttributeInteger.kt deleted file mode 100644 index d00f804..0000000 --- a/library/src/main/java/io/appwrite/models/AttributeInteger.kt +++ /dev/null @@ -1,79 +0,0 @@ -package io.appwrite.models - -/** - * AttributeInteger - */ -data class AttributeInteger( - /** - * Attribute Key. - * - */ - val key: String, - - /** - * Attribute type. - * - */ - val type: String, - - /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - * - */ - val status: String, - - /** - * Is attribute required? - * - */ - val required: Boolean, - - /** - * Is attribute an array? - * - */ - var array: Boolean? = , - - /** - * Minimum value to enforce for new documents. - * - */ - var min: Long? = , - - /** - * Maximum value to enforce for new documents. - * - */ - var max: Long? = , - - /** - * Default value for attribute when not provided. Cannot be set when attribute is required. - * - */ - var default: Long? = -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = AttributeInteger( - key = map["key"] as String, - type = map["type"] as String, - status = map["status"] as String, - required = map["required"] as Boolean, - array = map["array"] as? Boolean, - min = map["min"] as? Long, - max = map["max"] as? Long, - default = map["default"] as? Long - ) - } - - fun toMap(): Map = mapOf( - "key" to key as Any, - "type" to type as Any, - "status" to status as Any, - "required" to required as Any, - "array" to array as Any, - "min" to min as Any, - "max" to max as Any, - "default" to default as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeIp.kt b/library/src/main/java/io/appwrite/models/AttributeIp.kt deleted file mode 100644 index 88c1c22..0000000 --- a/library/src/main/java/io/appwrite/models/AttributeIp.kt +++ /dev/null @@ -1,71 +0,0 @@ -package io.appwrite.models - -/** - * AttributeIP - */ -data class AttributeIp( - /** - * Attribute Key. - * - */ - val key: String, - - /** - * Attribute type. - * - */ - val type: String, - - /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - * - */ - val status: String, - - /** - * Is attribute required? - * - */ - val required: Boolean, - - /** - * Is attribute an array? - * - */ - var array: Boolean? = , - - /** - * String format. - * - */ - val format: String, - - /** - * Default value for attribute when not provided. Cannot be set when attribute is required. - * - */ - var default: String? = -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = AttributeIp( - key = map["key"] as String, - type = map["type"] as String, - status = map["status"] as String, - required = map["required"] as Boolean, - array = map["array"] as? Boolean, - format = map["format"] as String, - default = map["default"] as? String - ) - } - - fun toMap(): Map = mapOf( - "key" to key as Any, - "type" to type as Any, - "status" to status as Any, - "required" to required as Any, - "array" to array as Any, - "format" to format as Any, - "default" to default as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeString.kt b/library/src/main/java/io/appwrite/models/AttributeString.kt deleted file mode 100644 index d383f4a..0000000 --- a/library/src/main/java/io/appwrite/models/AttributeString.kt +++ /dev/null @@ -1,71 +0,0 @@ -package io.appwrite.models - -/** - * AttributeString - */ -data class AttributeString( - /** - * Attribute Key. - * - */ - val key: String, - - /** - * Attribute type. - * - */ - val type: String, - - /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - * - */ - val status: String, - - /** - * Is attribute required? - * - */ - val required: Boolean, - - /** - * Is attribute an array? - * - */ - var array: Boolean? = , - - /** - * Attribute size. - * - */ - val size: String, - - /** - * Default value for attribute when not provided. Cannot be set when attribute is required. - * - */ - var default: String? = -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = AttributeString( - key = map["key"] as String, - type = map["type"] as String, - status = map["status"] as String, - required = map["required"] as Boolean, - array = map["array"] as? Boolean, - size = map["size"] as String, - default = map["default"] as? String - ) - } - - fun toMap(): Map = mapOf( - "key" to key as Any, - "type" to type as Any, - "status" to status as Any, - "required" to required as Any, - "array" to array as Any, - "size" to size as Any, - "default" to default as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeUrl.kt b/library/src/main/java/io/appwrite/models/AttributeUrl.kt deleted file mode 100644 index 5a8cd5f..0000000 --- a/library/src/main/java/io/appwrite/models/AttributeUrl.kt +++ /dev/null @@ -1,71 +0,0 @@ -package io.appwrite.models - -/** - * AttributeURL - */ -data class AttributeUrl( - /** - * Attribute Key. - * - */ - val key: String, - - /** - * Attribute type. - * - */ - val type: String, - - /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - * - */ - val status: String, - - /** - * Is attribute required? - * - */ - val required: Boolean, - - /** - * Is attribute an array? - * - */ - var array: Boolean? = , - - /** - * String format. - * - */ - val format: String, - - /** - * Default value for attribute when not provided. Cannot be set when attribute is required. - * - */ - var default: String? = -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = AttributeUrl( - key = map["key"] as String, - type = map["type"] as String, - status = map["status"] as String, - required = map["required"] as Boolean, - array = map["array"] as? Boolean, - format = map["format"] as String, - default = map["default"] as? String - ) - } - - fun toMap(): Map = mapOf( - "key" to key as Any, - "type" to type as Any, - "status" to status as Any, - "required" to required as Any, - "array" to array as Any, - "format" to format as Any, - "default" to default as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Collection.kt b/library/src/main/java/io/appwrite/models/Collection.kt deleted file mode 100644 index c16018b..0000000 --- a/library/src/main/java/io/appwrite/models/Collection.kt +++ /dev/null @@ -1,79 +0,0 @@ -package io.appwrite.models - -/** - * Collection - */ -data class Collection( - /** - * Collection ID. - * - */ - val id: String, - - /** - * Collection read permissions. - * - */ - val read: List, - - /** - * Collection write permissions. - * - */ - val write: List, - - /** - * Collection name. - * - */ - val name: String, - - /** - * Collection enabled. - * - */ - val enabled: Boolean, - - /** - * Collection permission model. Possible values: `document` or `collection` - * - */ - val permission: String, - - /** - * Collection attributes. - * - */ - val attributes: List, - - /** - * Collection indexes. - * - */ - val indexes: List -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Collection( - id = map["\$id"] as String, - read = map["\$read"] as List, - write = map["\$write"] as List, - name = map["name"] as String, - enabled = map["enabled"] as Boolean, - permission = map["permission"] as String, - attributes = map["attributes"] as List, - indexes = (map["indexes"] as List>).map { Index.from(map = it) } - ) - } - - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "\$read" to read as Any, - "\$write" to write as Any, - "name" to name as Any, - "enabled" to enabled as Any, - "permission" to permission as Any, - "attributes" to attributes as Any, - "indexes" to indexes.map { it.toMap() } as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Function.kt b/library/src/main/java/io/appwrite/models/Function.kt deleted file mode 100644 index bc46e83..0000000 --- a/library/src/main/java/io/appwrite/models/Function.kt +++ /dev/null @@ -1,127 +0,0 @@ -package io.appwrite.models - -/** - * Function - */ -data class Function( - /** - * Function ID. - * - */ - val id: String, - - /** - * Execution permissions. - * - */ - val execute: String, - - /** - * Function name. - * - */ - val name: String, - - /** - * Function creation date in Unix timestamp. - * - */ - val dateCreated: Long, - - /** - * Function update date in Unix timestamp. - * - */ - val dateUpdated: Long, - - /** - * Function status. Possible values: `disabled`, `enabled` - * - */ - val status: String, - - /** - * Function execution runtime. - * - */ - val runtime: String, - - /** - * Function active tag ID. - * - */ - val tag: String, - - /** - * Function environment variables. - * - */ - val vars: String, - - /** - * Function trigger events. - * - */ - val events: List, - - /** - * Function execution schedult in CRON format. - * - */ - val schedule: String, - - /** - * Function next scheduled execution date in Unix timestamp. - * - */ - val scheduleNext: Long, - - /** - * Function next scheduled execution date in Unix timestamp. - * - */ - val schedulePrevious: Long, - - /** - * Function execution timeout in seconds. - * - */ - val timeout: Long -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Function( - id = map["\$id"] as String, - execute = map["execute"] as String, - name = map["name"] as String, - dateCreated = map["dateCreated"] as Long, - dateUpdated = map["dateUpdated"] as Long, - status = map["status"] as String, - runtime = map["runtime"] as String, - tag = map["tag"] as String, - vars = map["vars"] as String, - events = map["events"] as List, - schedule = map["schedule"] as String, - scheduleNext = map["scheduleNext"] as Long, - schedulePrevious = map["schedulePrevious"] as Long, - timeout = map["timeout"] as Long - ) - } - - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "execute" to execute as Any, - "name" to name as Any, - "dateCreated" to dateCreated as Any, - "dateUpdated" to dateUpdated as Any, - "status" to status as Any, - "runtime" to runtime as Any, - "tag" to tag as Any, - "vars" to vars as Any, - "events" to events as Any, - "schedule" to schedule as Any, - "scheduleNext" to scheduleNext as Any, - "schedulePrevious" to schedulePrevious as Any, - "timeout" to timeout as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Index.kt b/library/src/main/java/io/appwrite/models/Index.kt deleted file mode 100644 index 5173b20..0000000 --- a/library/src/main/java/io/appwrite/models/Index.kt +++ /dev/null @@ -1,55 +0,0 @@ -package io.appwrite.models - -/** - * Index - */ -data class Index( - /** - * Index Key. - * - */ - val key: String, - - /** - * Index type. - * - */ - val type: String, - - /** - * Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - * - */ - val status: String, - - /** - * Index attributes. - * - */ - val attributes: List, - - /** - * Index orders. - * - */ - val orders: List -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Index( - key = map["key"] as String, - type = map["type"] as String, - status = map["status"] as String, - attributes = map["attributes"] as List, - orders = map["orders"] as List - ) - } - - fun toMap(): Map = mapOf( - "key" to key as Any, - "type" to type as Any, - "status" to status as Any, - "attributes" to attributes as Any, - "orders" to orders as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Runtime.kt b/library/src/main/java/io/appwrite/models/Runtime.kt deleted file mode 100644 index 664467c..0000000 --- a/library/src/main/java/io/appwrite/models/Runtime.kt +++ /dev/null @@ -1,71 +0,0 @@ -package io.appwrite.models - -/** - * Runtime - */ -data class Runtime( - /** - * Runtime ID. - * - */ - val id: String, - - /** - * Runtime Name. - * - */ - val name: String, - - /** - * Runtime version. - * - */ - val version: String, - - /** - * Base Docker image used to build the runtime. - * - */ - val base: String, - - /** - * Image name of Docker Hub. - * - */ - val image: String, - - /** - * Name of the logo image. - * - */ - val logo: String, - - /** - * List of supported architectures. - * - */ - val supports: List -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Runtime( - id = map["\$id"] as String, - name = map["name"] as String, - version = map["version"] as String, - base = map["base"] as String, - image = map["image"] as String, - logo = map["logo"] as String, - supports = map["supports"] as List - ) - } - - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "name" to name as Any, - "version" to version as Any, - "base" to base as Any, - "image" to image as Any, - "logo" to logo as Any, - "supports" to supports as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Tag.kt b/library/src/main/java/io/appwrite/models/Tag.kt deleted file mode 100644 index b2a69b9..0000000 --- a/library/src/main/java/io/appwrite/models/Tag.kt +++ /dev/null @@ -1,55 +0,0 @@ -package io.appwrite.models - -/** - * Tag - */ -data class Tag( - /** - * Tag ID. - * - */ - val id: String, - - /** - * Function ID. - * - */ - val functionId: String, - - /** - * The tag creation date in Unix timestamp. - * - */ - val dateCreated: Long, - - /** - * The entrypoint command in use to execute the tag code. - * - */ - val command: String, - - /** - * The code size in bytes. - * - */ - val size: String -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Tag( - id = map["\$id"] as String, - functionId = map["functionId"] as String, - dateCreated = map["dateCreated"] as Long, - command = map["command"] as String, - size = map["size"] as String - ) - } - - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "functionId" to functionId as Any, - "dateCreated" to dateCreated as Any, - "command" to command as Any, - "size" to size as Any - ) -} \ No newline at end of file From 7c1c0cff77b15c1acf43a84822fe496e8ebc7db4 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 6 Jan 2022 15:53:31 +0545 Subject: [PATCH 019/118] fix version --- README.md | 4 +- build.gradle | 2 +- .../io/appwrite/models/AttributeBoolean.kt | 63 +++++++++ .../java/io/appwrite/models/AttributeEmail.kt | 71 ++++++++++ .../java/io/appwrite/models/AttributeEnum.kt | 79 +++++++++++ .../java/io/appwrite/models/AttributeFloat.kt | 79 +++++++++++ .../io/appwrite/models/AttributeInteger.kt | 79 +++++++++++ .../java/io/appwrite/models/AttributeIp.kt | 71 ++++++++++ .../io/appwrite/models/AttributeString.kt | 71 ++++++++++ .../java/io/appwrite/models/AttributeUrl.kt | 71 ++++++++++ .../java/io/appwrite/models/Collection.kt | 79 +++++++++++ .../main/java/io/appwrite/models/Function.kt | 127 ++++++++++++++++++ .../src/main/java/io/appwrite/models/Index.kt | 55 ++++++++ .../main/java/io/appwrite/models/Runtime.kt | 71 ++++++++++ .../src/main/java/io/appwrite/models/Tag.kt | 55 ++++++++ 15 files changed, 974 insertions(+), 3 deletions(-) create mode 100644 library/src/main/java/io/appwrite/models/AttributeBoolean.kt create mode 100644 library/src/main/java/io/appwrite/models/AttributeEmail.kt create mode 100644 library/src/main/java/io/appwrite/models/AttributeEnum.kt create mode 100644 library/src/main/java/io/appwrite/models/AttributeFloat.kt create mode 100644 library/src/main/java/io/appwrite/models/AttributeInteger.kt create mode 100644 library/src/main/java/io/appwrite/models/AttributeIp.kt create mode 100644 library/src/main/java/io/appwrite/models/AttributeString.kt create mode 100644 library/src/main/java/io/appwrite/models/AttributeUrl.kt create mode 100644 library/src/main/java/io/appwrite/models/Collection.kt create mode 100644 library/src/main/java/io/appwrite/models/Function.kt create mode 100644 library/src/main/java/io/appwrite/models/Index.kt create mode 100644 library/src/main/java/io/appwrite/models/Runtime.kt create mode 100644 library/src/main/java/io/appwrite/models/Tag.kt diff --git a/README.md b/README.md index bc43724..3dca835 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:0.3.1") +implementation("io.appwrite:sdk-for-android:0.3.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 0.3.1 + 0.3.0 ``` diff --git a/build.gradle b/build.gradle index 1c7defb..be4a0fa 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,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" - version "0.3.1" + version "0.3.0" repositories { maven { url "https://plugins.gradle.org/m2/" } google() diff --git a/library/src/main/java/io/appwrite/models/AttributeBoolean.kt b/library/src/main/java/io/appwrite/models/AttributeBoolean.kt new file mode 100644 index 0000000..dc1ea40 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AttributeBoolean.kt @@ -0,0 +1,63 @@ +package io.appwrite.models + +/** + * AttributeBoolean + */ +data class AttributeBoolean( + /** + * Attribute Key. + * + */ + val key: String, + + /** + * Attribute type. + * + */ + val type: String, + + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * + */ + val status: String, + + /** + * Is attribute required? + * + */ + val required: Boolean, + + /** + * Is attribute an array? + * + */ + var array: Boolean? = , + + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + * + */ + var default: Boolean? = +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = AttributeBoolean( + key = map["key"] as String, + type = map["type"] as String, + status = map["status"] as String, + required = map["required"] as Boolean, + array = map["array"] as? Boolean, + default = map["default"] as? Boolean + ) + } + + fun toMap(): Map = mapOf( + "key" to key as Any, + "type" to type as Any, + "status" to status as Any, + "required" to required as Any, + "array" to array as Any, + "default" to default as Any + ) +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeEmail.kt b/library/src/main/java/io/appwrite/models/AttributeEmail.kt new file mode 100644 index 0000000..890b40f --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AttributeEmail.kt @@ -0,0 +1,71 @@ +package io.appwrite.models + +/** + * AttributeEmail + */ +data class AttributeEmail( + /** + * Attribute Key. + * + */ + val key: String, + + /** + * Attribute type. + * + */ + val type: String, + + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * + */ + val status: String, + + /** + * Is attribute required? + * + */ + val required: Boolean, + + /** + * Is attribute an array? + * + */ + var array: Boolean? = , + + /** + * String format. + * + */ + val format: String, + + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + * + */ + var default: String? = +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = AttributeEmail( + key = map["key"] as String, + type = map["type"] as String, + status = map["status"] as String, + required = map["required"] as Boolean, + array = map["array"] as? Boolean, + format = map["format"] as String, + default = map["default"] as? String + ) + } + + fun toMap(): Map = mapOf( + "key" to key as Any, + "type" to type as Any, + "status" to status as Any, + "required" to required as Any, + "array" to array as Any, + "format" to format as Any, + "default" to default as Any + ) +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeEnum.kt b/library/src/main/java/io/appwrite/models/AttributeEnum.kt new file mode 100644 index 0000000..e700277 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AttributeEnum.kt @@ -0,0 +1,79 @@ +package io.appwrite.models + +/** + * AttributeEnum + */ +data class AttributeEnum( + /** + * Attribute Key. + * + */ + val key: String, + + /** + * Attribute type. + * + */ + val type: String, + + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * + */ + val status: String, + + /** + * Is attribute required? + * + */ + val required: Boolean, + + /** + * Is attribute an array? + * + */ + var array: Boolean? = , + + /** + * Array of elements in enumerated type. + * + */ + val elements: List, + + /** + * String format. + * + */ + val format: String, + + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + * + */ + var default: String? = +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = AttributeEnum( + key = map["key"] as String, + type = map["type"] as String, + status = map["status"] as String, + required = map["required"] as Boolean, + array = map["array"] as? Boolean, + elements = map["elements"] as List, + format = map["format"] as String, + default = map["default"] as? String + ) + } + + fun toMap(): Map = mapOf( + "key" to key as Any, + "type" to type as Any, + "status" to status as Any, + "required" to required as Any, + "array" to array as Any, + "elements" to elements as Any, + "format" to format as Any, + "default" to default as Any + ) +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeFloat.kt b/library/src/main/java/io/appwrite/models/AttributeFloat.kt new file mode 100644 index 0000000..ae7b985 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AttributeFloat.kt @@ -0,0 +1,79 @@ +package io.appwrite.models + +/** + * AttributeFloat + */ +data class AttributeFloat( + /** + * Attribute Key. + * + */ + val key: String, + + /** + * Attribute type. + * + */ + val type: String, + + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * + */ + val status: String, + + /** + * Is attribute required? + * + */ + val required: Boolean, + + /** + * Is attribute an array? + * + */ + var array: Boolean? = , + + /** + * Minimum value to enforce for new documents. + * + */ + var min: Double? = , + + /** + * Maximum value to enforce for new documents. + * + */ + var max: Double? = , + + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + * + */ + var default: Double? = +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = AttributeFloat( + key = map["key"] as String, + type = map["type"] as String, + status = map["status"] as String, + required = map["required"] as Boolean, + array = map["array"] as? Boolean, + min = map["min"] as? Double, + max = map["max"] as? Double, + default = map["default"] as? Double + ) + } + + fun toMap(): Map = mapOf( + "key" to key as Any, + "type" to type as Any, + "status" to status as Any, + "required" to required as Any, + "array" to array as Any, + "min" to min as Any, + "max" to max as Any, + "default" to default as Any + ) +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeInteger.kt b/library/src/main/java/io/appwrite/models/AttributeInteger.kt new file mode 100644 index 0000000..d00f804 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AttributeInteger.kt @@ -0,0 +1,79 @@ +package io.appwrite.models + +/** + * AttributeInteger + */ +data class AttributeInteger( + /** + * Attribute Key. + * + */ + val key: String, + + /** + * Attribute type. + * + */ + val type: String, + + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * + */ + val status: String, + + /** + * Is attribute required? + * + */ + val required: Boolean, + + /** + * Is attribute an array? + * + */ + var array: Boolean? = , + + /** + * Minimum value to enforce for new documents. + * + */ + var min: Long? = , + + /** + * Maximum value to enforce for new documents. + * + */ + var max: Long? = , + + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + * + */ + var default: Long? = +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = AttributeInteger( + key = map["key"] as String, + type = map["type"] as String, + status = map["status"] as String, + required = map["required"] as Boolean, + array = map["array"] as? Boolean, + min = map["min"] as? Long, + max = map["max"] as? Long, + default = map["default"] as? Long + ) + } + + fun toMap(): Map = mapOf( + "key" to key as Any, + "type" to type as Any, + "status" to status as Any, + "required" to required as Any, + "array" to array as Any, + "min" to min as Any, + "max" to max as Any, + "default" to default as Any + ) +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeIp.kt b/library/src/main/java/io/appwrite/models/AttributeIp.kt new file mode 100644 index 0000000..88c1c22 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AttributeIp.kt @@ -0,0 +1,71 @@ +package io.appwrite.models + +/** + * AttributeIP + */ +data class AttributeIp( + /** + * Attribute Key. + * + */ + val key: String, + + /** + * Attribute type. + * + */ + val type: String, + + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * + */ + val status: String, + + /** + * Is attribute required? + * + */ + val required: Boolean, + + /** + * Is attribute an array? + * + */ + var array: Boolean? = , + + /** + * String format. + * + */ + val format: String, + + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + * + */ + var default: String? = +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = AttributeIp( + key = map["key"] as String, + type = map["type"] as String, + status = map["status"] as String, + required = map["required"] as Boolean, + array = map["array"] as? Boolean, + format = map["format"] as String, + default = map["default"] as? String + ) + } + + fun toMap(): Map = mapOf( + "key" to key as Any, + "type" to type as Any, + "status" to status as Any, + "required" to required as Any, + "array" to array as Any, + "format" to format as Any, + "default" to default as Any + ) +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeString.kt b/library/src/main/java/io/appwrite/models/AttributeString.kt new file mode 100644 index 0000000..d383f4a --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AttributeString.kt @@ -0,0 +1,71 @@ +package io.appwrite.models + +/** + * AttributeString + */ +data class AttributeString( + /** + * Attribute Key. + * + */ + val key: String, + + /** + * Attribute type. + * + */ + val type: String, + + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * + */ + val status: String, + + /** + * Is attribute required? + * + */ + val required: Boolean, + + /** + * Is attribute an array? + * + */ + var array: Boolean? = , + + /** + * Attribute size. + * + */ + val size: String, + + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + * + */ + var default: String? = +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = AttributeString( + key = map["key"] as String, + type = map["type"] as String, + status = map["status"] as String, + required = map["required"] as Boolean, + array = map["array"] as? Boolean, + size = map["size"] as String, + default = map["default"] as? String + ) + } + + fun toMap(): Map = mapOf( + "key" to key as Any, + "type" to type as Any, + "status" to status as Any, + "required" to required as Any, + "array" to array as Any, + "size" to size as Any, + "default" to default as Any + ) +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeUrl.kt b/library/src/main/java/io/appwrite/models/AttributeUrl.kt new file mode 100644 index 0000000..5a8cd5f --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AttributeUrl.kt @@ -0,0 +1,71 @@ +package io.appwrite.models + +/** + * AttributeURL + */ +data class AttributeUrl( + /** + * Attribute Key. + * + */ + val key: String, + + /** + * Attribute type. + * + */ + val type: String, + + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * + */ + val status: String, + + /** + * Is attribute required? + * + */ + val required: Boolean, + + /** + * Is attribute an array? + * + */ + var array: Boolean? = , + + /** + * String format. + * + */ + val format: String, + + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + * + */ + var default: String? = +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = AttributeUrl( + key = map["key"] as String, + type = map["type"] as String, + status = map["status"] as String, + required = map["required"] as Boolean, + array = map["array"] as? Boolean, + format = map["format"] as String, + default = map["default"] as? String + ) + } + + fun toMap(): Map = mapOf( + "key" to key as Any, + "type" to type as Any, + "status" to status as Any, + "required" to required as Any, + "array" to array as Any, + "format" to format as Any, + "default" to default as Any + ) +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Collection.kt b/library/src/main/java/io/appwrite/models/Collection.kt new file mode 100644 index 0000000..c16018b --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Collection.kt @@ -0,0 +1,79 @@ +package io.appwrite.models + +/** + * Collection + */ +data class Collection( + /** + * Collection ID. + * + */ + val id: String, + + /** + * Collection read permissions. + * + */ + val read: List, + + /** + * Collection write permissions. + * + */ + val write: List, + + /** + * Collection name. + * + */ + val name: String, + + /** + * Collection enabled. + * + */ + val enabled: Boolean, + + /** + * Collection permission model. Possible values: `document` or `collection` + * + */ + val permission: String, + + /** + * Collection attributes. + * + */ + val attributes: List, + + /** + * Collection indexes. + * + */ + val indexes: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Collection( + id = map["\$id"] as String, + read = map["\$read"] as List, + write = map["\$write"] as List, + name = map["name"] as String, + enabled = map["enabled"] as Boolean, + permission = map["permission"] as String, + attributes = map["attributes"] as List, + indexes = (map["indexes"] as List>).map { Index.from(map = it) } + ) + } + + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$read" to read as Any, + "\$write" to write as Any, + "name" to name as Any, + "enabled" to enabled as Any, + "permission" to permission as Any, + "attributes" to attributes as Any, + "indexes" to indexes.map { it.toMap() } as Any + ) +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Function.kt b/library/src/main/java/io/appwrite/models/Function.kt new file mode 100644 index 0000000..bc46e83 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Function.kt @@ -0,0 +1,127 @@ +package io.appwrite.models + +/** + * Function + */ +data class Function( + /** + * Function ID. + * + */ + val id: String, + + /** + * Execution permissions. + * + */ + val execute: String, + + /** + * Function name. + * + */ + val name: String, + + /** + * Function creation date in Unix timestamp. + * + */ + val dateCreated: Long, + + /** + * Function update date in Unix timestamp. + * + */ + val dateUpdated: Long, + + /** + * Function status. Possible values: `disabled`, `enabled` + * + */ + val status: String, + + /** + * Function execution runtime. + * + */ + val runtime: String, + + /** + * Function active tag ID. + * + */ + val tag: String, + + /** + * Function environment variables. + * + */ + val vars: String, + + /** + * Function trigger events. + * + */ + val events: List, + + /** + * Function execution schedult in CRON format. + * + */ + val schedule: String, + + /** + * Function next scheduled execution date in Unix timestamp. + * + */ + val scheduleNext: Long, + + /** + * Function next scheduled execution date in Unix timestamp. + * + */ + val schedulePrevious: Long, + + /** + * Function execution timeout in seconds. + * + */ + val timeout: Long +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Function( + id = map["\$id"] as String, + execute = map["execute"] as String, + name = map["name"] as String, + dateCreated = map["dateCreated"] as Long, + dateUpdated = map["dateUpdated"] as Long, + status = map["status"] as String, + runtime = map["runtime"] as String, + tag = map["tag"] as String, + vars = map["vars"] as String, + events = map["events"] as List, + schedule = map["schedule"] as String, + scheduleNext = map["scheduleNext"] as Long, + schedulePrevious = map["schedulePrevious"] as Long, + timeout = map["timeout"] as Long + ) + } + + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "execute" to execute as Any, + "name" to name as Any, + "dateCreated" to dateCreated as Any, + "dateUpdated" to dateUpdated as Any, + "status" to status as Any, + "runtime" to runtime as Any, + "tag" to tag as Any, + "vars" to vars as Any, + "events" to events as Any, + "schedule" to schedule as Any, + "scheduleNext" to scheduleNext as Any, + "schedulePrevious" to schedulePrevious as Any, + "timeout" to timeout as Any + ) +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Index.kt b/library/src/main/java/io/appwrite/models/Index.kt new file mode 100644 index 0000000..5173b20 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Index.kt @@ -0,0 +1,55 @@ +package io.appwrite.models + +/** + * Index + */ +data class Index( + /** + * Index Key. + * + */ + val key: String, + + /** + * Index type. + * + */ + val type: String, + + /** + * Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + * + */ + val status: String, + + /** + * Index attributes. + * + */ + val attributes: List, + + /** + * Index orders. + * + */ + val orders: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Index( + key = map["key"] as String, + type = map["type"] as String, + status = map["status"] as String, + attributes = map["attributes"] as List, + orders = map["orders"] as List + ) + } + + fun toMap(): Map = mapOf( + "key" to key as Any, + "type" to type as Any, + "status" to status as Any, + "attributes" to attributes as Any, + "orders" to orders as Any + ) +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Runtime.kt b/library/src/main/java/io/appwrite/models/Runtime.kt new file mode 100644 index 0000000..664467c --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Runtime.kt @@ -0,0 +1,71 @@ +package io.appwrite.models + +/** + * Runtime + */ +data class Runtime( + /** + * Runtime ID. + * + */ + val id: String, + + /** + * Runtime Name. + * + */ + val name: String, + + /** + * Runtime version. + * + */ + val version: String, + + /** + * Base Docker image used to build the runtime. + * + */ + val base: String, + + /** + * Image name of Docker Hub. + * + */ + val image: String, + + /** + * Name of the logo image. + * + */ + val logo: String, + + /** + * List of supported architectures. + * + */ + val supports: List +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Runtime( + id = map["\$id"] as String, + name = map["name"] as String, + version = map["version"] as String, + base = map["base"] as String, + image = map["image"] as String, + logo = map["logo"] as String, + supports = map["supports"] as List + ) + } + + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "name" to name as Any, + "version" to version as Any, + "base" to base as Any, + "image" to image as Any, + "logo" to logo as Any, + "supports" to supports as Any + ) +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Tag.kt b/library/src/main/java/io/appwrite/models/Tag.kt new file mode 100644 index 0000000..b2a69b9 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Tag.kt @@ -0,0 +1,55 @@ +package io.appwrite.models + +/** + * Tag + */ +data class Tag( + /** + * Tag ID. + * + */ + val id: String, + + /** + * Function ID. + * + */ + val functionId: String, + + /** + * The tag creation date in Unix timestamp. + * + */ + val dateCreated: Long, + + /** + * The entrypoint command in use to execute the tag code. + * + */ + val command: String, + + /** + * The code size in bytes. + * + */ + val size: String +) { + companion object { + @Suppress("UNCHECKED_CAST") + fun from(map: Map) = Tag( + id = map["\$id"] as String, + functionId = map["functionId"] as String, + dateCreated = map["dateCreated"] as Long, + command = map["command"] as String, + size = map["size"] as String + ) + } + + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "functionId" to functionId as Any, + "dateCreated" to dateCreated as Any, + "command" to command as Any, + "size" to size as Any + ) +} \ No newline at end of file From e582f73abbf3770bb1d39e04a81100e7bbd27434 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 6 Jan 2022 17:27:37 +0545 Subject: [PATCH 020/118] fix attribute models --- .../io/appwrite/models/AttributeBoolean.kt | 63 --------- .../java/io/appwrite/models/AttributeEmail.kt | 71 ---------- .../java/io/appwrite/models/AttributeEnum.kt | 79 ----------- .../java/io/appwrite/models/AttributeFloat.kt | 79 ----------- .../io/appwrite/models/AttributeInteger.kt | 79 ----------- .../java/io/appwrite/models/AttributeIp.kt | 71 ---------- .../io/appwrite/models/AttributeString.kt | 71 ---------- .../java/io/appwrite/models/AttributeUrl.kt | 71 ---------- .../java/io/appwrite/models/Collection.kt | 79 ----------- .../main/java/io/appwrite/models/Function.kt | 127 ------------------ .../src/main/java/io/appwrite/models/Index.kt | 55 -------- .../main/java/io/appwrite/models/Runtime.kt | 71 ---------- .../src/main/java/io/appwrite/models/Tag.kt | 55 -------- 13 files changed, 971 deletions(-) delete mode 100644 library/src/main/java/io/appwrite/models/AttributeBoolean.kt delete mode 100644 library/src/main/java/io/appwrite/models/AttributeEmail.kt delete mode 100644 library/src/main/java/io/appwrite/models/AttributeEnum.kt delete mode 100644 library/src/main/java/io/appwrite/models/AttributeFloat.kt delete mode 100644 library/src/main/java/io/appwrite/models/AttributeInteger.kt delete mode 100644 library/src/main/java/io/appwrite/models/AttributeIp.kt delete mode 100644 library/src/main/java/io/appwrite/models/AttributeString.kt delete mode 100644 library/src/main/java/io/appwrite/models/AttributeUrl.kt delete mode 100644 library/src/main/java/io/appwrite/models/Collection.kt delete mode 100644 library/src/main/java/io/appwrite/models/Function.kt delete mode 100644 library/src/main/java/io/appwrite/models/Index.kt delete mode 100644 library/src/main/java/io/appwrite/models/Runtime.kt delete mode 100644 library/src/main/java/io/appwrite/models/Tag.kt diff --git a/library/src/main/java/io/appwrite/models/AttributeBoolean.kt b/library/src/main/java/io/appwrite/models/AttributeBoolean.kt deleted file mode 100644 index dc1ea40..0000000 --- a/library/src/main/java/io/appwrite/models/AttributeBoolean.kt +++ /dev/null @@ -1,63 +0,0 @@ -package io.appwrite.models - -/** - * AttributeBoolean - */ -data class AttributeBoolean( - /** - * Attribute Key. - * - */ - val key: String, - - /** - * Attribute type. - * - */ - val type: String, - - /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - * - */ - val status: String, - - /** - * Is attribute required? - * - */ - val required: Boolean, - - /** - * Is attribute an array? - * - */ - var array: Boolean? = , - - /** - * Default value for attribute when not provided. Cannot be set when attribute is required. - * - */ - var default: Boolean? = -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = AttributeBoolean( - key = map["key"] as String, - type = map["type"] as String, - status = map["status"] as String, - required = map["required"] as Boolean, - array = map["array"] as? Boolean, - default = map["default"] as? Boolean - ) - } - - fun toMap(): Map = mapOf( - "key" to key as Any, - "type" to type as Any, - "status" to status as Any, - "required" to required as Any, - "array" to array as Any, - "default" to default as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeEmail.kt b/library/src/main/java/io/appwrite/models/AttributeEmail.kt deleted file mode 100644 index 890b40f..0000000 --- a/library/src/main/java/io/appwrite/models/AttributeEmail.kt +++ /dev/null @@ -1,71 +0,0 @@ -package io.appwrite.models - -/** - * AttributeEmail - */ -data class AttributeEmail( - /** - * Attribute Key. - * - */ - val key: String, - - /** - * Attribute type. - * - */ - val type: String, - - /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - * - */ - val status: String, - - /** - * Is attribute required? - * - */ - val required: Boolean, - - /** - * Is attribute an array? - * - */ - var array: Boolean? = , - - /** - * String format. - * - */ - val format: String, - - /** - * Default value for attribute when not provided. Cannot be set when attribute is required. - * - */ - var default: String? = -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = AttributeEmail( - key = map["key"] as String, - type = map["type"] as String, - status = map["status"] as String, - required = map["required"] as Boolean, - array = map["array"] as? Boolean, - format = map["format"] as String, - default = map["default"] as? String - ) - } - - fun toMap(): Map = mapOf( - "key" to key as Any, - "type" to type as Any, - "status" to status as Any, - "required" to required as Any, - "array" to array as Any, - "format" to format as Any, - "default" to default as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeEnum.kt b/library/src/main/java/io/appwrite/models/AttributeEnum.kt deleted file mode 100644 index e700277..0000000 --- a/library/src/main/java/io/appwrite/models/AttributeEnum.kt +++ /dev/null @@ -1,79 +0,0 @@ -package io.appwrite.models - -/** - * AttributeEnum - */ -data class AttributeEnum( - /** - * Attribute Key. - * - */ - val key: String, - - /** - * Attribute type. - * - */ - val type: String, - - /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - * - */ - val status: String, - - /** - * Is attribute required? - * - */ - val required: Boolean, - - /** - * Is attribute an array? - * - */ - var array: Boolean? = , - - /** - * Array of elements in enumerated type. - * - */ - val elements: List, - - /** - * String format. - * - */ - val format: String, - - /** - * Default value for attribute when not provided. Cannot be set when attribute is required. - * - */ - var default: String? = -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = AttributeEnum( - key = map["key"] as String, - type = map["type"] as String, - status = map["status"] as String, - required = map["required"] as Boolean, - array = map["array"] as? Boolean, - elements = map["elements"] as List, - format = map["format"] as String, - default = map["default"] as? String - ) - } - - fun toMap(): Map = mapOf( - "key" to key as Any, - "type" to type as Any, - "status" to status as Any, - "required" to required as Any, - "array" to array as Any, - "elements" to elements as Any, - "format" to format as Any, - "default" to default as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeFloat.kt b/library/src/main/java/io/appwrite/models/AttributeFloat.kt deleted file mode 100644 index ae7b985..0000000 --- a/library/src/main/java/io/appwrite/models/AttributeFloat.kt +++ /dev/null @@ -1,79 +0,0 @@ -package io.appwrite.models - -/** - * AttributeFloat - */ -data class AttributeFloat( - /** - * Attribute Key. - * - */ - val key: String, - - /** - * Attribute type. - * - */ - val type: String, - - /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - * - */ - val status: String, - - /** - * Is attribute required? - * - */ - val required: Boolean, - - /** - * Is attribute an array? - * - */ - var array: Boolean? = , - - /** - * Minimum value to enforce for new documents. - * - */ - var min: Double? = , - - /** - * Maximum value to enforce for new documents. - * - */ - var max: Double? = , - - /** - * Default value for attribute when not provided. Cannot be set when attribute is required. - * - */ - var default: Double? = -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = AttributeFloat( - key = map["key"] as String, - type = map["type"] as String, - status = map["status"] as String, - required = map["required"] as Boolean, - array = map["array"] as? Boolean, - min = map["min"] as? Double, - max = map["max"] as? Double, - default = map["default"] as? Double - ) - } - - fun toMap(): Map = mapOf( - "key" to key as Any, - "type" to type as Any, - "status" to status as Any, - "required" to required as Any, - "array" to array as Any, - "min" to min as Any, - "max" to max as Any, - "default" to default as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeInteger.kt b/library/src/main/java/io/appwrite/models/AttributeInteger.kt deleted file mode 100644 index d00f804..0000000 --- a/library/src/main/java/io/appwrite/models/AttributeInteger.kt +++ /dev/null @@ -1,79 +0,0 @@ -package io.appwrite.models - -/** - * AttributeInteger - */ -data class AttributeInteger( - /** - * Attribute Key. - * - */ - val key: String, - - /** - * Attribute type. - * - */ - val type: String, - - /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - * - */ - val status: String, - - /** - * Is attribute required? - * - */ - val required: Boolean, - - /** - * Is attribute an array? - * - */ - var array: Boolean? = , - - /** - * Minimum value to enforce for new documents. - * - */ - var min: Long? = , - - /** - * Maximum value to enforce for new documents. - * - */ - var max: Long? = , - - /** - * Default value for attribute when not provided. Cannot be set when attribute is required. - * - */ - var default: Long? = -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = AttributeInteger( - key = map["key"] as String, - type = map["type"] as String, - status = map["status"] as String, - required = map["required"] as Boolean, - array = map["array"] as? Boolean, - min = map["min"] as? Long, - max = map["max"] as? Long, - default = map["default"] as? Long - ) - } - - fun toMap(): Map = mapOf( - "key" to key as Any, - "type" to type as Any, - "status" to status as Any, - "required" to required as Any, - "array" to array as Any, - "min" to min as Any, - "max" to max as Any, - "default" to default as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeIp.kt b/library/src/main/java/io/appwrite/models/AttributeIp.kt deleted file mode 100644 index 88c1c22..0000000 --- a/library/src/main/java/io/appwrite/models/AttributeIp.kt +++ /dev/null @@ -1,71 +0,0 @@ -package io.appwrite.models - -/** - * AttributeIP - */ -data class AttributeIp( - /** - * Attribute Key. - * - */ - val key: String, - - /** - * Attribute type. - * - */ - val type: String, - - /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - * - */ - val status: String, - - /** - * Is attribute required? - * - */ - val required: Boolean, - - /** - * Is attribute an array? - * - */ - var array: Boolean? = , - - /** - * String format. - * - */ - val format: String, - - /** - * Default value for attribute when not provided. Cannot be set when attribute is required. - * - */ - var default: String? = -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = AttributeIp( - key = map["key"] as String, - type = map["type"] as String, - status = map["status"] as String, - required = map["required"] as Boolean, - array = map["array"] as? Boolean, - format = map["format"] as String, - default = map["default"] as? String - ) - } - - fun toMap(): Map = mapOf( - "key" to key as Any, - "type" to type as Any, - "status" to status as Any, - "required" to required as Any, - "array" to array as Any, - "format" to format as Any, - "default" to default as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeString.kt b/library/src/main/java/io/appwrite/models/AttributeString.kt deleted file mode 100644 index d383f4a..0000000 --- a/library/src/main/java/io/appwrite/models/AttributeString.kt +++ /dev/null @@ -1,71 +0,0 @@ -package io.appwrite.models - -/** - * AttributeString - */ -data class AttributeString( - /** - * Attribute Key. - * - */ - val key: String, - - /** - * Attribute type. - * - */ - val type: String, - - /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - * - */ - val status: String, - - /** - * Is attribute required? - * - */ - val required: Boolean, - - /** - * Is attribute an array? - * - */ - var array: Boolean? = , - - /** - * Attribute size. - * - */ - val size: String, - - /** - * Default value for attribute when not provided. Cannot be set when attribute is required. - * - */ - var default: String? = -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = AttributeString( - key = map["key"] as String, - type = map["type"] as String, - status = map["status"] as String, - required = map["required"] as Boolean, - array = map["array"] as? Boolean, - size = map["size"] as String, - default = map["default"] as? String - ) - } - - fun toMap(): Map = mapOf( - "key" to key as Any, - "type" to type as Any, - "status" to status as Any, - "required" to required as Any, - "array" to array as Any, - "size" to size as Any, - "default" to default as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AttributeUrl.kt b/library/src/main/java/io/appwrite/models/AttributeUrl.kt deleted file mode 100644 index 5a8cd5f..0000000 --- a/library/src/main/java/io/appwrite/models/AttributeUrl.kt +++ /dev/null @@ -1,71 +0,0 @@ -package io.appwrite.models - -/** - * AttributeURL - */ -data class AttributeUrl( - /** - * Attribute Key. - * - */ - val key: String, - - /** - * Attribute type. - * - */ - val type: String, - - /** - * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - * - */ - val status: String, - - /** - * Is attribute required? - * - */ - val required: Boolean, - - /** - * Is attribute an array? - * - */ - var array: Boolean? = , - - /** - * String format. - * - */ - val format: String, - - /** - * Default value for attribute when not provided. Cannot be set when attribute is required. - * - */ - var default: String? = -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = AttributeUrl( - key = map["key"] as String, - type = map["type"] as String, - status = map["status"] as String, - required = map["required"] as Boolean, - array = map["array"] as? Boolean, - format = map["format"] as String, - default = map["default"] as? String - ) - } - - fun toMap(): Map = mapOf( - "key" to key as Any, - "type" to type as Any, - "status" to status as Any, - "required" to required as Any, - "array" to array as Any, - "format" to format as Any, - "default" to default as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Collection.kt b/library/src/main/java/io/appwrite/models/Collection.kt deleted file mode 100644 index c16018b..0000000 --- a/library/src/main/java/io/appwrite/models/Collection.kt +++ /dev/null @@ -1,79 +0,0 @@ -package io.appwrite.models - -/** - * Collection - */ -data class Collection( - /** - * Collection ID. - * - */ - val id: String, - - /** - * Collection read permissions. - * - */ - val read: List, - - /** - * Collection write permissions. - * - */ - val write: List, - - /** - * Collection name. - * - */ - val name: String, - - /** - * Collection enabled. - * - */ - val enabled: Boolean, - - /** - * Collection permission model. Possible values: `document` or `collection` - * - */ - val permission: String, - - /** - * Collection attributes. - * - */ - val attributes: List, - - /** - * Collection indexes. - * - */ - val indexes: List -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Collection( - id = map["\$id"] as String, - read = map["\$read"] as List, - write = map["\$write"] as List, - name = map["name"] as String, - enabled = map["enabled"] as Boolean, - permission = map["permission"] as String, - attributes = map["attributes"] as List, - indexes = (map["indexes"] as List>).map { Index.from(map = it) } - ) - } - - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "\$read" to read as Any, - "\$write" to write as Any, - "name" to name as Any, - "enabled" to enabled as Any, - "permission" to permission as Any, - "attributes" to attributes as Any, - "indexes" to indexes.map { it.toMap() } as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Function.kt b/library/src/main/java/io/appwrite/models/Function.kt deleted file mode 100644 index bc46e83..0000000 --- a/library/src/main/java/io/appwrite/models/Function.kt +++ /dev/null @@ -1,127 +0,0 @@ -package io.appwrite.models - -/** - * Function - */ -data class Function( - /** - * Function ID. - * - */ - val id: String, - - /** - * Execution permissions. - * - */ - val execute: String, - - /** - * Function name. - * - */ - val name: String, - - /** - * Function creation date in Unix timestamp. - * - */ - val dateCreated: Long, - - /** - * Function update date in Unix timestamp. - * - */ - val dateUpdated: Long, - - /** - * Function status. Possible values: `disabled`, `enabled` - * - */ - val status: String, - - /** - * Function execution runtime. - * - */ - val runtime: String, - - /** - * Function active tag ID. - * - */ - val tag: String, - - /** - * Function environment variables. - * - */ - val vars: String, - - /** - * Function trigger events. - * - */ - val events: List, - - /** - * Function execution schedult in CRON format. - * - */ - val schedule: String, - - /** - * Function next scheduled execution date in Unix timestamp. - * - */ - val scheduleNext: Long, - - /** - * Function next scheduled execution date in Unix timestamp. - * - */ - val schedulePrevious: Long, - - /** - * Function execution timeout in seconds. - * - */ - val timeout: Long -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Function( - id = map["\$id"] as String, - execute = map["execute"] as String, - name = map["name"] as String, - dateCreated = map["dateCreated"] as Long, - dateUpdated = map["dateUpdated"] as Long, - status = map["status"] as String, - runtime = map["runtime"] as String, - tag = map["tag"] as String, - vars = map["vars"] as String, - events = map["events"] as List, - schedule = map["schedule"] as String, - scheduleNext = map["scheduleNext"] as Long, - schedulePrevious = map["schedulePrevious"] as Long, - timeout = map["timeout"] as Long - ) - } - - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "execute" to execute as Any, - "name" to name as Any, - "dateCreated" to dateCreated as Any, - "dateUpdated" to dateUpdated as Any, - "status" to status as Any, - "runtime" to runtime as Any, - "tag" to tag as Any, - "vars" to vars as Any, - "events" to events as Any, - "schedule" to schedule as Any, - "scheduleNext" to scheduleNext as Any, - "schedulePrevious" to schedulePrevious as Any, - "timeout" to timeout as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Index.kt b/library/src/main/java/io/appwrite/models/Index.kt deleted file mode 100644 index 5173b20..0000000 --- a/library/src/main/java/io/appwrite/models/Index.kt +++ /dev/null @@ -1,55 +0,0 @@ -package io.appwrite.models - -/** - * Index - */ -data class Index( - /** - * Index Key. - * - */ - val key: String, - - /** - * Index type. - * - */ - val type: String, - - /** - * Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` - * - */ - val status: String, - - /** - * Index attributes. - * - */ - val attributes: List, - - /** - * Index orders. - * - */ - val orders: List -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Index( - key = map["key"] as String, - type = map["type"] as String, - status = map["status"] as String, - attributes = map["attributes"] as List, - orders = map["orders"] as List - ) - } - - fun toMap(): Map = mapOf( - "key" to key as Any, - "type" to type as Any, - "status" to status as Any, - "attributes" to attributes as Any, - "orders" to orders as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Runtime.kt b/library/src/main/java/io/appwrite/models/Runtime.kt deleted file mode 100644 index 664467c..0000000 --- a/library/src/main/java/io/appwrite/models/Runtime.kt +++ /dev/null @@ -1,71 +0,0 @@ -package io.appwrite.models - -/** - * Runtime - */ -data class Runtime( - /** - * Runtime ID. - * - */ - val id: String, - - /** - * Runtime Name. - * - */ - val name: String, - - /** - * Runtime version. - * - */ - val version: String, - - /** - * Base Docker image used to build the runtime. - * - */ - val base: String, - - /** - * Image name of Docker Hub. - * - */ - val image: String, - - /** - * Name of the logo image. - * - */ - val logo: String, - - /** - * List of supported architectures. - * - */ - val supports: List -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Runtime( - id = map["\$id"] as String, - name = map["name"] as String, - version = map["version"] as String, - base = map["base"] as String, - image = map["image"] as String, - logo = map["logo"] as String, - supports = map["supports"] as List - ) - } - - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "name" to name as Any, - "version" to version as Any, - "base" to base as Any, - "image" to image as Any, - "logo" to logo as Any, - "supports" to supports as Any - ) -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Tag.kt b/library/src/main/java/io/appwrite/models/Tag.kt deleted file mode 100644 index b2a69b9..0000000 --- a/library/src/main/java/io/appwrite/models/Tag.kt +++ /dev/null @@ -1,55 +0,0 @@ -package io.appwrite.models - -/** - * Tag - */ -data class Tag( - /** - * Tag ID. - * - */ - val id: String, - - /** - * Function ID. - * - */ - val functionId: String, - - /** - * The tag creation date in Unix timestamp. - * - */ - val dateCreated: Long, - - /** - * The entrypoint command in use to execute the tag code. - * - */ - val command: String, - - /** - * The code size in bytes. - * - */ - val size: String -) { - companion object { - @Suppress("UNCHECKED_CAST") - fun from(map: Map) = Tag( - id = map["\$id"] as String, - functionId = map["functionId"] as String, - dateCreated = map["dateCreated"] as Long, - command = map["command"] as String, - size = map["size"] as String - ) - } - - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "functionId" to functionId as Any, - "dateCreated" to dateCreated as Any, - "command" to command as Any, - "size" to size as Any - ) -} \ No newline at end of file From 092b318eb8f9686b2941611162e91c74e32ca07a Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Fri, 7 Jan 2022 13:14:32 +0545 Subject: [PATCH 021/118] revert gradle --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index be4a0fa..60022df 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { mavenCentral() } dependencies { - classpath "com.android.tools.build:gradle:7.0.3" + classpath "com.android.tools.build:gradle:4.2.0" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'io.github.gradle-nexus:publish-plugin:1.1.0' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 710f6bd..2dadb9d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Tue Jun 01 15:55:54 IST 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME From 67fe1d7ad92626257b8f407d96e099ed1a368c8f Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 21 Jan 2022 21:23:51 +1300 Subject: [PATCH 022/118] Fixes for number conversion and exceptions on Java 16+ --- README.md | 6 +++--- build.gradle | 2 +- .../java/account/update-magic-u-r-l-session.md | 2 +- .../kotlin/account/update-magic-u-r-l-session.md | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- library/src/main/java/io/appwrite/Client.kt | 11 ++++++++++- .../src/main/java/io/appwrite/models/ContinentList.kt | 2 +- .../src/main/java/io/appwrite/models/CountryList.kt | 2 +- library/src/main/java/io/appwrite/models/Currency.kt | 4 ++-- .../src/main/java/io/appwrite/models/CurrencyList.kt | 2 +- .../src/main/java/io/appwrite/models/DocumentList.kt | 2 +- library/src/main/java/io/appwrite/models/Execution.kt | 6 +++--- .../src/main/java/io/appwrite/models/ExecutionList.kt | 2 +- library/src/main/java/io/appwrite/models/File.kt | 4 ++-- library/src/main/java/io/appwrite/models/FileList.kt | 2 +- .../src/main/java/io/appwrite/models/LanguageList.kt | 2 +- library/src/main/java/io/appwrite/models/Log.kt | 2 +- library/src/main/java/io/appwrite/models/LogList.kt | 2 +- .../src/main/java/io/appwrite/models/Membership.kt | 4 ++-- .../main/java/io/appwrite/models/MembershipList.kt | 2 +- library/src/main/java/io/appwrite/models/PhoneList.kt | 2 +- library/src/main/java/io/appwrite/models/Session.kt | 2 +- .../src/main/java/io/appwrite/models/SessionList.kt | 2 +- library/src/main/java/io/appwrite/models/Team.kt | 4 ++-- library/src/main/java/io/appwrite/models/TeamList.kt | 2 +- library/src/main/java/io/appwrite/models/Token.kt | 2 +- library/src/main/java/io/appwrite/models/User.kt | 4 ++-- 27 files changed, 45 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 3dca835..5905436 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![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-0.12.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-0.12.1-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) @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:0.3.0") +implementation("io.appwrite:sdk-for-android:0.3.2") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 0.3.0 + 0.3.2 ``` diff --git a/build.gradle b/build.gradle index 60022df..751076f 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,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" - version "0.3.0" + version "0.3.2" repositories { maven { url "https://plugins.gradle.org/m2/" } google() 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 f8375b9..d0734e1 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 @@ -19,7 +19,7 @@ public class MainActivity extends AppCompatActivity { Account account = new Account(client); account.updateMagicURLSession( - "", + "[USER_ID]", "[SECRET]" new Continuation() { @NotNull 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 923574e..3fe1b7c 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 @@ -18,7 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = account.updateMagicURLSession( - userId = "", + userId = "[USER_ID]", secret = "[SECRET]" ) val json = response.body?.string() diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 710f6bd..2dadb9d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Tue Jun 01 15:55:54 IST 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 352294d..312dddd 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -347,8 +347,17 @@ class Client @JvmOverloads constructor( .charStream() .buffered() .use(BufferedReader::readText) + val error = if (response.headers["content-type"]?.contains("application/json") == true) { - body.fromJson() + val map = gson.fromJson>( + body, + object : TypeToken>(){}.type + ) + AppwriteException( + map["message"] as? String ?: "", + (map["code"] as Number).toInt(), + body + ) } else { AppwriteException(body, response.code) } diff --git a/library/src/main/java/io/appwrite/models/ContinentList.kt b/library/src/main/java/io/appwrite/models/ContinentList.kt index 9b076c4..5ec4a01 100644 --- a/library/src/main/java/io/appwrite/models/ContinentList.kt +++ b/library/src/main/java/io/appwrite/models/ContinentList.kt @@ -19,7 +19,7 @@ data class ContinentList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = ContinentList( - sum = map["sum"] as Long, + sum = (map["sum"] as Number).toLong(), continents = (map["continents"] as List>).map { Continent.from(map = it) } ) } diff --git a/library/src/main/java/io/appwrite/models/CountryList.kt b/library/src/main/java/io/appwrite/models/CountryList.kt index a1476a1..fe9b804 100644 --- a/library/src/main/java/io/appwrite/models/CountryList.kt +++ b/library/src/main/java/io/appwrite/models/CountryList.kt @@ -19,7 +19,7 @@ data class CountryList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = CountryList( - sum = map["sum"] as Long, + sum = (map["sum"] as Number).toLong(), countries = (map["countries"] as List>).map { Country.from(map = it) } ) } diff --git a/library/src/main/java/io/appwrite/models/Currency.kt b/library/src/main/java/io/appwrite/models/Currency.kt index 58002c2..a35a7d6 100644 --- a/library/src/main/java/io/appwrite/models/Currency.kt +++ b/library/src/main/java/io/appwrite/models/Currency.kt @@ -52,8 +52,8 @@ data class Currency( symbol = map["symbol"] as String, name = map["name"] as String, symbolNative = map["symbolNative"] as String, - decimalDigits = map["decimalDigits"] as Long, - rounding = map["rounding"] as Double, + decimalDigits = (map["decimalDigits"] as Number).toLong(), + rounding = (map["rounding"] as Number).toDouble(), code = map["code"] as String, namePlural = map["namePlural"] as String ) diff --git a/library/src/main/java/io/appwrite/models/CurrencyList.kt b/library/src/main/java/io/appwrite/models/CurrencyList.kt index d2863d9..c50f951 100644 --- a/library/src/main/java/io/appwrite/models/CurrencyList.kt +++ b/library/src/main/java/io/appwrite/models/CurrencyList.kt @@ -19,7 +19,7 @@ data class CurrencyList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = CurrencyList( - sum = map["sum"] as Long, + sum = (map["sum"] as Number).toLong(), currencies = (map["currencies"] as List>).map { Currency.from(map = it) } ) } diff --git a/library/src/main/java/io/appwrite/models/DocumentList.kt b/library/src/main/java/io/appwrite/models/DocumentList.kt index c05899f..eab362f 100644 --- a/library/src/main/java/io/appwrite/models/DocumentList.kt +++ b/library/src/main/java/io/appwrite/models/DocumentList.kt @@ -19,7 +19,7 @@ data class DocumentList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = DocumentList( - sum = map["sum"] as Long, + sum = (map["sum"] as Number).toLong(), documents = (map["documents"] as List>).map { Document.from(map = it) } ) } diff --git a/library/src/main/java/io/appwrite/models/Execution.kt b/library/src/main/java/io/appwrite/models/Execution.kt index 2d25a73..52537f9 100644 --- a/library/src/main/java/io/appwrite/models/Execution.kt +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -70,13 +70,13 @@ data class Execution( id = map["\$id"] as String, read = map["\$read"] as List, functionId = map["functionId"] as String, - dateCreated = map["dateCreated"] as Long, + dateCreated = (map["dateCreated"] as Number).toLong(), trigger = map["trigger"] as String, status = map["status"] as String, - exitCode = map["exitCode"] as Long, + exitCode = (map["exitCode"] as Number).toLong(), stdout = map["stdout"] as String, stderr = map["stderr"] as String, - time = map["time"] as Double + time = (map["time"] as Number).toDouble() ) } diff --git a/library/src/main/java/io/appwrite/models/ExecutionList.kt b/library/src/main/java/io/appwrite/models/ExecutionList.kt index 5ab06b7..597324e 100644 --- a/library/src/main/java/io/appwrite/models/ExecutionList.kt +++ b/library/src/main/java/io/appwrite/models/ExecutionList.kt @@ -19,7 +19,7 @@ data class ExecutionList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = ExecutionList( - sum = map["sum"] as Long, + sum = (map["sum"] as Number).toLong(), executions = (map["executions"] as List>).map { Execution.from(map = it) } ) } diff --git a/library/src/main/java/io/appwrite/models/File.kt b/library/src/main/java/io/appwrite/models/File.kt index 1546c61..ef3aade 100644 --- a/library/src/main/java/io/appwrite/models/File.kt +++ b/library/src/main/java/io/appwrite/models/File.kt @@ -59,10 +59,10 @@ data class File( read = map["\$read"] as List, write = map["\$write"] as List, name = map["name"] as String, - dateCreated = map["dateCreated"] as Long, + dateCreated = (map["dateCreated"] as Number).toLong(), signature = map["signature"] as String, mimeType = map["mimeType"] as String, - sizeOriginal = map["sizeOriginal"] as Long + sizeOriginal = (map["sizeOriginal"] as Number).toLong() ) } diff --git a/library/src/main/java/io/appwrite/models/FileList.kt b/library/src/main/java/io/appwrite/models/FileList.kt index 4c9cf1c..9160ac0 100644 --- a/library/src/main/java/io/appwrite/models/FileList.kt +++ b/library/src/main/java/io/appwrite/models/FileList.kt @@ -19,7 +19,7 @@ data class FileList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = FileList( - sum = map["sum"] as Long, + sum = (map["sum"] as Number).toLong(), files = (map["files"] as List>).map { File.from(map = it) } ) } diff --git a/library/src/main/java/io/appwrite/models/LanguageList.kt b/library/src/main/java/io/appwrite/models/LanguageList.kt index 813c99b..4346157 100644 --- a/library/src/main/java/io/appwrite/models/LanguageList.kt +++ b/library/src/main/java/io/appwrite/models/LanguageList.kt @@ -19,7 +19,7 @@ data class LanguageList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = LanguageList( - sum = map["sum"] as Long, + sum = (map["sum"] as Number).toLong(), languages = (map["languages"] as List>).map { Language.from(map = it) } ) } diff --git a/library/src/main/java/io/appwrite/models/Log.kt b/library/src/main/java/io/appwrite/models/Log.kt index 05a0786..87e2114 100644 --- a/library/src/main/java/io/appwrite/models/Log.kt +++ b/library/src/main/java/io/appwrite/models/Log.kt @@ -139,7 +139,7 @@ data class Log( userName = map["userName"] as String, mode = map["mode"] as String, ip = map["ip"] as String, - time = map["time"] as Long, + time = (map["time"] as Number).toLong(), osCode = map["osCode"] as String, osName = map["osName"] as String, osVersion = map["osVersion"] as String, diff --git a/library/src/main/java/io/appwrite/models/LogList.kt b/library/src/main/java/io/appwrite/models/LogList.kt index a6bbd4a..7fb5178 100644 --- a/library/src/main/java/io/appwrite/models/LogList.kt +++ b/library/src/main/java/io/appwrite/models/LogList.kt @@ -19,7 +19,7 @@ data class LogList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = LogList( - sum = map["sum"] as Long, + sum = (map["sum"] as Number).toLong(), logs = (map["logs"] as List>).map { Log.from(map = it) } ) } diff --git a/library/src/main/java/io/appwrite/models/Membership.kt b/library/src/main/java/io/appwrite/models/Membership.kt index 9e0266f..5375520 100644 --- a/library/src/main/java/io/appwrite/models/Membership.kt +++ b/library/src/main/java/io/appwrite/models/Membership.kt @@ -66,8 +66,8 @@ data class Membership( teamId = map["teamId"] as String, name = map["name"] as String, email = map["email"] as String, - invited = map["invited"] as Long, - joined = map["joined"] as Long, + invited = (map["invited"] as Number).toLong(), + joined = (map["joined"] as Number).toLong(), confirm = map["confirm"] as Boolean, roles = map["roles"] as List ) diff --git a/library/src/main/java/io/appwrite/models/MembershipList.kt b/library/src/main/java/io/appwrite/models/MembershipList.kt index 3935263..66563d8 100644 --- a/library/src/main/java/io/appwrite/models/MembershipList.kt +++ b/library/src/main/java/io/appwrite/models/MembershipList.kt @@ -19,7 +19,7 @@ data class MembershipList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = MembershipList( - sum = map["sum"] as Long, + sum = (map["sum"] as Number).toLong(), memberships = (map["memberships"] as List>).map { Membership.from(map = it) } ) } diff --git a/library/src/main/java/io/appwrite/models/PhoneList.kt b/library/src/main/java/io/appwrite/models/PhoneList.kt index a7b92d0..4331302 100644 --- a/library/src/main/java/io/appwrite/models/PhoneList.kt +++ b/library/src/main/java/io/appwrite/models/PhoneList.kt @@ -19,7 +19,7 @@ data class PhoneList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = PhoneList( - sum = map["sum"] as Long, + sum = (map["sum"] as Number).toLong(), phones = (map["phones"] as List>).map { Phone.from(map = it) } ) } diff --git a/library/src/main/java/io/appwrite/models/Session.kt b/library/src/main/java/io/appwrite/models/Session.kt index fa8a91f..6b5847b 100644 --- a/library/src/main/java/io/appwrite/models/Session.kt +++ b/library/src/main/java/io/appwrite/models/Session.kt @@ -141,7 +141,7 @@ data class Session( fun from(map: Map) = Session( id = map["\$id"] as String, userId = map["userId"] as String, - expire = map["expire"] as Long, + expire = (map["expire"] as Number).toLong(), provider = map["provider"] as String, providerUid = map["providerUid"] as String, providerToken = map["providerToken"] as String, diff --git a/library/src/main/java/io/appwrite/models/SessionList.kt b/library/src/main/java/io/appwrite/models/SessionList.kt index 655701d..2cf2df3 100644 --- a/library/src/main/java/io/appwrite/models/SessionList.kt +++ b/library/src/main/java/io/appwrite/models/SessionList.kt @@ -19,7 +19,7 @@ data class SessionList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = SessionList( - sum = map["sum"] as Long, + sum = (map["sum"] as Number).toLong(), sessions = (map["sessions"] as List>).map { Session.from(map = it) } ) } diff --git a/library/src/main/java/io/appwrite/models/Team.kt b/library/src/main/java/io/appwrite/models/Team.kt index 414886a..895791c 100644 --- a/library/src/main/java/io/appwrite/models/Team.kt +++ b/library/src/main/java/io/appwrite/models/Team.kt @@ -33,8 +33,8 @@ data class Team( fun from(map: Map) = Team( id = map["\$id"] as String, name = map["name"] as String, - dateCreated = map["dateCreated"] as Long, - sum = map["sum"] as Long + dateCreated = (map["dateCreated"] as Number).toLong(), + sum = (map["sum"] as Number).toLong() ) } diff --git a/library/src/main/java/io/appwrite/models/TeamList.kt b/library/src/main/java/io/appwrite/models/TeamList.kt index 3adca8d..db88ac3 100644 --- a/library/src/main/java/io/appwrite/models/TeamList.kt +++ b/library/src/main/java/io/appwrite/models/TeamList.kt @@ -19,7 +19,7 @@ data class TeamList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = TeamList( - sum = map["sum"] as Long, + sum = (map["sum"] as Number).toLong(), teams = (map["teams"] as List>).map { Team.from(map = it) } ) } diff --git a/library/src/main/java/io/appwrite/models/Token.kt b/library/src/main/java/io/appwrite/models/Token.kt index 5041d1a..c11cf3b 100644 --- a/library/src/main/java/io/appwrite/models/Token.kt +++ b/library/src/main/java/io/appwrite/models/Token.kt @@ -34,7 +34,7 @@ data class Token( id = map["\$id"] as String, userId = map["userId"] as String, secret = map["secret"] as String, - expire = map["expire"] as Long + expire = (map["expire"] as Number).toLong() ) } diff --git a/library/src/main/java/io/appwrite/models/User.kt b/library/src/main/java/io/appwrite/models/User.kt index 0af27cc..e852703 100644 --- a/library/src/main/java/io/appwrite/models/User.kt +++ b/library/src/main/java/io/appwrite/models/User.kt @@ -57,9 +57,9 @@ data class User( fun from(map: Map) = User( id = map["\$id"] as String, name = map["name"] as String, - registration = map["registration"] as Long, + registration = (map["registration"] as Number).toLong(), status = map["status"] as Boolean, - passwordUpdate = map["passwordUpdate"] as Long, + passwordUpdate = (map["passwordUpdate"] as Number).toLong(), email = map["email"] as String, emailVerification = map["emailVerification"] as Boolean, prefs = Preferences.from(map = map["prefs"] as Map) From 17c7a4b5542481af511c17c8a653e4d634234759 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 21 Jan 2022 21:24:33 +1300 Subject: [PATCH 023/118] Add snapshot tag --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 751076f..48f98e9 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,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" - version "0.3.2" + version "0.3.2-SNAPSHOT" repositories { maven { url "https://plugins.gradle.org/m2/" } google() From 7c78fa58bdc97b913a959d6f326874423855f739 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 25 Jan 2022 23:24:16 +1300 Subject: [PATCH 024/118] Update generated SDK --- build.gradle | 2 +- library/src/main/java/io/appwrite/services/Account.kt | 5 +++-- library/src/main/java/io/appwrite/services/Database.kt | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 48f98e9..751076f 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,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" - version "0.3.2-SNAPSHOT" + version "0.3.2" repositories { maven { url "https://plugins.gradle.org/m2/" } google() diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 17344c4..2c1b6a1 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -335,8 +335,9 @@ class Account(client: Client) : Service(client) { /** * Update Account Preferences * - * Update currently logged in user account preferences. You can pass only the - * specific settings you wish to update. + * 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.User] diff --git a/library/src/main/java/io/appwrite/services/Database.kt b/library/src/main/java/io/appwrite/services/Database.kt index 9e7a077..7b43505 100644 --- a/library/src/main/java/io/appwrite/services/Database.kt +++ b/library/src/main/java/io/appwrite/services/Database.kt @@ -74,7 +74,7 @@ class Database(client: Client) : Service(client) { * integration](/docs/server/database#databaseCreateCollection) API or * directly from your database console. * - * @param collectionId Collection ID. You can create a new collection with validation rules using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). + * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). 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 data Document data as JSON object. * @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. @@ -154,7 +154,7 @@ class Database(client: Client) : Service(client) { * Update a document by its unique ID. Using the patch method you can pass * only specific fields that will get updated. * - * @param collectionId Collection ID. You can create a new collection with validation rules using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). + * @param collectionId Collection ID. * @param documentId Document ID. * @param data Document data as JSON object. * @param read An array of strings with read permissions. By default inherits the existing read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. From 63f3795214590ace57917eceaa812b6550838c3d Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 27 Jan 2022 23:18:57 +1300 Subject: [PATCH 025/118] Add serialized names to fix deserializing with realtime `payloadType` --- README.md | 6 ++--- build.gradle | 2 +- .../main/java/io/appwrite/models/Continent.kt | 4 ++++ .../java/io/appwrite/models/ContinentList.kt | 4 ++++ .../main/java/io/appwrite/models/Country.kt | 4 ++++ .../java/io/appwrite/models/CountryList.kt | 4 ++++ .../main/java/io/appwrite/models/Currency.kt | 9 +++++++ .../java/io/appwrite/models/CurrencyList.kt | 4 ++++ .../main/java/io/appwrite/models/Document.kt | 6 +++++ .../java/io/appwrite/models/DocumentList.kt | 4 ++++ .../main/java/io/appwrite/models/Execution.kt | 12 ++++++++++ .../java/io/appwrite/models/ExecutionList.kt | 4 ++++ .../src/main/java/io/appwrite/models/File.kt | 10 ++++++++ .../main/java/io/appwrite/models/FileList.kt | 4 ++++ .../src/main/java/io/appwrite/models/Jwt.kt | 3 +++ .../main/java/io/appwrite/models/Language.kt | 5 ++++ .../java/io/appwrite/models/LanguageList.kt | 4 ++++ .../main/java/io/appwrite/models/Locale.kt | 9 +++++++ .../src/main/java/io/appwrite/models/Log.kt | 23 ++++++++++++++++++ .../main/java/io/appwrite/models/LogList.kt | 4 ++++ .../java/io/appwrite/models/Membership.kt | 11 +++++++++ .../java/io/appwrite/models/MembershipList.kt | 4 ++++ .../src/main/java/io/appwrite/models/Phone.kt | 5 ++++ .../main/java/io/appwrite/models/PhoneList.kt | 4 ++++ .../java/io/appwrite/models/Preferences.kt | 2 ++ .../main/java/io/appwrite/models/Session.kt | 24 +++++++++++++++++++ .../java/io/appwrite/models/SessionList.kt | 4 ++++ .../src/main/java/io/appwrite/models/Team.kt | 6 +++++ .../main/java/io/appwrite/models/TeamList.kt | 4 ++++ .../src/main/java/io/appwrite/models/Token.kt | 6 +++++ .../src/main/java/io/appwrite/models/User.kt | 10 ++++++++ 31 files changed, 201 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5905436..6656d46 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:0.3.2") +implementation("io.appwrite:sdk-for-android:0.3.3") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 0.3.2 + 0.3.3 ``` @@ -158,4 +158,4 @@ This library is auto-generated by Appwrite custom [SDK Generator](https://github ## License -Please see the [BSD-3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information. \ No newline at end of file +Please see the [BSD-3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information. diff --git a/build.gradle b/build.gradle index 751076f..42d442d 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,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" - version "0.3.2" + version "0.3.3" repositories { maven { url "https://plugins.gradle.org/m2/" } google() diff --git a/library/src/main/java/io/appwrite/models/Continent.kt b/library/src/main/java/io/appwrite/models/Continent.kt index da6eca6..ba8b5ae 100644 --- a/library/src/main/java/io/appwrite/models/Continent.kt +++ b/library/src/main/java/io/appwrite/models/Continent.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Continent */ @@ -8,12 +10,14 @@ data class Continent( * Continent name. * */ + @SerializedName("name") val name: String, /** * Continent two letter code. * */ + @SerializedName("code") val code: String ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/ContinentList.kt b/library/src/main/java/io/appwrite/models/ContinentList.kt index 5ec4a01..0e7a052 100644 --- a/library/src/main/java/io/appwrite/models/ContinentList.kt +++ b/library/src/main/java/io/appwrite/models/ContinentList.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Continents List */ @@ -8,12 +10,14 @@ data class ContinentList( * Total number of items available on the server. * */ + @SerializedName("sum") val sum: Long, /** * List of continents. * */ + @SerializedName("continents") val continents: List ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/Country.kt b/library/src/main/java/io/appwrite/models/Country.kt index 8c1d608..51fee8f 100644 --- a/library/src/main/java/io/appwrite/models/Country.kt +++ b/library/src/main/java/io/appwrite/models/Country.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Country */ @@ -8,12 +10,14 @@ data class Country( * Country name. * */ + @SerializedName("name") val name: String, /** * Country two-character ISO 3166-1 alpha code. * */ + @SerializedName("code") val code: String ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/CountryList.kt b/library/src/main/java/io/appwrite/models/CountryList.kt index fe9b804..7cbb9b4 100644 --- a/library/src/main/java/io/appwrite/models/CountryList.kt +++ b/library/src/main/java/io/appwrite/models/CountryList.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Countries List */ @@ -8,12 +10,14 @@ data class CountryList( * Total number of items available on the server. * */ + @SerializedName("sum") val sum: Long, /** * List of countries. * */ + @SerializedName("countries") val countries: List ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/Currency.kt b/library/src/main/java/io/appwrite/models/Currency.kt index a35a7d6..df6e230 100644 --- a/library/src/main/java/io/appwrite/models/Currency.kt +++ b/library/src/main/java/io/appwrite/models/Currency.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Currency */ @@ -8,42 +10,49 @@ 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 ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/CurrencyList.kt b/library/src/main/java/io/appwrite/models/CurrencyList.kt index c50f951..a311340 100644 --- a/library/src/main/java/io/appwrite/models/CurrencyList.kt +++ b/library/src/main/java/io/appwrite/models/CurrencyList.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Currencies List */ @@ -8,12 +10,14 @@ data class CurrencyList( * Total number of items available on the server. * */ + @SerializedName("sum") val sum: Long, /** * List of currencies. * */ + @SerializedName("currencies") val currencies: List ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/Document.kt b/library/src/main/java/io/appwrite/models/Document.kt index f443676..a83a844 100644 --- a/library/src/main/java/io/appwrite/models/Document.kt +++ b/library/src/main/java/io/appwrite/models/Document.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Document */ @@ -8,24 +10,28 @@ data class Document( * Document ID. * */ + @SerializedName("\$id") val id: String, /** * Collection ID. * */ + @SerializedName("\$collection") val collection: String, /** * Document read permissions. * */ + @SerializedName("\$read") val read: List, /** * Document write permissions. * */ + @SerializedName("\$write") val write: List, val data: Map diff --git a/library/src/main/java/io/appwrite/models/DocumentList.kt b/library/src/main/java/io/appwrite/models/DocumentList.kt index eab362f..1807253 100644 --- a/library/src/main/java/io/appwrite/models/DocumentList.kt +++ b/library/src/main/java/io/appwrite/models/DocumentList.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Documents List */ @@ -8,12 +10,14 @@ data class DocumentList( * Total number of items available on the server. * */ + @SerializedName("sum") val sum: Long, /** * List of documents. * */ + @SerializedName("documents") val documents: List ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/Execution.kt b/library/src/main/java/io/appwrite/models/Execution.kt index 52537f9..f03925d 100644 --- a/library/src/main/java/io/appwrite/models/Execution.kt +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Execution */ @@ -8,60 +10,70 @@ data class Execution( * Execution ID. * */ + @SerializedName("\$id") val id: String, /** * Execution read permissions. * */ + @SerializedName("\$read") val read: List, /** * Function ID. * */ + @SerializedName("functionId") val functionId: String, /** * The execution creation date in Unix timestamp. * */ + @SerializedName("dateCreated") val dateCreated: Long, /** * 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 exit code. * */ + @SerializedName("exitCode") val exitCode: Long, /** * The script stdout output string. Logs the last 4,000 characters of the execution stdout output. * */ + @SerializedName("stdout") val stdout: String, /** * The script stderr output string. Logs the last 4,000 characters of the execution stderr output * */ + @SerializedName("stderr") val stderr: String, /** * The script execution time in seconds. * */ + @SerializedName("time") val time: Double ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/ExecutionList.kt b/library/src/main/java/io/appwrite/models/ExecutionList.kt index 597324e..c771f57 100644 --- a/library/src/main/java/io/appwrite/models/ExecutionList.kt +++ b/library/src/main/java/io/appwrite/models/ExecutionList.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Executions List */ @@ -8,12 +10,14 @@ data class ExecutionList( * Total number of items available on the server. * */ + @SerializedName("sum") val sum: Long, /** * List of executions. * */ + @SerializedName("executions") val executions: List ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/File.kt b/library/src/main/java/io/appwrite/models/File.kt index ef3aade..1f9e734 100644 --- a/library/src/main/java/io/appwrite/models/File.kt +++ b/library/src/main/java/io/appwrite/models/File.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * File */ @@ -8,48 +10,56 @@ data class File( * File ID. * */ + @SerializedName("\$id") val id: String, /** * File read permissions. * */ + @SerializedName("\$read") val read: List, /** * File write permissions. * */ + @SerializedName("\$write") val write: List, /** * File name. * */ + @SerializedName("name") val name: String, /** * File creation date in Unix timestamp. * */ + @SerializedName("dateCreated") val dateCreated: Long, /** * 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 ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/FileList.kt b/library/src/main/java/io/appwrite/models/FileList.kt index 9160ac0..d000dfc 100644 --- a/library/src/main/java/io/appwrite/models/FileList.kt +++ b/library/src/main/java/io/appwrite/models/FileList.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Files List */ @@ -8,12 +10,14 @@ data class FileList( * Total number of items available on the server. * */ + @SerializedName("sum") val sum: Long, /** * List of files. * */ + @SerializedName("files") val files: List ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/Jwt.kt b/library/src/main/java/io/appwrite/models/Jwt.kt index 4012643..c871237 100644 --- a/library/src/main/java/io/appwrite/models/Jwt.kt +++ b/library/src/main/java/io/appwrite/models/Jwt.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * JWT */ @@ -8,6 +10,7 @@ data class Jwt( * JWT encoded string. * */ + @SerializedName("jwt") val jwt: String ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/Language.kt b/library/src/main/java/io/appwrite/models/Language.kt index 0f050a8..045202f 100644 --- a/library/src/main/java/io/appwrite/models/Language.kt +++ b/library/src/main/java/io/appwrite/models/Language.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Language */ @@ -8,18 +10,21 @@ 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 ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/LanguageList.kt b/library/src/main/java/io/appwrite/models/LanguageList.kt index 4346157..6c688a6 100644 --- a/library/src/main/java/io/appwrite/models/LanguageList.kt +++ b/library/src/main/java/io/appwrite/models/LanguageList.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Languages List */ @@ -8,12 +10,14 @@ data class LanguageList( * Total number of items available on the server. * */ + @SerializedName("sum") val sum: Long, /** * List of languages. * */ + @SerializedName("languages") val languages: List ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/Locale.kt b/library/src/main/java/io/appwrite/models/Locale.kt index 6e812c5..d8d3fcf 100644 --- a/library/src/main/java/io/appwrite/models/Locale.kt +++ b/library/src/main/java/io/appwrite/models/Locale.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Locale */ @@ -8,42 +10,49 @@ 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 ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/Log.kt b/library/src/main/java/io/appwrite/models/Log.kt index 87e2114..fb4de88 100644 --- a/library/src/main/java/io/appwrite/models/Log.kt +++ b/library/src/main/java/io/appwrite/models/Log.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Log */ @@ -8,126 +10,147 @@ 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 time in Unix timestamp. * */ + @SerializedName("time") val time: Long, /** * 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 ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/LogList.kt b/library/src/main/java/io/appwrite/models/LogList.kt index 7fb5178..d6666cf 100644 --- a/library/src/main/java/io/appwrite/models/LogList.kt +++ b/library/src/main/java/io/appwrite/models/LogList.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Logs List */ @@ -8,12 +10,14 @@ data class LogList( * Total number of items available on the server. * */ + @SerializedName("sum") val sum: Long, /** * List of logs. * */ + @SerializedName("logs") val logs: List ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/Membership.kt b/library/src/main/java/io/appwrite/models/Membership.kt index 5375520..45b42c8 100644 --- a/library/src/main/java/io/appwrite/models/Membership.kt +++ b/library/src/main/java/io/appwrite/models/Membership.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Membership */ @@ -8,54 +10,63 @@ data class Membership( * Membership ID. * */ + @SerializedName("\$id") val id: String, /** * User ID. * */ + @SerializedName("userId") val userId: String, /** * Team ID. * */ + @SerializedName("teamId") val teamId: String, /** * User name. * */ + @SerializedName("name") val name: String, /** * User email address. * */ + @SerializedName("email") val email: String, /** * Date, the user has been invited to join the team in Unix timestamp. * */ + @SerializedName("invited") val invited: Long, /** * Date, the user has accepted the invitation to join the team in Unix timestamp. * */ + @SerializedName("joined") val joined: Long, /** * 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 ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/MembershipList.kt b/library/src/main/java/io/appwrite/models/MembershipList.kt index 66563d8..3171fae 100644 --- a/library/src/main/java/io/appwrite/models/MembershipList.kt +++ b/library/src/main/java/io/appwrite/models/MembershipList.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Memberships List */ @@ -8,12 +10,14 @@ data class MembershipList( * Total number of items available on the server. * */ + @SerializedName("sum") val sum: Long, /** * List of memberships. * */ + @SerializedName("memberships") val memberships: List ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/Phone.kt b/library/src/main/java/io/appwrite/models/Phone.kt index a11de9d..bfa3113 100644 --- a/library/src/main/java/io/appwrite/models/Phone.kt +++ b/library/src/main/java/io/appwrite/models/Phone.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Phone */ @@ -8,18 +10,21 @@ 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 ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/PhoneList.kt b/library/src/main/java/io/appwrite/models/PhoneList.kt index 4331302..d9338cb 100644 --- a/library/src/main/java/io/appwrite/models/PhoneList.kt +++ b/library/src/main/java/io/appwrite/models/PhoneList.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Phones List */ @@ -8,12 +10,14 @@ data class PhoneList( * Total number of items available on the server. * */ + @SerializedName("sum") val sum: Long, /** * List of phones. * */ + @SerializedName("phones") val phones: List ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/Preferences.kt b/library/src/main/java/io/appwrite/models/Preferences.kt index a95850f..0b11e85 100644 --- a/library/src/main/java/io/appwrite/models/Preferences.kt +++ b/library/src/main/java/io/appwrite/models/Preferences.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Preferences */ diff --git a/library/src/main/java/io/appwrite/models/Session.kt b/library/src/main/java/io/appwrite/models/Session.kt index 6b5847b..1ee5187 100644 --- a/library/src/main/java/io/appwrite/models/Session.kt +++ b/library/src/main/java/io/appwrite/models/Session.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Session */ @@ -8,132 +10,154 @@ data class Session( * Session ID. * */ + @SerializedName("\$id") val id: String, /** * User ID. * */ + @SerializedName("userId") val userId: String, /** * Session expiration date in Unix timestamp. * */ + @SerializedName("expire") val expire: Long, /** * Session Provider. * */ + @SerializedName("provider") val provider: String, /** * Session Provider User ID. * */ + @SerializedName("providerUid") val providerUid: String, /** * Session Provider Token. * */ + @SerializedName("providerToken") val providerToken: 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 ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/SessionList.kt b/library/src/main/java/io/appwrite/models/SessionList.kt index 2cf2df3..2d6a4bd 100644 --- a/library/src/main/java/io/appwrite/models/SessionList.kt +++ b/library/src/main/java/io/appwrite/models/SessionList.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Sessions List */ @@ -8,12 +10,14 @@ data class SessionList( * Total number of items available on the server. * */ + @SerializedName("sum") val sum: Long, /** * List of sessions. * */ + @SerializedName("sessions") val sessions: List ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/Team.kt b/library/src/main/java/io/appwrite/models/Team.kt index 895791c..d0eda4e 100644 --- a/library/src/main/java/io/appwrite/models/Team.kt +++ b/library/src/main/java/io/appwrite/models/Team.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Team */ @@ -8,24 +10,28 @@ data class Team( * Team ID. * */ + @SerializedName("\$id") val id: String, /** * Team name. * */ + @SerializedName("name") val name: String, /** * Team creation date in Unix timestamp. * */ + @SerializedName("dateCreated") val dateCreated: Long, /** * Total sum of team members. * */ + @SerializedName("sum") val sum: Long ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/TeamList.kt b/library/src/main/java/io/appwrite/models/TeamList.kt index db88ac3..af63825 100644 --- a/library/src/main/java/io/appwrite/models/TeamList.kt +++ b/library/src/main/java/io/appwrite/models/TeamList.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Teams List */ @@ -8,12 +10,14 @@ data class TeamList( * Total number of items available on the server. * */ + @SerializedName("sum") val sum: Long, /** * List of teams. * */ + @SerializedName("teams") val teams: List ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/Token.kt b/library/src/main/java/io/appwrite/models/Token.kt index c11cf3b..d555f45 100644 --- a/library/src/main/java/io/appwrite/models/Token.kt +++ b/library/src/main/java/io/appwrite/models/Token.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Token */ @@ -8,24 +10,28 @@ data class Token( * Token ID. * */ + @SerializedName("\$id") val id: 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 Unix timestamp. * */ + @SerializedName("expire") val expire: Long ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/User.kt b/library/src/main/java/io/appwrite/models/User.kt index e852703..032391e 100644 --- a/library/src/main/java/io/appwrite/models/User.kt +++ b/library/src/main/java/io/appwrite/models/User.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * User */ @@ -8,48 +10,56 @@ data class User( * User ID. * */ + @SerializedName("\$id") val id: String, /** * User name. * */ + @SerializedName("name") val name: String, /** * User registration date in Unix timestamp. * */ + @SerializedName("registration") val registration: Long, /** * User status. Pass `true` for enabled and `false` for disabled. * */ + @SerializedName("status") val status: Boolean, /** * Unix timestamp of the most recent password update * */ + @SerializedName("passwordUpdate") val passwordUpdate: Long, /** * User email address. * */ + @SerializedName("email") val email: String, /** * Email verification status. * */ + @SerializedName("emailVerification") val emailVerification: Boolean, /** * User preferences as a key-value object * */ + @SerializedName("prefs") val prefs: Preferences ) { companion object { From 5b9c43f8722b87cca302cd5bdfd3b66c463fcdf2 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 2 Mar 2022 12:23:43 +0100 Subject: [PATCH 026/118] feat: support for 0.13.0 --- README.md | 6 +- build.gradle | 2 +- docs/examples/java/account/update-session.md | 48 +++++ docs/examples/java/functions/retry-build.md | 50 ++++++ docs/examples/java/storage/create-file.md | 1 + docs/examples/java/storage/delete-file.md | 1 + .../java/storage/get-file-download.md | 1 + .../examples/java/storage/get-file-preview.md | 1 + docs/examples/java/storage/get-file-view.md | 1 + docs/examples/java/storage/get-file.md | 1 + docs/examples/java/storage/list-files.md | 1 + docs/examples/java/storage/update-file.md | 3 +- .../examples/kotlin/account/update-session.md | 26 +++ docs/examples/kotlin/functions/retry-build.md | 28 +++ docs/examples/kotlin/storage/create-file.md | 1 + docs/examples/kotlin/storage/delete-file.md | 1 + .../kotlin/storage/get-file-download.md | 1 + .../kotlin/storage/get-file-preview.md | 1 + docs/examples/kotlin/storage/get-file-view.md | 1 + docs/examples/kotlin/storage/get-file.md | 1 + docs/examples/kotlin/storage/list-files.md | 1 + docs/examples/kotlin/storage/update-file.md | 3 +- library/build.gradle | 2 + library/src/main/java/io/appwrite/Client.kt | 98 +++++++++- .../appwrite/exceptions/AppwriteException.kt | 1 + .../java/io/appwrite/models/ContinentList.kt | 10 +- .../java/io/appwrite/models/CountryList.kt | 10 +- .../java/io/appwrite/models/CurrencyList.kt | 10 +- .../java/io/appwrite/models/DocumentList.kt | 10 +- .../main/java/io/appwrite/models/Execution.kt | 10 +- .../java/io/appwrite/models/ExecutionList.kt | 10 +- .../src/main/java/io/appwrite/models/File.kt | 33 +++- .../main/java/io/appwrite/models/FileList.kt | 10 +- .../java/io/appwrite/models/LanguageList.kt | 10 +- .../main/java/io/appwrite/models/LogList.kt | 10 +- .../java/io/appwrite/models/MembershipList.kt | 10 +- .../main/java/io/appwrite/models/PhoneList.kt | 10 +- .../java/io/appwrite/models/RealtimeModels.kt | 1 + .../main/java/io/appwrite/models/Session.kt | 28 ++- .../java/io/appwrite/models/SessionList.kt | 10 +- .../src/main/java/io/appwrite/models/Team.kt | 10 +- .../main/java/io/appwrite/models/TeamList.kt | 10 +- .../java/io/appwrite/models/UploadProgress.kt | 9 + .../main/java/io/appwrite/services/Account.kt | 167 +++++++++++------- .../main/java/io/appwrite/services/Avatars.kt | 14 +- .../java/io/appwrite/services/Database.kt | 30 ++-- .../java/io/appwrite/services/Functions.kt | 55 ++++-- .../main/java/io/appwrite/services/Locale.kt | 42 ++--- .../main/java/io/appwrite/services/Storage.kt | 108 +++++++---- .../main/java/io/appwrite/services/Teams.kt | 68 +++---- 50 files changed, 694 insertions(+), 282 deletions(-) create mode 100644 docs/examples/java/account/update-session.md create mode 100644 docs/examples/java/functions/retry-build.md create mode 100644 docs/examples/kotlin/account/update-session.md create mode 100644 docs/examples/kotlin/functions/retry-build.md create mode 100644 library/src/main/java/io/appwrite/models/UploadProgress.kt diff --git a/README.md b/README.md index 6656d46..8c463db 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-0.12.1-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-0.13.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 0.12.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).** +**This SDK is compatible with Appwrite server version 0.13.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) @@ -158,4 +158,4 @@ This library is auto-generated by Appwrite custom [SDK Generator](https://github ## License -Please see the [BSD-3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information. +Please see the [BSD-3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information. \ No newline at end of file diff --git a/build.gradle b/build.gradle index 42d442d..79f6b0b 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,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" - version "0.3.3" + version System.getenv("SDK_VERSION") repositories { maven { url "https://plugins.gradle.org/m2/" } google() diff --git a/docs/examples/java/account/update-session.md b/docs/examples/java/account/update-session.md new file mode 100644 index 0000000..80aff11 --- /dev/null +++ b/docs/examples/java/account/update-session.md @@ -0,0 +1,48 @@ +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.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 diff --git a/docs/examples/java/functions/retry-build.md b/docs/examples/java/functions/retry-build.md new file mode 100644 index 0000000..96501a0 --- /dev/null +++ b/docs/examples/java/functions/retry-build.md @@ -0,0 +1,50 @@ +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/storage/create-file.md b/docs/examples/java/storage/create-file.md index 420ca3c..bc1df1a 100644 --- a/docs/examples/java/storage/create-file.md +++ b/docs/examples/java/storage/create-file.md @@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity { Storage storage = new Storage(client); storage.createFile( + "[BUCKET_ID]", "[FILE_ID]", File("./path-to-files/image.jpg"), new Continuation() { diff --git a/docs/examples/java/storage/delete-file.md b/docs/examples/java/storage/delete-file.md index aafae2c..585593a 100644 --- a/docs/examples/java/storage/delete-file.md +++ b/docs/examples/java/storage/delete-file.md @@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity { Storage storage = new Storage(client); storage.deleteFile( + "[BUCKET_ID]", "[FILE_ID]" new Continuation() { @NotNull diff --git a/docs/examples/java/storage/get-file-download.md b/docs/examples/java/storage/get-file-download.md index d56f293..b162248 100644 --- a/docs/examples/java/storage/get-file-download.md +++ b/docs/examples/java/storage/get-file-download.md @@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity { Storage storage = new Storage(client); storage.getFileDownload( + "[BUCKET_ID]", "[FILE_ID]" new Continuation() { @NotNull diff --git a/docs/examples/java/storage/get-file-preview.md b/docs/examples/java/storage/get-file-preview.md index 00b54f2..583c1a0 100644 --- a/docs/examples/java/storage/get-file-preview.md +++ b/docs/examples/java/storage/get-file-preview.md @@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity { Storage storage = new Storage(client); storage.getFilePreview( + "[BUCKET_ID]", "[FILE_ID]", new Continuation() { @NotNull diff --git a/docs/examples/java/storage/get-file-view.md b/docs/examples/java/storage/get-file-view.md index 087a48b..21a5074 100644 --- a/docs/examples/java/storage/get-file-view.md +++ b/docs/examples/java/storage/get-file-view.md @@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity { Storage storage = new Storage(client); storage.getFileView( + "[BUCKET_ID]", "[FILE_ID]" new Continuation() { @NotNull diff --git a/docs/examples/java/storage/get-file.md b/docs/examples/java/storage/get-file.md index 9473cab..61740a9 100644 --- a/docs/examples/java/storage/get-file.md +++ b/docs/examples/java/storage/get-file.md @@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity { Storage storage = new Storage(client); storage.getFile( + "[BUCKET_ID]", "[FILE_ID]" new Continuation() { @NotNull diff --git a/docs/examples/java/storage/list-files.md b/docs/examples/java/storage/list-files.md index e2eab69..a7ea06e 100644 --- a/docs/examples/java/storage/list-files.md +++ b/docs/examples/java/storage/list-files.md @@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity { Storage storage = new Storage(client); storage.listFiles( + "[BUCKET_ID]", new Continuation() { @NotNull @Override diff --git a/docs/examples/java/storage/update-file.md b/docs/examples/java/storage/update-file.md index 1477615..b3e8e90 100644 --- a/docs/examples/java/storage/update-file.md +++ b/docs/examples/java/storage/update-file.md @@ -19,9 +19,8 @@ public class MainActivity extends AppCompatActivity { Storage storage = new Storage(client); storage.updateFile( + "[BUCKET_ID]", "[FILE_ID]", - listOf(), - listOf() new Continuation() { @NotNull @Override diff --git a/docs/examples/kotlin/account/update-session.md b/docs/examples/kotlin/account/update-session.md new file mode 100644 index 0000000..465320d --- /dev/null +++ b/docs/examples/kotlin/account/update-session.md @@ -0,0 +1,26 @@ +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.updateSession( + sessionId = "[SESSION_ID]" + ) + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/functions/retry-build.md b/docs/examples/kotlin/functions/retry-build.md new file mode 100644 index 0000000..597421c --- /dev/null +++ b/docs/examples/kotlin/functions/retry-build.md @@ -0,0 +1,28 @@ +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/storage/create-file.md b/docs/examples/kotlin/storage/create-file.md index 1261bda..437bdeb 100644 --- a/docs/examples/kotlin/storage/create-file.md +++ b/docs/examples/kotlin/storage/create-file.md @@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = storage.createFile( + bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]", file = File("./path-to-files/image.jpg"), ) diff --git a/docs/examples/kotlin/storage/delete-file.md b/docs/examples/kotlin/storage/delete-file.md index f26acac..1a4a5b9 100644 --- a/docs/examples/kotlin/storage/delete-file.md +++ b/docs/examples/kotlin/storage/delete-file.md @@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = storage.deleteFile( + bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]" ) val json = response.body?.string() diff --git a/docs/examples/kotlin/storage/get-file-download.md b/docs/examples/kotlin/storage/get-file-download.md index b7d3d4a..3970fb8 100644 --- a/docs/examples/kotlin/storage/get-file-download.md +++ b/docs/examples/kotlin/storage/get-file-download.md @@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val result = storage.getFileDownload( + bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]" ) println(result); // Resource URL diff --git a/docs/examples/kotlin/storage/get-file-preview.md b/docs/examples/kotlin/storage/get-file-preview.md index 9f1d459..7804527 100644 --- a/docs/examples/kotlin/storage/get-file-preview.md +++ b/docs/examples/kotlin/storage/get-file-preview.md @@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val result = storage.getFilePreview( + bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]", ) println(result); // Resource URL diff --git a/docs/examples/kotlin/storage/get-file-view.md b/docs/examples/kotlin/storage/get-file-view.md index 0b4fe07..107ad45 100644 --- a/docs/examples/kotlin/storage/get-file-view.md +++ b/docs/examples/kotlin/storage/get-file-view.md @@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val result = storage.getFileView( + bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]" ) println(result); // Resource URL diff --git a/docs/examples/kotlin/storage/get-file.md b/docs/examples/kotlin/storage/get-file.md index b534d3b..30f640b 100644 --- a/docs/examples/kotlin/storage/get-file.md +++ b/docs/examples/kotlin/storage/get-file.md @@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = storage.getFile( + bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]" ) val json = response.body?.string() diff --git a/docs/examples/kotlin/storage/list-files.md b/docs/examples/kotlin/storage/list-files.md index 7d63837..20a253a 100644 --- a/docs/examples/kotlin/storage/list-files.md +++ b/docs/examples/kotlin/storage/list-files.md @@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = storage.listFiles( + bucketId = "[BUCKET_ID]", ) val json = response.body?.string() } diff --git a/docs/examples/kotlin/storage/update-file.md b/docs/examples/kotlin/storage/update-file.md index 31dfb38..35b1afb 100644 --- a/docs/examples/kotlin/storage/update-file.md +++ b/docs/examples/kotlin/storage/update-file.md @@ -18,9 +18,8 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = storage.updateFile( + bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]", - read = listOf(), - write = listOf() ) val json = response.body?.string() } diff --git a/library/build.gradle b/library/build.gradle index cb15537..ee98757 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -19,6 +19,8 @@ ext { GITHUB_SCM_CONNECTION = 'scm:git:git://github.com/appwrite/sdk-for-android.git' } +version PUBLISH_VERSION + android { compileSdkVersion(31) diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 312dddd..902fd7f 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -8,6 +8,7 @@ import io.appwrite.appwrite.BuildConfig import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.fromJson import io.appwrite.json.PreciseNumberAdapter +import io.appwrite.models.UploadProgress import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -42,6 +43,10 @@ class Client @JvmOverloads constructor( private var selfSigned: Boolean = false ) : CoroutineScope { + companion object { + const val CHUNK_SIZE = 5*1024*1024; // 5MB + } + override val coroutineContext: CoroutineContext get() = Dispatchers.Main + job @@ -79,7 +84,7 @@ class Client @JvmOverloads constructor( "origin" to "appwrite-android://${context.packageName}", "user-agent" to "${context.packageName}/${appVersion}, ${System.getProperty("http.agent")}", "x-sdk-version" to "appwrite:android:${BuildConfig.SDK_VERSION}", - "x-appwrite-response-format" to "0.12.0" + "x-appwrite-response-format" to "0.13.0" ) config = mutableMapOf() @@ -231,7 +236,7 @@ class Client @JvmOverloads constructor( * @param headers * @param params * - * @return [Response] + * @return [T] */ @Throws(AppwriteException::class) suspend fun call( @@ -285,8 +290,7 @@ class Client @JvmOverloads constructor( filteredParams.forEach { when { it.key == "file" -> { - val file = it.value as File - builder.addFormDataPart(it.key, file.name, file.asRequestBody()) + builder.addPart(it.value as MultipartBody.Part) } it.value is List<*> -> { val list = it.value as List<*> @@ -317,6 +321,89 @@ class Client @JvmOverloads constructor( return awaitResponse(request, responseType, convert) } + /** + * Upload a file in chunks + * + * @param path + * @param headers + * @param params + * + * @return [T] + */ + @Throws(AppwriteException::class) + suspend fun chunkedUpload( + path: String, + headers: MutableMap, + params: MutableMap, + responseType: Class, + convert: ((Map) -> T), + paramName: String, + onProgress: ((UploadProgress) -> Unit)? = null, + ): T { + val file = params[paramName] as File + val size = file.length() + + if (size < CHUNK_SIZE) { + params[paramName] = MultipartBody.Part.createFormData( + paramName, + file.name, + file.asRequestBody() + ) + return call( + "POST", + path, + headers, + params, + responseType, + convert + ) + } + + val input = file.inputStream().buffered() + val buffer = ByteArray(CHUNK_SIZE) + var offset = 0L + var result: Map<*, *>? = null + + generateSequence { + val readBytes = input.read(buffer) + if (readBytes >= 0) { + buffer.copyOf(readBytes) + } else { + input.close() + null + } + }.forEach { + params[paramName] = MultipartBody.Part.createFormData( + paramName, + file.name, + it.toRequestBody() + ) + + headers["Content-Range"] = + "bytes $offset-${((offset + CHUNK_SIZE) - 1).coerceAtMost(size)}/$size" + + result = call( + "POST", + path, + headers, + params, + Map::class.java + ) + + offset += CHUNK_SIZE + headers["x-appwrite-id"] = result!!["\$id"].toString() + onProgress?.invoke(UploadProgress( + id = result!!["\$id"].toString(), + progress = offset.coerceAtMost(size).toDouble()/size * 100, + sizeUploaded = offset.coerceAtMost(size), + chunksTotal = result!!["chunksTotal"].toString().toInt(), + chunksUploaded = result!!["chunksUploaded"].toString().toInt(), + )) + } + + return convert(result as Map) + } + /** * Await Response * @@ -355,7 +442,8 @@ class Client @JvmOverloads constructor( ) AppwriteException( map["message"] as? String ?: "", - (map["code"] as Number).toInt(), + (map["code"] as Number).toInt(), + map["type"] as? String ?: "", body ) } else { diff --git a/library/src/main/java/io/appwrite/exceptions/AppwriteException.kt b/library/src/main/java/io/appwrite/exceptions/AppwriteException.kt index 1d22595..105f5ee 100644 --- a/library/src/main/java/io/appwrite/exceptions/AppwriteException.kt +++ b/library/src/main/java/io/appwrite/exceptions/AppwriteException.kt @@ -5,5 +5,6 @@ import java.lang.Exception class AppwriteException( override val message: String? = null, val code: Int? = null, + val type: String? = null, val response: String? = null ) : Exception(message) \ 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 0e7a052..6a09c92 100644 --- a/library/src/main/java/io/appwrite/models/ContinentList.kt +++ b/library/src/main/java/io/appwrite/models/ContinentList.kt @@ -7,11 +7,11 @@ import com.google.gson.annotations.SerializedName */ data class ContinentList( /** - * Total number of items available on the server. + * Total number of continents documents that matched your query. * */ - @SerializedName("sum") - val sum: Long, + @SerializedName("total") + val total: Long, /** * List of continents. @@ -23,13 +23,13 @@ data class ContinentList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = ContinentList( - sum = (map["sum"] as Number).toLong(), + total = (map["total"] as Number).toLong(), continents = (map["continents"] as List>).map { Continent.from(map = it) } ) } fun toMap(): Map = mapOf( - "sum" to sum as Any, + "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/CountryList.kt b/library/src/main/java/io/appwrite/models/CountryList.kt index 7cbb9b4..98dbfcd 100644 --- a/library/src/main/java/io/appwrite/models/CountryList.kt +++ b/library/src/main/java/io/appwrite/models/CountryList.kt @@ -7,11 +7,11 @@ import com.google.gson.annotations.SerializedName */ data class CountryList( /** - * Total number of items available on the server. + * Total number of countries documents that matched your query. * */ - @SerializedName("sum") - val sum: Long, + @SerializedName("total") + val total: Long, /** * List of countries. @@ -23,13 +23,13 @@ data class CountryList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = CountryList( - sum = (map["sum"] as Number).toLong(), + total = (map["total"] as Number).toLong(), countries = (map["countries"] as List>).map { Country.from(map = it) } ) } fun toMap(): Map = mapOf( - "sum" to sum as Any, + "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/CurrencyList.kt b/library/src/main/java/io/appwrite/models/CurrencyList.kt index a311340..abc719d 100644 --- a/library/src/main/java/io/appwrite/models/CurrencyList.kt +++ b/library/src/main/java/io/appwrite/models/CurrencyList.kt @@ -7,11 +7,11 @@ import com.google.gson.annotations.SerializedName */ data class CurrencyList( /** - * Total number of items available on the server. + * Total number of currencies documents that matched your query. * */ - @SerializedName("sum") - val sum: Long, + @SerializedName("total") + val total: Long, /** * List of currencies. @@ -23,13 +23,13 @@ data class CurrencyList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = CurrencyList( - sum = (map["sum"] as Number).toLong(), + total = (map["total"] as Number).toLong(), currencies = (map["currencies"] as List>).map { Currency.from(map = it) } ) } fun toMap(): Map = mapOf( - "sum" to sum as Any, + "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/DocumentList.kt b/library/src/main/java/io/appwrite/models/DocumentList.kt index 1807253..f8e41b5 100644 --- a/library/src/main/java/io/appwrite/models/DocumentList.kt +++ b/library/src/main/java/io/appwrite/models/DocumentList.kt @@ -7,11 +7,11 @@ import com.google.gson.annotations.SerializedName */ data class DocumentList( /** - * Total number of items available on the server. + * Total number of documents documents that matched your query. * */ - @SerializedName("sum") - val sum: Long, + @SerializedName("total") + val total: Long, /** * List of documents. @@ -23,13 +23,13 @@ data class DocumentList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = DocumentList( - sum = (map["sum"] as Number).toLong(), + total = (map["total"] as Number).toLong(), documents = (map["documents"] as List>).map { Document.from(map = it) } ) } fun toMap(): Map = mapOf( - "sum" to sum as Any, + "total" to total as Any, "documents" to documents.map { it.toMap() } as Any ) diff --git a/library/src/main/java/io/appwrite/models/Execution.kt b/library/src/main/java/io/appwrite/models/Execution.kt index f03925d..c8f2ae2 100644 --- a/library/src/main/java/io/appwrite/models/Execution.kt +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -49,11 +49,11 @@ data class Execution( val status: String, /** - * The script exit code. + * The script status code. * */ - @SerializedName("exitCode") - val exitCode: Long, + @SerializedName("statusCode") + val statusCode: Long, /** * The script stdout output string. Logs the last 4,000 characters of the execution stdout output. @@ -85,7 +85,7 @@ data class Execution( dateCreated = (map["dateCreated"] as Number).toLong(), trigger = map["trigger"] as String, status = map["status"] as String, - exitCode = (map["exitCode"] as Number).toLong(), + statusCode = (map["statusCode"] as Number).toLong(), stdout = map["stdout"] as String, stderr = map["stderr"] as String, time = (map["time"] as Number).toDouble() @@ -99,7 +99,7 @@ data class Execution( "dateCreated" to dateCreated as Any, "trigger" to trigger as Any, "status" to status as Any, - "exitCode" to exitCode as Any, + "statusCode" to statusCode as Any, "stdout" to stdout as Any, "stderr" to stderr as Any, "time" to time as Any diff --git a/library/src/main/java/io/appwrite/models/ExecutionList.kt b/library/src/main/java/io/appwrite/models/ExecutionList.kt index c771f57..2131ffc 100644 --- a/library/src/main/java/io/appwrite/models/ExecutionList.kt +++ b/library/src/main/java/io/appwrite/models/ExecutionList.kt @@ -7,11 +7,11 @@ import com.google.gson.annotations.SerializedName */ data class ExecutionList( /** - * Total number of items available on the server. + * Total number of executions documents that matched your query. * */ - @SerializedName("sum") - val sum: Long, + @SerializedName("total") + val total: Long, /** * List of executions. @@ -23,13 +23,13 @@ data class ExecutionList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = ExecutionList( - sum = (map["sum"] as Number).toLong(), + total = (map["total"] as Number).toLong(), executions = (map["executions"] as List>).map { Execution.from(map = it) } ) } fun toMap(): Map = mapOf( - "sum" to sum as Any, + "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 1f9e734..2faa1e4 100644 --- a/library/src/main/java/io/appwrite/models/File.kt +++ b/library/src/main/java/io/appwrite/models/File.kt @@ -13,6 +13,13 @@ data class File( @SerializedName("\$id") val id: String, + /** + * Bucket ID. + * + */ + @SerializedName("bucketId") + val bucketId: String, + /** * File read permissions. * @@ -60,30 +67,50 @@ data class File( * */ @SerializedName("sizeOriginal") - val sizeOriginal: Long + val sizeOriginal: Long, + + /** + * Total number of chunks available + * + */ + @SerializedName("chunksTotal") + val chunksTotal: Long, + + /** + * Total number of chunks uploaded + * + */ + @SerializedName("chunksUploaded") + val chunksUploaded: Long ) { companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = File( id = map["\$id"] as String, + bucketId = map["bucketId"] as String, read = map["\$read"] as List, write = map["\$write"] as List, name = map["name"] as String, dateCreated = (map["dateCreated"] as Number).toLong(), signature = map["signature"] as String, mimeType = map["mimeType"] as String, - sizeOriginal = (map["sizeOriginal"] as Number).toLong() + sizeOriginal = (map["sizeOriginal"] as Number).toLong(), + chunksTotal = (map["chunksTotal"] as Number).toLong(), + chunksUploaded = (map["chunksUploaded"] as Number).toLong() ) } fun toMap(): Map = mapOf( "\$id" to id as Any, + "bucketId" to bucketId as Any, "\$read" to read as Any, "\$write" to write as Any, "name" to name as Any, "dateCreated" to dateCreated as Any, "signature" to signature as Any, "mimeType" to mimeType as Any, - "sizeOriginal" to sizeOriginal 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 d000dfc..477bad2 100644 --- a/library/src/main/java/io/appwrite/models/FileList.kt +++ b/library/src/main/java/io/appwrite/models/FileList.kt @@ -7,11 +7,11 @@ import com.google.gson.annotations.SerializedName */ data class FileList( /** - * Total number of items available on the server. + * Total number of files documents that matched your query. * */ - @SerializedName("sum") - val sum: Long, + @SerializedName("total") + val total: Long, /** * List of files. @@ -23,13 +23,13 @@ data class FileList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = FileList( - sum = (map["sum"] as Number).toLong(), + total = (map["total"] as Number).toLong(), files = (map["files"] as List>).map { File.from(map = it) } ) } fun toMap(): Map = mapOf( - "sum" to sum as Any, + "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/LanguageList.kt b/library/src/main/java/io/appwrite/models/LanguageList.kt index 6c688a6..8ca4f5f 100644 --- a/library/src/main/java/io/appwrite/models/LanguageList.kt +++ b/library/src/main/java/io/appwrite/models/LanguageList.kt @@ -7,11 +7,11 @@ import com.google.gson.annotations.SerializedName */ data class LanguageList( /** - * Total number of items available on the server. + * Total number of languages documents that matched your query. * */ - @SerializedName("sum") - val sum: Long, + @SerializedName("total") + val total: Long, /** * List of languages. @@ -23,13 +23,13 @@ data class LanguageList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = LanguageList( - sum = (map["sum"] as Number).toLong(), + total = (map["total"] as Number).toLong(), languages = (map["languages"] as List>).map { Language.from(map = it) } ) } fun toMap(): Map = mapOf( - "sum" to sum as Any, + "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/LogList.kt b/library/src/main/java/io/appwrite/models/LogList.kt index d6666cf..47d5680 100644 --- a/library/src/main/java/io/appwrite/models/LogList.kt +++ b/library/src/main/java/io/appwrite/models/LogList.kt @@ -7,11 +7,11 @@ import com.google.gson.annotations.SerializedName */ data class LogList( /** - * Total number of items available on the server. + * Total number of logs documents that matched your query. * */ - @SerializedName("sum") - val sum: Long, + @SerializedName("total") + val total: Long, /** * List of logs. @@ -23,13 +23,13 @@ data class LogList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = LogList( - sum = (map["sum"] as Number).toLong(), + total = (map["total"] as Number).toLong(), logs = (map["logs"] as List>).map { Log.from(map = it) } ) } fun toMap(): Map = mapOf( - "sum" to sum as Any, + "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/MembershipList.kt b/library/src/main/java/io/appwrite/models/MembershipList.kt index 3171fae..1b7549d 100644 --- a/library/src/main/java/io/appwrite/models/MembershipList.kt +++ b/library/src/main/java/io/appwrite/models/MembershipList.kt @@ -7,11 +7,11 @@ import com.google.gson.annotations.SerializedName */ data class MembershipList( /** - * Total number of items available on the server. + * Total number of memberships documents that matched your query. * */ - @SerializedName("sum") - val sum: Long, + @SerializedName("total") + val total: Long, /** * List of memberships. @@ -23,13 +23,13 @@ data class MembershipList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = MembershipList( - sum = (map["sum"] as Number).toLong(), + total = (map["total"] as Number).toLong(), memberships = (map["memberships"] as List>).map { Membership.from(map = it) } ) } fun toMap(): Map = mapOf( - "sum" to sum as Any, + "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/PhoneList.kt b/library/src/main/java/io/appwrite/models/PhoneList.kt index d9338cb..6dee844 100644 --- a/library/src/main/java/io/appwrite/models/PhoneList.kt +++ b/library/src/main/java/io/appwrite/models/PhoneList.kt @@ -7,11 +7,11 @@ import com.google.gson.annotations.SerializedName */ data class PhoneList( /** - * Total number of items available on the server. + * Total number of phones documents that matched your query. * */ - @SerializedName("sum") - val sum: Long, + @SerializedName("total") + val total: Long, /** * List of phones. @@ -23,13 +23,13 @@ data class PhoneList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = PhoneList( - sum = (map["sum"] as Number).toLong(), + total = (map["total"] as Number).toLong(), phones = (map["phones"] as List>).map { Phone.from(map = it) } ) } fun toMap(): Map = mapOf( - "sum" to sum as Any, + "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/RealtimeModels.kt b/library/src/main/java/io/appwrite/models/RealtimeModels.kt index e2b012a..4237638 100644 --- a/library/src/main/java/io/appwrite/models/RealtimeModels.kt +++ b/library/src/main/java/io/appwrite/models/RealtimeModels.kt @@ -1,5 +1,6 @@ package io.appwrite.models +import kotlin.collections.Collection import java.io.Closeable data class RealtimeSubscription( diff --git a/library/src/main/java/io/appwrite/models/Session.kt b/library/src/main/java/io/appwrite/models/Session.kt index 1ee5187..1abd909 100644 --- a/library/src/main/java/io/appwrite/models/Session.kt +++ b/library/src/main/java/io/appwrite/models/Session.kt @@ -42,11 +42,25 @@ data class Session( val providerUid: String, /** - * Session Provider Token. + * Session Provider Access Token. * */ - @SerializedName("providerToken") - val providerToken: String, + @SerializedName("providerAccessToken") + val providerAccessToken: String, + + /** + * Date, the Unix timestamp of when the access token expires. + * + */ + @SerializedName("providerAccessTokenExpiry") + val providerAccessTokenExpiry: Long, + + /** + * Session Provider Refresh Token. + * + */ + @SerializedName("providerRefreshToken") + val providerRefreshToken: String, /** * IP in use when the session was created. @@ -168,7 +182,9 @@ data class Session( expire = (map["expire"] as Number).toLong(), provider = map["provider"] as String, providerUid = map["providerUid"] as String, - providerToken = map["providerToken"] as String, + providerAccessToken = map["providerAccessToken"] as String, + providerAccessTokenExpiry = (map["providerAccessTokenExpiry"] as Number).toLong(), + providerRefreshToken = map["providerRefreshToken"] as String, ip = map["ip"] as String, osCode = map["osCode"] as String, osName = map["osName"] as String, @@ -194,7 +210,9 @@ data class Session( "expire" to expire as Any, "provider" to provider as Any, "providerUid" to providerUid as Any, - "providerToken" to providerToken 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, diff --git a/library/src/main/java/io/appwrite/models/SessionList.kt b/library/src/main/java/io/appwrite/models/SessionList.kt index 2d6a4bd..9891102 100644 --- a/library/src/main/java/io/appwrite/models/SessionList.kt +++ b/library/src/main/java/io/appwrite/models/SessionList.kt @@ -7,11 +7,11 @@ import com.google.gson.annotations.SerializedName */ data class SessionList( /** - * Total number of items available on the server. + * Total number of sessions documents that matched your query. * */ - @SerializedName("sum") - val sum: Long, + @SerializedName("total") + val total: Long, /** * List of sessions. @@ -23,13 +23,13 @@ data class SessionList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = SessionList( - sum = (map["sum"] as Number).toLong(), + total = (map["total"] as Number).toLong(), sessions = (map["sessions"] as List>).map { Session.from(map = it) } ) } fun toMap(): Map = mapOf( - "sum" to sum as Any, + "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 d0eda4e..f502375 100644 --- a/library/src/main/java/io/appwrite/models/Team.kt +++ b/library/src/main/java/io/appwrite/models/Team.kt @@ -28,11 +28,11 @@ data class Team( val dateCreated: Long, /** - * Total sum of team members. + * Total number of team members. * */ - @SerializedName("sum") - val sum: Long + @SerializedName("total") + val total: Long ) { companion object { @Suppress("UNCHECKED_CAST") @@ -40,7 +40,7 @@ data class Team( id = map["\$id"] as String, name = map["name"] as String, dateCreated = (map["dateCreated"] as Number).toLong(), - sum = (map["sum"] as Number).toLong() + total = (map["total"] as Number).toLong() ) } @@ -48,6 +48,6 @@ data class Team( "\$id" to id as Any, "name" to name as Any, "dateCreated" to dateCreated as Any, - "sum" to sum 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 af63825..4f210b3 100644 --- a/library/src/main/java/io/appwrite/models/TeamList.kt +++ b/library/src/main/java/io/appwrite/models/TeamList.kt @@ -7,11 +7,11 @@ import com.google.gson.annotations.SerializedName */ data class TeamList( /** - * Total number of items available on the server. + * Total number of teams documents that matched your query. * */ - @SerializedName("sum") - val sum: Long, + @SerializedName("total") + val total: Long, /** * List of teams. @@ -23,13 +23,13 @@ data class TeamList( companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = TeamList( - sum = (map["sum"] as Number).toLong(), + total = (map["total"] as Number).toLong(), teams = (map["teams"] as List>).map { Team.from(map = it) } ) } fun toMap(): Map = mapOf( - "sum" to sum as Any, + "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/UploadProgress.kt b/library/src/main/java/io/appwrite/models/UploadProgress.kt new file mode 100644 index 0000000..4199694 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/UploadProgress.kt @@ -0,0 +1,9 @@ +package io.appwrite.models + +data class UploadProgress( + val id: String, + val progress: Double, + val sizeUploaded: Long, + val chunksTotal: Int, + val chunksUploaded: Int +) \ 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 2c1b6a1..997b7c7 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -25,9 +25,9 @@ class Account(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun get(): io.appwrite.models.User { val path = "/account" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.User = { @@ -39,7 +39,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.User::class.java, - convert = convert + convert = convert, ) } @@ -53,7 +53,7 @@ class Account(client: Client) : Service(client) { * 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 "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. @@ -68,13 +68,13 @@ class Account(client: Client) : Service(client) { name: String? = null ): io.appwrite.models.User { val path = "/account" - val params = mapOf( + val params = mutableMapOf( "userId" to userId, "email" to email, "password" to password, "name" to name ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.User = { @@ -86,7 +86,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.User::class.java, - convert = convert + convert = convert, ) } @@ -105,9 +105,9 @@ class Account(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun delete(): Any { val path = "/account" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) return client.call( @@ -142,11 +142,11 @@ class Account(client: Client) : Service(client) { password: String ): io.appwrite.models.User { val path = "/account/email" - val params = mapOf( + val params = mutableMapOf( "email" to email, "password" to password ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.User = { @@ -158,7 +158,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.User::class.java, - convert = convert + convert = convert, ) } @@ -177,9 +177,9 @@ class Account(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun createJWT(): io.appwrite.models.Jwt { val path = "/account/jwt" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.Jwt = { @@ -191,7 +191,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Jwt::class.java, - convert = convert + convert = convert, ) } @@ -212,11 +212,11 @@ class Account(client: Client) : Service(client) { offset: Long? = null ): io.appwrite.models.LogList { val path = "/account/logs" - val params = mapOf( + val params = mutableMapOf( "limit" to limit, "offset" to offset ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.LogList = { @@ -228,7 +228,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.LogList::class.java, - convert = convert + convert = convert, ) } @@ -246,10 +246,10 @@ class Account(client: Client) : Service(client) { name: String ): io.appwrite.models.User { val path = "/account/name" - val params = mapOf( + val params = mutableMapOf( "name" to name ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.User = { @@ -261,7 +261,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.User::class.java, - convert = convert + convert = convert, ) } @@ -283,11 +283,11 @@ class Account(client: Client) : Service(client) { oldPassword: String? = null ): io.appwrite.models.User { val path = "/account/password" - val params = mapOf( + val params = mutableMapOf( "password" to password, "oldPassword" to oldPassword ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.User = { @@ -299,7 +299,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.User::class.java, - convert = convert + convert = convert, ) } @@ -314,9 +314,9 @@ class Account(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun getPrefs(): io.appwrite.models.Preferences { val path = "/account/prefs" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.Preferences = { @@ -328,7 +328,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Preferences::class.java, - convert = convert + convert = convert, ) } @@ -348,10 +348,10 @@ class Account(client: Client) : Service(client) { prefs: Any ): io.appwrite.models.User { val path = "/account/prefs" - val params = mapOf( + val params = mutableMapOf( "prefs" to prefs ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.User = { @@ -363,7 +363,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.User::class.java, - convert = convert + convert = convert, ) } @@ -390,11 +390,11 @@ class Account(client: Client) : Service(client) { url: String ): io.appwrite.models.Token { val path = "/account/recovery" - val params = mapOf( + val params = mutableMapOf( "email" to email, "url" to url ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.Token = { @@ -406,7 +406,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Token::class.java, - convert = convert + convert = convert, ) } @@ -438,13 +438,13 @@ class Account(client: Client) : Service(client) { passwordAgain: String ): io.appwrite.models.Token { val path = "/account/recovery" - val params = mapOf( + val params = mutableMapOf( "userId" to userId, "secret" to secret, "password" to password, "passwordAgain" to passwordAgain ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.Token = { @@ -456,7 +456,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Token::class.java, - convert = convert + convert = convert, ) } @@ -472,9 +472,9 @@ class Account(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun getSessions(): io.appwrite.models.SessionList { val path = "/account/sessions" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.SessionList = { @@ -486,7 +486,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.SessionList::class.java, - convert = convert + convert = convert, ) } @@ -507,11 +507,11 @@ class Account(client: Client) : Service(client) { password: String ): io.appwrite.models.Session { val path = "/account/sessions" - val params = mapOf( + val params = mutableMapOf( "email" to email, "password" to password ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.Session = { @@ -523,7 +523,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Session::class.java, - convert = convert + convert = convert, ) } @@ -539,9 +539,9 @@ class Account(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun deleteSessions(): Any { val path = "/account/sessions" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) return client.call( @@ -569,9 +569,9 @@ class Account(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun createAnonymousSession(): io.appwrite.models.Session { val path = "/account/sessions/anonymous" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.Session = { @@ -583,7 +583,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Session::class.java, - convert = convert + convert = convert, ) } @@ -601,7 +601,7 @@ class Account(client: Client) : Service(client) { * 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. + * @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 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] @@ -614,12 +614,12 @@ class Account(client: Client) : Service(client) { url: String? = null ): io.appwrite.models.Token { val path = "/account/sessions/magic-url" - val params = mapOf( + val params = mutableMapOf( "userId" to userId, "email" to email, "url" to url ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.Token = { @@ -631,7 +631,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Token::class.java, - convert = convert + convert = convert, ) } @@ -661,11 +661,11 @@ class Account(client: Client) : Service(client) { secret: String ): io.appwrite.models.Session { val path = "/account/sessions/magic-url" - val params = mapOf( + val params = mutableMapOf( "userId" to userId, "secret" to secret ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.Session = { @@ -677,7 +677,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Session::class.java, - convert = convert + convert = convert, ) } @@ -697,7 +697,7 @@ class Account(client: Client) : Service(client) { * user.. * * - * @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, bitbucket, bitly, box, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, paypal, paypalSandbox, salesforce, slack, spotify, tradeshift, tradeshiftBox, twitch, vk, yahoo, yammer, yandex, wordpress. + * @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, bitbucket, bitly, box, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, notion, paypal, paypalSandbox, salesforce, slack, spotify, tradeshift, tradeshiftBox, twitch, vk, yahoo, yammer, yandex, wordpress, stripe. * @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. @@ -713,7 +713,7 @@ class Account(client: Client) : Service(client) { scopes: List? = null ) { val path = "/account/sessions/oauth2/{provider}".replace("{provider}", provider) - val params = mapOf( + val params = mutableMapOf( "success" to success, "failure" to failure, "scopes" to scopes, @@ -778,9 +778,9 @@ class Account(client: Client) : Service(client) { sessionId: String ): io.appwrite.models.Session { val path = "/account/sessions/{sessionId}".replace("{sessionId}", sessionId) - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.Session = { @@ -792,7 +792,37 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Session::class.java, - convert = convert + convert = convert, + ) + } + + /** + * Update Session (Refresh Tokens) + * + * @param sessionId Session ID. Use the string 'current' to update the current device 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) + val params = mutableMapOf( + ) + val headers = mutableMapOf( + "content-type" to "application/json" + ) + val convert: (Map) -> io.appwrite.models.Session = { + io.appwrite.models.Session.from(map = it) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.Session::class.java, + convert = convert, ) } @@ -801,7 +831,8 @@ class Account(client: Client) : Service(client) { * * 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 - * option id argument, only the session unique ID provider will be deleted. + * 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] @@ -812,9 +843,9 @@ class Account(client: Client) : Service(client) { sessionId: String ): Any { val path = "/account/sessions/{sessionId}".replace("{sessionId}", sessionId) - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) return client.call( @@ -854,10 +885,10 @@ class Account(client: Client) : Service(client) { url: String ): io.appwrite.models.Token { val path = "/account/verification" - val params = mapOf( + val params = mutableMapOf( "url" to url ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.Token = { @@ -869,7 +900,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Token::class.java, - convert = convert + convert = convert, ) } @@ -892,11 +923,11 @@ class Account(client: Client) : Service(client) { secret: String ): io.appwrite.models.Token { val path = "/account/verification" - val params = mapOf( + val params = mutableMapOf( "userId" to userId, "secret" to secret ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.Token = { @@ -908,7 +939,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Token::class.java, - convert = convert + convert = convert, ) } diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt index 912b1e5..09afbc6 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -35,7 +35,7 @@ class Avatars(client: Client) : Service(client) { quality: Long? = null ): ByteArray { val path = "/avatars/browsers/{code}".replace("{code}", code) - val params = mapOf( + val params = mutableMapOf( "width" to width, "height" to height, "quality" to quality, @@ -71,7 +71,7 @@ class Avatars(client: Client) : Service(client) { quality: Long? = null ): ByteArray { val path = "/avatars/credit-cards/{code}".replace("{code}", code) - val params = mapOf( + val params = mutableMapOf( "width" to width, "height" to height, "quality" to quality, @@ -101,7 +101,7 @@ class Avatars(client: Client) : Service(client) { url: String ): ByteArray { val path = "/avatars/favicon" - val params = mapOf( + val params = mutableMapOf( "url" to url, "project" to client.config["project"] ) @@ -135,7 +135,7 @@ class Avatars(client: Client) : Service(client) { quality: Long? = null ): ByteArray { val path = "/avatars/flags/{code}".replace("{code}", code) - val params = mapOf( + val params = mutableMapOf( "width" to width, "height" to height, "quality" to quality, @@ -170,7 +170,7 @@ class Avatars(client: Client) : Service(client) { height: Long? = null ): ByteArray { val path = "/avatars/image" - val params = mapOf( + val params = mutableMapOf( "url" to url, "width" to width, "height" to height, @@ -215,7 +215,7 @@ class Avatars(client: Client) : Service(client) { background: String? = null ): ByteArray { val path = "/avatars/initials" - val params = mapOf( + val params = mutableMapOf( "name" to name, "width" to width, "height" to height, @@ -252,7 +252,7 @@ class Avatars(client: Client) : Service(client) { download: Boolean? = null ): ByteArray { val path = "/avatars/qr" - val params = mapOf( + val params = mutableMapOf( "text" to text, "size" to size, "margin" to margin, diff --git a/library/src/main/java/io/appwrite/services/Database.kt b/library/src/main/java/io/appwrite/services/Database.kt index 7b43505..8db1ac2 100644 --- a/library/src/main/java/io/appwrite/services/Database.kt +++ b/library/src/main/java/io/appwrite/services/Database.kt @@ -41,7 +41,7 @@ class Database(client: Client) : Service(client) { orderTypes: List? = null ): io.appwrite.models.DocumentList { val path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId) - val params = mapOf( + val params = mutableMapOf( "queries" to queries, "limit" to limit, "offset" to offset, @@ -50,7 +50,7 @@ class Database(client: Client) : Service(client) { "orderAttributes" to orderAttributes, "orderTypes" to orderTypes ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.DocumentList = { @@ -62,7 +62,7 @@ class Database(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.DocumentList::class.java, - convert = convert + convert = convert, ) } @@ -75,7 +75,7 @@ class Database(client: Client) : Service(client) { * directly from your database console. * * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). 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 "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 read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. * @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. @@ -91,13 +91,13 @@ class Database(client: Client) : Service(client) { write: List? = null ): io.appwrite.models.Document { val path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId) - val params = mapOf( + val params = mutableMapOf( "documentId" to documentId, "data" to data, "read" to read, "write" to write ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.Document = { @@ -109,7 +109,7 @@ class Database(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Document::class.java, - convert = convert + convert = convert, ) } @@ -130,9 +130,9 @@ class Database(client: Client) : Service(client) { documentId: String ): io.appwrite.models.Document { val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId) - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.Document = { @@ -144,7 +144,7 @@ class Database(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Document::class.java, - convert = convert + convert = convert, ) } @@ -171,12 +171,12 @@ class Database(client: Client) : Service(client) { write: List? = null ): io.appwrite.models.Document { val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId) - val params = mapOf( + val params = mutableMapOf( "data" to data, "read" to read, "write" to write ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.Document = { @@ -188,7 +188,7 @@ class Database(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Document::class.java, - convert = convert + convert = convert, ) } @@ -210,9 +210,9 @@ class Database(client: Client) : Service(client) { documentId: String ): Any { val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId) - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) return client.call( diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index 132e753..36f6b33 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -10,6 +10,36 @@ import java.io.File class Functions(client: Client) : Service(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 * @@ -37,14 +67,14 @@ class Functions(client: Client) : Service(client) { cursorDirection: String? = null ): io.appwrite.models.ExecutionList { val path = "/functions/{functionId}/executions".replace("{functionId}", functionId) - val params = mapOf( + val params = mutableMapOf( "limit" to limit, "offset" to offset, "search" to search, "cursor" to cursor, "cursorDirection" to cursorDirection ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.ExecutionList = { @@ -56,7 +86,7 @@ class Functions(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.ExecutionList::class.java, - convert = convert + convert = convert, ) } @@ -70,19 +100,22 @@ class Functions(client: Client) : Service(client) { * * @param functionId Function ID. * @param data String of custom data to send to function. + * @param async Execute code asynchronously. Default value is true. * @return [io.appwrite.models.Execution] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun createExecution( functionId: String, - data: String? = null + data: String? = null, + async: Boolean? = null ): io.appwrite.models.Execution { val path = "/functions/{functionId}/executions".replace("{functionId}", functionId) - val params = mapOf( - "data" to data + val params = mutableMapOf( + "data" to data, + "async" to async ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.Execution = { @@ -94,7 +127,7 @@ class Functions(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Execution::class.java, - convert = convert + convert = convert, ) } @@ -114,9 +147,9 @@ class Functions(client: Client) : Service(client) { executionId: String ): io.appwrite.models.Execution { val path = "/functions/{functionId}/executions/{executionId}".replace("{functionId}", functionId).replace("{executionId}", executionId) - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.Execution = { @@ -128,7 +161,7 @@ class Functions(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Execution::class.java, - convert = convert + convert = convert, ) } diff --git a/library/src/main/java/io/appwrite/services/Locale.kt b/library/src/main/java/io/appwrite/services/Locale.kt index 423a323..c8837b4 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -26,9 +26,9 @@ class Locale(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun get(): io.appwrite.models.Locale { val path = "/locale" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.Locale = { @@ -40,7 +40,7 @@ class Locale(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Locale::class.java, - convert = convert + convert = convert, ) } @@ -56,9 +56,9 @@ class Locale(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun getContinents(): io.appwrite.models.ContinentList { val path = "/locale/continents" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.ContinentList = { @@ -70,7 +70,7 @@ class Locale(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.ContinentList::class.java, - convert = convert + convert = convert, ) } @@ -86,9 +86,9 @@ class Locale(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun getCountries(): io.appwrite.models.CountryList { val path = "/locale/countries" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.CountryList = { @@ -100,7 +100,7 @@ class Locale(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.CountryList::class.java, - convert = convert + convert = convert, ) } @@ -116,9 +116,9 @@ class Locale(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun getCountriesEU(): io.appwrite.models.CountryList { val path = "/locale/countries/eu" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.CountryList = { @@ -130,7 +130,7 @@ class Locale(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.CountryList::class.java, - convert = convert + convert = convert, ) } @@ -146,9 +146,9 @@ class Locale(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun getCountriesPhones(): io.appwrite.models.PhoneList { val path = "/locale/countries/phones" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.PhoneList = { @@ -160,7 +160,7 @@ class Locale(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.PhoneList::class.java, - convert = convert + convert = convert, ) } @@ -177,9 +177,9 @@ class Locale(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun getCurrencies(): io.appwrite.models.CurrencyList { val path = "/locale/currencies" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.CurrencyList = { @@ -191,7 +191,7 @@ class Locale(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.CurrencyList::class.java, - convert = convert + convert = convert, ) } @@ -207,9 +207,9 @@ class Locale(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun getLanguages(): io.appwrite.models.LanguageList { val path = "/locale/languages" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.LanguageList = { @@ -221,7 +221,7 @@ class Locale(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.LanguageList::class.java, - convert = convert + convert = convert, ) } diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index 42a0958..0117a62 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -19,6 +19,7 @@ class Storage(client: Client) : Service(client) { * 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). * + * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket). * @param search Search term to filter your list results. Max length: 256 chars. * @param limit Maximum number of files to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. * @param offset Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) @@ -30,6 +31,7 @@ class Storage(client: Client) : Service(client) { @JvmOverloads @Throws(AppwriteException::class) suspend fun listFiles( + bucketId: String, search: String? = null, limit: Long? = null, offset: Long? = null, @@ -37,8 +39,8 @@ class Storage(client: Client) : Service(client) { cursorDirection: String? = null, orderType: String? = null ): io.appwrite.models.FileList { - val path = "/storage/files" - val params = mapOf( + val path = "/storage/buckets/{bucketId}/files".replace("{bucketId}", bucketId) + val params = mutableMapOf( "search" to search, "limit" to limit, "offset" to offset, @@ -46,7 +48,7 @@ class Storage(client: Client) : Service(client) { "cursorDirection" to cursorDirection, "orderType" to orderType ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.FileList = { @@ -58,18 +60,34 @@ class Storage(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.FileList::class.java, - convert = convert + convert = convert, ) } /** * Create File * - * Create a new file. The user who creates the file will automatically be - * assigned to read and write access unless he has passed custom values for - * read and write arguments. + * Create a new file. Before using this route, you should create a new bucket + * resource using either a [server + * integration](/docs/server/database#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 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 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 file Binary file. * @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. * @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. @@ -78,31 +96,34 @@ class Storage(client: Client) : Service(client) { @JvmOverloads @Throws(AppwriteException::class) suspend fun createFile( + bucketId: String, fileId: String, file: File, read: List? = null, - write: List? = null + write: List? = null, onProgress: ((UploadProgress) -> Unit)? = null ): io.appwrite.models.File { - val path = "/storage/files" - val params = mapOf( + val path = "/storage/buckets/{bucketId}/files".replace("{bucketId}", bucketId) + val params = mutableMapOf( "fileId" to fileId, "file" to file, "read" to read, "write" to write ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "multipart/form-data" ) val convert: (Map) -> io.appwrite.models.File = { io.appwrite.models.File.from(map = it) } - return client.call( - "POST", + val paramName = "file" + return client.chunkedUpload( path, headers, params, responseType = io.appwrite.models.File::class.java, - convert = convert + convert = convert, + paramName, + onProgress, ) } @@ -112,18 +133,20 @@ class Storage(client: Client) : Service(client) { * 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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getFile( + bucketId: String, fileId: String ): io.appwrite.models.File { - val path = "/storage/files/{fileId}".replace("{fileId}", fileId) - val params = mapOf( + val path = "/storage/buckets/{bucketId}/files/{fileId}".replace("{bucketId}", bucketId).replace("{fileId}", fileId) + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.File = { @@ -135,7 +158,7 @@ class Storage(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.File::class.java, - convert = convert + convert = convert, ) } @@ -145,7 +168,8 @@ class Storage(client: Client) : Service(client) { * Update a file by its unique ID. Only users with write permissions have * access to update this resource. * - * @param fileId File ID. + * @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 read An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. * @param write An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. * @return [io.appwrite.models.File] @@ -153,16 +177,17 @@ class Storage(client: Client) : Service(client) { @JvmOverloads @Throws(AppwriteException::class) suspend fun updateFile( + bucketId: String, fileId: String, - read: List, - write: List + read: List? = null, + write: List? = null ): io.appwrite.models.File { - val path = "/storage/files/{fileId}".replace("{fileId}", fileId) - val params = mapOf( + val path = "/storage/buckets/{bucketId}/files/{fileId}".replace("{bucketId}", bucketId).replace("{fileId}", fileId) + val params = mutableMapOf( "read" to read, "write" to write ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.File = { @@ -174,7 +199,7 @@ class Storage(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.File::class.java, - convert = convert + convert = convert, ) } @@ -184,18 +209,20 @@ class Storage(client: Client) : Service(client) { * 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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun deleteFile( + bucketId: String, fileId: String ): Any { - val path = "/storage/files/{fileId}".replace("{fileId}", fileId) - val params = mapOf( + val path = "/storage/buckets/{bucketId}/files/{fileId}".replace("{bucketId}", bucketId).replace("{fileId}", fileId) + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) return client.call( @@ -214,16 +241,18 @@ class Storage(client: Client) : Service(client) { * '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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getFileDownload( + bucketId: String, fileId: String ): ByteArray { - val path = "/storage/files/{fileId}/download".replace("{fileId}", fileId) - val params = mapOf( + 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( @@ -240,9 +269,11 @@ class Storage(client: Client) : Service(client) { * 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. + * string arguments for cutting and resizing your preview image. Preview is + * supported only for image files smaller than 10MB. * - * @param fileId File ID. + * @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 * @param width Resize preview image width, Pass an integer between 0 to 4000. * @param height Resize preview image height, Pass an integer between 0 to 4000. * @param gravity Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right @@ -259,6 +290,7 @@ class Storage(client: Client) : Service(client) { @JvmOverloads @Throws(AppwriteException::class) suspend fun getFilePreview( + bucketId: String, fileId: String, width: Long? = null, height: Long? = null, @@ -272,8 +304,8 @@ class Storage(client: Client) : Service(client) { background: String? = null, output: String? = null ): ByteArray { - val path = "/storage/files/{fileId}/preview".replace("{fileId}", fileId) - val params = mapOf( + val path = "/storage/buckets/{bucketId}/files/{fileId}/preview".replace("{bucketId}", bucketId).replace("{fileId}", fileId) + val params = mutableMapOf( "width" to width, "height" to height, "gravity" to gravity, @@ -302,16 +334,18 @@ class Storage(client: Client) : Service(client) { * 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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getFileView( + bucketId: String, fileId: String ): ByteArray { - val path = "/storage/files/{fileId}/view".replace("{fileId}", fileId) - val params = mapOf( + 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( diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index cc08040..f58df7c 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -38,7 +38,7 @@ class Teams(client: Client) : Service(client) { orderType: String? = null ): io.appwrite.models.TeamList { val path = "/teams" - val params = mapOf( + val params = mutableMapOf( "search" to search, "limit" to limit, "offset" to offset, @@ -46,7 +46,7 @@ class Teams(client: Client) : Service(client) { "cursorDirection" to cursorDirection, "orderType" to orderType ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.TeamList = { @@ -58,7 +58,7 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.TeamList::class.java, - convert = convert + convert = convert, ) } @@ -69,7 +69,7 @@ class Teams(client: Client) : Service(client) { * 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 "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). Max length for each role is 32 chars. * @return [io.appwrite.models.Team] @@ -82,12 +82,12 @@ class Teams(client: Client) : Service(client) { roles: List? = null ): io.appwrite.models.Team { val path = "/teams" - val params = mapOf( + val params = mutableMapOf( "teamId" to teamId, "name" to name, "roles" to roles ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.Team = { @@ -99,7 +99,7 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Team::class.java, - convert = convert + convert = convert, ) } @@ -117,9 +117,9 @@ class Teams(client: Client) : Service(client) { teamId: String ): io.appwrite.models.Team { val path = "/teams/{teamId}".replace("{teamId}", teamId) - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.Team = { @@ -131,7 +131,7 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Team::class.java, - convert = convert + convert = convert, ) } @@ -152,10 +152,10 @@ class Teams(client: Client) : Service(client) { name: String ): io.appwrite.models.Team { val path = "/teams/{teamId}".replace("{teamId}", teamId) - val params = mapOf( + val params = mutableMapOf( "name" to name ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.Team = { @@ -167,7 +167,7 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Team::class.java, - convert = convert + convert = convert, ) } @@ -186,9 +186,9 @@ class Teams(client: Client) : Service(client) { teamId: String ): Any { val path = "/teams/{teamId}".replace("{teamId}", teamId) - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) return client.call( @@ -227,7 +227,7 @@ class Teams(client: Client) : Service(client) { orderType: String? = null ): io.appwrite.models.MembershipList { val path = "/teams/{teamId}/memberships".replace("{teamId}", teamId) - val params = mapOf( + val params = mutableMapOf( "search" to search, "limit" to limit, "offset" to offset, @@ -235,7 +235,7 @@ class Teams(client: Client) : Service(client) { "cursorDirection" to cursorDirection, "orderType" to orderType ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.MembershipList = { @@ -247,7 +247,7 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.MembershipList::class.java, - convert = convert + convert = convert, ) } @@ -287,13 +287,13 @@ class Teams(client: Client) : Service(client) { name: String? = null ): io.appwrite.models.Membership { val path = "/teams/{teamId}/memberships".replace("{teamId}", teamId) - val params = mapOf( + val params = mutableMapOf( "email" to email, "roles" to roles, "url" to url, "name" to name ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.Membership = { @@ -305,7 +305,7 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Membership::class.java, - convert = convert + convert = convert, ) } @@ -326,9 +326,9 @@ class Teams(client: Client) : Service(client) { membershipId: String ): io.appwrite.models.MembershipList { val path = "/teams/{teamId}/memberships/{membershipId}".replace("{teamId}", teamId).replace("{membershipId}", membershipId) - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.MembershipList = { @@ -340,7 +340,7 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.MembershipList::class.java, - convert = convert + convert = convert, ) } @@ -364,10 +364,10 @@ class Teams(client: Client) : Service(client) { roles: List ): io.appwrite.models.Membership { val path = "/teams/{teamId}/memberships/{membershipId}".replace("{teamId}", teamId).replace("{membershipId}", membershipId) - val params = mapOf( + val params = mutableMapOf( "roles" to roles ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.Membership = { @@ -379,7 +379,7 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Membership::class.java, - convert = convert + convert = convert, ) } @@ -401,9 +401,9 @@ class Teams(client: Client) : Service(client) { membershipId: String ): Any { val path = "/teams/{teamId}/memberships/{membershipId}".replace("{teamId}", teamId).replace("{membershipId}", membershipId) - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) return client.call( @@ -421,6 +421,10 @@ class Teams(client: Client) : Service(client) { * 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. @@ -437,11 +441,11 @@ class Teams(client: Client) : Service(client) { secret: String ): io.appwrite.models.Membership { val path = "/teams/{teamId}/memberships/{membershipId}/status".replace("{teamId}", teamId).replace("{membershipId}", membershipId) - val params = mapOf( + val params = mutableMapOf( "userId" to userId, "secret" to secret ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) val convert: (Map) -> io.appwrite.models.Membership = { @@ -453,7 +457,7 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Membership::class.java, - convert = convert + convert = convert, ) } From 8fd751e9544f4cead06f6d20de7c1d5943b019fc Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 2 Mar 2022 12:26:58 +0100 Subject: [PATCH 027/118] feat: support for 0.13.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8c463db..f58d55b 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:0.3.3") +implementation("io.appwrite:sdk-for-android:0.4.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 0.3.3 + 0.4.0 ``` From 0a65a5548a62f6a2c4d7c0636da56e238e134ec6 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 12 Apr 2022 11:19:55 +0545 Subject: [PATCH 028/118] latest fixes --- README.md | 4 +- library/build.gradle | 1 - library/src/main/java/io/appwrite/Client.kt | 2 +- .../java/io/appwrite/cookies/Extensions.kt | 53 ++++ .../io/appwrite/cookies/InternalCookie.kt | 49 ++++ .../cookies/stores/InMemoryCookieStore.kt | 269 ++++++++++++++++++ .../stores/SharedPreferencesCookieStore.kt | 99 +++++++ 7 files changed, 473 insertions(+), 4 deletions(-) create mode 100644 library/src/main/java/io/appwrite/cookies/Extensions.kt create mode 100644 library/src/main/java/io/appwrite/cookies/InternalCookie.kt create mode 100644 library/src/main/java/io/appwrite/cookies/stores/InMemoryCookieStore.kt create mode 100644 library/src/main/java/io/appwrite/cookies/stores/SharedPreferencesCookieStore.kt diff --git a/README.md b/README.md index f58d55b..6051870 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:0.4.0") +implementation("io.appwrite:sdk-for-android:0.4.1") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 0.4.0 + 0.4.1 ``` diff --git a/library/build.gradle b/library/build.gradle index ee98757..7045591 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -63,7 +63,6 @@ dependencies { implementation("com.squareup.okhttp3:logging-interceptor") implementation("com.google.code.gson:gson:2.8.7") - implementation("net.gotev:cookie-store:1.3.5") 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") diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 902fd7f..fefa174 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -5,6 +5,7 @@ import android.content.pm.PackageManager import com.google.gson.GsonBuilder import com.google.gson.reflect.TypeToken import io.appwrite.appwrite.BuildConfig +import io.appwrite.cookies.stores.SharedPreferencesCookieStore import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.fromJson import io.appwrite.json.PreciseNumberAdapter @@ -13,7 +14,6 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.suspendCancellableCoroutine -import net.gotev.cookiestore.SharedPreferencesCookieStore import okhttp3.* import okhttp3.Headers.Companion.toHeaders import okhttp3.HttpUrl.Companion.toHttpUrl diff --git a/library/src/main/java/io/appwrite/cookies/Extensions.kt b/library/src/main/java/io/appwrite/cookies/Extensions.kt new file mode 100644 index 0000000..257c904 --- /dev/null +++ b/library/src/main/java/io/appwrite/cookies/Extensions.kt @@ -0,0 +1,53 @@ +package io.appwrite.cookies + +import android.os.Build +import java.net.CookieStore +import java.net.HttpCookie +import java.text.SimpleDateFormat +import java.util.Calendar +import java.util.Locale +import java.util.TimeZone + +fun HttpCookie.toSetCookieString(): String { + val expires = if (maxAge != -1L) { + val dateFormat = SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.UK).apply { + timeZone = TimeZone.getTimeZone("GMT") + } + + val calendar = Calendar.getInstance(Locale.UK).apply { set(Calendar.SECOND, maxAge.toInt()) } + + "; expires=${dateFormat.format(calendar.time)}" + } else { + "" + } + + val path = if (path != null) "; path=$path" else "" + val domain = if (domain != null) "; domain=$domain" else "" + val secure = if (secure) "; secure" else "" + val httpOnly = if (Build.VERSION.SDK_INT >= 24) { + if (isHttpOnly) "; httponly" else "" + } else { + "" + } + + return "$name=$value$expires$path$domain$secure$httpOnly" +} + +@Synchronized +fun CookieStore.syncToWebKitCookieManager() { + val webKitCookieManager = android.webkit.CookieManager.getInstance() + + cookies.forEach { + val hostUrl = "${if (it.secure) "https" else "http"}://${it.domain}" + webKitCookieManager.setCookie(hostUrl, it.toSetCookieString()) + } + + webKitCookieManager.flush() +} + +@Synchronized +@Suppress("DEPRECATION") +fun android.webkit.CookieManager.removeAll() { + removeAllCookies(null) + flush() +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/cookies/InternalCookie.kt b/library/src/main/java/io/appwrite/cookies/InternalCookie.kt new file mode 100644 index 0000000..c4ea22a --- /dev/null +++ b/library/src/main/java/io/appwrite/cookies/InternalCookie.kt @@ -0,0 +1,49 @@ +package io.appwrite.cookies + +import android.os.Build +import java.net.HttpCookie + +data class InternalCookie( + val comment: String?, + val commentURL: String?, + val discard: Boolean?, + val domain: String, + val maxAge: Long?, + val name: String, + val path: String?, + val portlist: String?, + val secure: Boolean?, + val value: String, + val version: Int?, + var httpOnly: Boolean? = null +) { + constructor(cookie: HttpCookie) : this( + cookie.comment, + cookie.commentURL, + cookie.discard, + cookie.domain, + cookie.maxAge, + cookie.name, + cookie.path, + cookie.portlist, + cookie.secure, + cookie.value, + cookie.version + ) + + fun toHttpCookie() = HttpCookie(name, value).apply { + comment = this@InternalCookie.comment + commentURL = this@InternalCookie.commentURL + discard = this@InternalCookie.discard == true + domain = this@InternalCookie.domain + maxAge = this@InternalCookie.maxAge ?: 0 + path = this@InternalCookie.path + portlist = this@InternalCookie.portlist + secure = this@InternalCookie.secure == true + version = this@InternalCookie.version ?: 0 + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + isHttpOnly = (this@InternalCookie.httpOnly == true) + } + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/cookies/stores/InMemoryCookieStore.kt b/library/src/main/java/io/appwrite/cookies/stores/InMemoryCookieStore.kt new file mode 100644 index 0000000..7de9ec9 --- /dev/null +++ b/library/src/main/java/io/appwrite/cookies/stores/InMemoryCookieStore.kt @@ -0,0 +1,269 @@ +package io.appwrite.cookies.stores + +import android.os.Build +import android.util.Log +import java.net.CookieStore +import java.net.HttpCookie +import java.net.URI +import java.net.URISyntaxException +import java.util.Collections +import java.util.concurrent.locks.ReentrantLock + +open class InMemoryCookieStore(private val name: String) : CookieStore { + + internal val uriIndex = mutableMapOf>() + private val lock = ReentrantLock(false) + + override fun removeAll(): Boolean { + lock.lock() + + return try { + uriIndex.clear() + uriIndex.isEmpty() + } finally { + lock.unlock() + } + } + + override fun add(uri: URI?, cookie: HttpCookie?) { + if (cookie == null) { + Log.i( + javaClass.simpleName, + "tried to add null cookie in cookie store named $name. Doing nothing." + ) + return + } + + if (uri == null) { + Log.i( + javaClass.simpleName, + "tried to add null URI in cookie store named $name. Doing nothing." + ) + return + } + + lock.lock() + try { + addIndex(getEffectiveURI(uri), cookie) + } finally { + lock.unlock() + } + } + + override fun getCookies(): List { + val cookies = mutableListOf() + + lock.lock() + try { + for (list in uriIndex.values) { + val it = list.iterator() + while (it.hasNext()) { + val cookie = it.next() + if (cookie.hasExpired()) { + it.remove() + } else if (!cookies.contains(cookie)) { + cookies.add(cookie) + } + } + } + } finally { + lock.unlock() + } + + return cookies + } + + override fun getURIs(): List { + val uris = mutableListOf() + + lock.lock() + return try { + uriIndex.keys.toList() + } finally { + uris.addAll(uriIndex.keys) + lock.unlock() + } + } + + override fun remove(uri: URI?, cookie: HttpCookie?): Boolean { + if (cookie == null) { + Log.i( + javaClass.simpleName, + "tried to remove null cookie from cookie store named $name. Doing nothing." + ) + return true + } + + if (uri == null) { + Log.i( + javaClass.simpleName, + "tried to remove null URI from cookie store named $name. Doing nothing." + ) + return true + } + + lock.lock() + + return try { + val lintedURI = getEffectiveURI(uri) + + if (uriIndex[lintedURI] == null) { + false + } else { + val cookies = uriIndex[lintedURI] + cookies?.remove(cookie) ?: false + } + } finally { + lock.unlock() + } + } + + override fun get(uri: URI?): List { + if (uri == null) { + Log.i( + javaClass.simpleName, + "getting cookies from cookie store named $name for null URI results in empty list" + ) + return emptyList() + } + + val cookies = arrayListOf() + + lock.lock() + try { + uri.host?.let { cookies.addAll(getInternal1(it)) } + val internal2 = getInternal2(getEffectiveURI(uri)).filter { !cookies.contains(it) } + cookies.addAll(internal2) + } finally { + lock.unlock() + } + + return cookies + } + + internal fun getEffectiveURI(uri: URI): URI { + return try { + URI(uri.scheme ?: "http", uri.host, null, null, null) + } catch (ignored: URISyntaxException) { + uri + } + } + + private fun addIndex(index: URI, cookie: HttpCookie) { + val cookies = uriIndex[index] + + if (cookies != null) { + cookies.remove(cookie) + cookies.add(cookie) + } else { + val newCookies = mutableListOf() + newCookies.add(cookie) + uriIndex[index] = newCookies + } + } + + private fun netscapeDomainMatches(domain: String?, host: String?): Boolean { + if (domain == null || host == null) { + return false + } + + // If there's no embedded dot in domain and domain is not .local + val isLocalDomain = ".local".equals(domain, ignoreCase = true) + var embeddedDotInDomain = domain.indexOf('.') + if (embeddedDotInDomain == 0) { + embeddedDotInDomain = domain.indexOf('.', 1) + } + if (!isLocalDomain && (embeddedDotInDomain == -1 || embeddedDotInDomain == domain.length - 1)) { + return false + } + + // If the host name contains no dot and the domain name is .local + val firstDotInHost = host.indexOf('.') + if (firstDotInHost == -1 && isLocalDomain) { + return true + } + + val domainLength = domain.length + val lengthDiff = host.length - domainLength + if (lengthDiff == 0) { + // If the host name and the domain name are just string-compare euqal + return host.equals(domain, ignoreCase = true) + } else if (lengthDiff > 0) { + // need to check H & D component + val D = host.substring(lengthDiff) + + // Android-changed: b/26456024 targetSdkVersion based compatibility for domain matching + // Android M and earlier: Cookies with domain "foo.com" would not match "bar.foo.com". + // The RFC dictates that the user agent must treat those domains as if they had a + // leading period and must therefore match "bar.foo.com". + return if (Build.VERSION.SDK_INT <= 23 && !domain.startsWith(".")) { + false + } else D.equals(domain, ignoreCase = true) + } else if (lengthDiff == -1) { + // if domain is actually .host + return domain[0] == '.' && host.equals(domain.substring(1), ignoreCase = true) + } + + return false + } + + private fun getInternal1(host: String): List { + // BEGIN Android-changed: b/25897688 InMemoryCookieStore ignores scheme (http/https) + // Use a separate list to handle cookies that need to be removed so + // that there is no conflict with iterators. + val toRemove = mutableListOf() + val cookies = mutableListOf() + + for ((_, lst) in uriIndex) { + for (c in lst) { + val domain = c.domain + if (c.version == 0 && netscapeDomainMatches( + domain, + host + ) || c.version == 1 && HttpCookie.domainMatches(domain, host) + ) { + if (!c.hasExpired()) { + if (!cookies.contains(c)) { + cookies.add(c) + } + } else { + toRemove.add(c) + } + } + } + // Clean up the cookies that need to be removed + for (c in toRemove) { + lst.remove(c) + } + toRemove.clear() + } + return cookies + } + + private fun getInternal2(comparator: URI): List { + // BEGIN Android-changed: b/25897688 InMemoryCookieStore ignores scheme (http/https) + // Removed cookieJar + val cookies = mutableListOf() + + for (index in uriIndex.keys) { + if (index === comparator || comparator.compareTo(index) == 0) { + val indexedCookies = uriIndex[index] + // Check the list of cookies associated with this domain + if (indexedCookies != null) { + val it = indexedCookies.iterator() + while (it.hasNext()) { + val ck = it.next() + if (!ck.hasExpired()) { + if (!cookies.contains(ck)) + cookies.add(ck) + } else { + it.remove() + } + } + } + } + } + + return cookies + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/cookies/stores/SharedPreferencesCookieStore.kt b/library/src/main/java/io/appwrite/cookies/stores/SharedPreferencesCookieStore.kt new file mode 100644 index 0000000..83c677d --- /dev/null +++ b/library/src/main/java/io/appwrite/cookies/stores/SharedPreferencesCookieStore.kt @@ -0,0 +1,99 @@ +package io.appwrite.cookies.stores + +import io.appwrite.cookies.InternalCookie +import android.content.Context +import android.os.Build +import android.util.Log +import com.google.gson.Gson +import com.google.gson.reflect.TypeToken +import java.net.HttpCookie +import java.net.URI + +open class SharedPreferencesCookieStore( + context: Context, + private val name: String +) : InMemoryCookieStore(name) { + + private val preferences = context.getSharedPreferences(name, Context.MODE_PRIVATE) + private val gson = Gson() + + init { + synchronized(SharedPreferencesCookieStore::class.java) { + preferences.all.forEach { (key, value) -> + try { + val index = URI.create(key) + val listType = object : TypeToken>() {}.type + val internalCookies = + gson.fromJson>(value.toString(), listType) + val cookies = internalCookies.map { it.toHttpCookie() }.toMutableList() + uriIndex[index] = cookies + } catch (exception: Throwable) { + Log.e( + javaClass.simpleName, + "Error while loading key = $key, value = $value from cookie store named $name", + exception + ) + } + } + } + } + + override fun removeAll(): Boolean = + synchronized(SharedPreferencesCookieStore::class.java) { + super.removeAll() + preferences.edit().clear().apply() + true + } + + override fun add(uri: URI?, cookie: HttpCookie?) = + synchronized(SharedPreferencesCookieStore::class.java) { + uri ?: return@synchronized + + super.add(uri, cookie) + val index = getEffectiveURI(uri) + val cookies = uriIndex[index] ?: return@synchronized + + val internalCookies = cookies.map { + InternalCookie(it).apply { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + httpOnly = it.isHttpOnly + } + } + } + + val listType = object : TypeToken>() {}.type + val json = gson.toJson(internalCookies, listType) + + preferences + .edit() + .putString(index.toString(), json) + .apply() + } + + override fun remove(uri: URI?, cookie: HttpCookie?): Boolean = + synchronized(SharedPreferencesCookieStore::class.java) { + uri ?: return false + + val result = super.remove(uri, cookie) + val index = getEffectiveURI(uri) + val cookies = uriIndex[index] + val internalCookies = cookies?.map { + InternalCookie(it).apply { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + httpOnly = it.isHttpOnly + } + } + } + val listType = object : TypeToken>() {}.type + val json = gson.toJson(internalCookies, listType) + + preferences.edit().apply { + when (cookies) { + null -> remove(index.toString()) + else -> putString(index.toString(), json) + } + }.apply() + + return result + } +} \ No newline at end of file From e752f5efdc91e669797702334b0726a5f9bf6885 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 13 Apr 2022 09:58:08 +0545 Subject: [PATCH 029/118] resumable upload support --- README.md | 4 +- library/src/main/java/io/appwrite/Client.kt | 72 ++++++++++------- .../main/java/io/appwrite/services/Account.kt | 80 +++++++++---------- .../java/io/appwrite/services/Database.kt | 16 ++-- .../java/io/appwrite/services/Functions.kt | 12 +-- .../main/java/io/appwrite/services/Locale.kt | 28 +++---- .../main/java/io/appwrite/services/Storage.kt | 19 +++-- .../main/java/io/appwrite/services/Teams.kt | 36 ++++----- 8 files changed, 141 insertions(+), 126 deletions(-) diff --git a/README.md b/README.md index 6051870..2b1d293 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:0.4.1") +implementation("io.appwrite:sdk-for-android:0.5.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 0.4.1 + 0.5.0 ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index fefa174..be3fe85 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -23,6 +23,7 @@ import okhttp3.RequestBody.Companion.toRequestBody import java.io.BufferedInputStream import java.io.BufferedReader import java.io.File +import java.io.RandomAccessFile import java.io.IOException import java.net.CookieManager import java.net.CookiePolicy @@ -245,7 +246,7 @@ class Client @JvmOverloads constructor( headers: Map = mapOf(), params: Map = mapOf(), responseType: Class, - convert: ((Map) -> T)? = null + converter: ((Map) -> T)? = null ): T { val filteredParams = params.filterValues { it != null } @@ -281,7 +282,7 @@ class Client @JvmOverloads constructor( .get() .build() - return awaitResponse(request, responseType, convert) + return awaitResponse(request, responseType, converter) } val body = if (MultipartBody.FORM.toString() == headers["content-type"]) { @@ -318,7 +319,7 @@ class Client @JvmOverloads constructor( .method(method, body) .build() - return awaitResponse(request, responseType, convert) + return awaitResponse(request, responseType, converter) } /** @@ -336,8 +337,9 @@ class Client @JvmOverloads constructor( headers: MutableMap, params: MutableMap, responseType: Class, - convert: ((Map) -> T), + converter: ((Map) -> T), paramName: String, + idParamName: String? = null, onProgress: ((UploadProgress) -> Unit)? = null, ): T { val file = params[paramName] as File @@ -350,58 +352,68 @@ class Client @JvmOverloads constructor( file.asRequestBody() ) return call( - "POST", + method = "POST", path, headers, params, responseType, - convert + converter ) } - val input = file.inputStream().buffered() + val input = RandomAccessFile(file, "r") val buffer = ByteArray(CHUNK_SIZE) var offset = 0L var result: Map<*, *>? = null - generateSequence { - val readBytes = input.read(buffer) - if (readBytes >= 0) { - buffer.copyOf(readBytes) - } else { - input.close() - null - } - }.forEach { + if (idParamName?.isNotEmpty() == true && params[idParamName] != "unique()") { + // Make a request to check if a file already exists + val current = call( + method = "GET", + path = "$path/${params[idParamName]}", + headers = headers, + params = emptyMap(), + responseType = Map::class.java, + ) + val chunksUploaded = current["chunksUploaded"] as Long + offset = (chunksUploaded * CHUNK_SIZE).coerceAtMost(size) + } + + while (offset < size) { + input.seek(offset) + input.read(buffer) + params[paramName] = MultipartBody.Part.createFormData( paramName, file.name, - it.toRequestBody() + buffer.toRequestBody() ) headers["Content-Range"] = "bytes $offset-${((offset + CHUNK_SIZE) - 1).coerceAtMost(size)}/$size" result = call( - "POST", + method = "POST", path, headers, params, - Map::class.java + responseType = Map::class.java ) offset += CHUNK_SIZE headers["x-appwrite-id"] = result!!["\$id"].toString() - onProgress?.invoke(UploadProgress( - id = result!!["\$id"].toString(), - progress = offset.coerceAtMost(size).toDouble()/size * 100, - sizeUploaded = offset.coerceAtMost(size), - chunksTotal = result!!["chunksTotal"].toString().toInt(), - chunksUploaded = result!!["chunksUploaded"].toString().toInt(), - )) + onProgress?.invoke( + UploadProgress( + id = result!!["\$id"].toString(), + progress = offset.coerceAtMost(size).toDouble() / size * 100, + sizeUploaded = offset.coerceAtMost(size), + chunksTotal = result!!["chunksTotal"].toString().toInt(), + chunksUploaded = result!!["chunksUploaded"].toString().toInt(), + ) + ) } - return convert(result as Map) + return converter(result as Map) } /** @@ -409,7 +421,7 @@ class Client @JvmOverloads constructor( * * @param request * @param responseType - * @param convert + * @param converter * * @return [T] */ @@ -417,7 +429,7 @@ class Client @JvmOverloads constructor( private suspend fun awaitResponse( request: Request, responseType: Class, - convert: ((Map) -> T)? = null + converter: ((Map) -> T)? = null ) = suspendCancellableCoroutine { http.newCall(request).enqueue(object : Callback { override fun onFailure(call: Call, e: IOException) { @@ -483,7 +495,7 @@ class Client @JvmOverloads constructor( object : TypeToken>(){}.type ) it.resume( - convert?.invoke(map) ?: map as T + converter?.invoke(map) ?: map as T ) } }) diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 997b7c7..d47a521 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -30,7 +30,7 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.User = { + val converter: (Map) -> io.appwrite.models.User = { io.appwrite.models.User.from(map = it) } return client.call( @@ -39,7 +39,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.User::class.java, - convert = convert, + converter, ) } @@ -77,7 +77,7 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.User = { + val converter: (Map) -> io.appwrite.models.User = { io.appwrite.models.User.from(map = it) } return client.call( @@ -86,7 +86,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.User::class.java, - convert = convert, + converter, ) } @@ -149,7 +149,7 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.User = { + val converter: (Map) -> io.appwrite.models.User = { io.appwrite.models.User.from(map = it) } return client.call( @@ -158,7 +158,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.User::class.java, - convert = convert, + converter, ) } @@ -182,7 +182,7 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Jwt = { + val converter: (Map) -> io.appwrite.models.Jwt = { io.appwrite.models.Jwt.from(map = it) } return client.call( @@ -191,7 +191,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Jwt::class.java, - convert = convert, + converter, ) } @@ -219,7 +219,7 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.LogList = { + val converter: (Map) -> io.appwrite.models.LogList = { io.appwrite.models.LogList.from(map = it) } return client.call( @@ -228,7 +228,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.LogList::class.java, - convert = convert, + converter, ) } @@ -252,7 +252,7 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.User = { + val converter: (Map) -> io.appwrite.models.User = { io.appwrite.models.User.from(map = it) } return client.call( @@ -261,7 +261,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.User::class.java, - convert = convert, + converter, ) } @@ -290,7 +290,7 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.User = { + val converter: (Map) -> io.appwrite.models.User = { io.appwrite.models.User.from(map = it) } return client.call( @@ -299,7 +299,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.User::class.java, - convert = convert, + converter, ) } @@ -319,7 +319,7 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Preferences = { + val converter: (Map) -> io.appwrite.models.Preferences = { io.appwrite.models.Preferences.from(map = it) } return client.call( @@ -328,7 +328,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Preferences::class.java, - convert = convert, + converter, ) } @@ -354,7 +354,7 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.User = { + val converter: (Map) -> io.appwrite.models.User = { io.appwrite.models.User.from(map = it) } return client.call( @@ -363,7 +363,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.User::class.java, - convert = convert, + converter, ) } @@ -397,7 +397,7 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Token = { + val converter: (Map) -> io.appwrite.models.Token = { io.appwrite.models.Token.from(map = it) } return client.call( @@ -406,7 +406,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Token::class.java, - convert = convert, + converter, ) } @@ -447,7 +447,7 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Token = { + val converter: (Map) -> io.appwrite.models.Token = { io.appwrite.models.Token.from(map = it) } return client.call( @@ -456,7 +456,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Token::class.java, - convert = convert, + converter, ) } @@ -477,7 +477,7 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.SessionList = { + val converter: (Map) -> io.appwrite.models.SessionList = { io.appwrite.models.SessionList.from(map = it) } return client.call( @@ -486,7 +486,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.SessionList::class.java, - convert = convert, + converter, ) } @@ -514,7 +514,7 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Session = { + val converter: (Map) -> io.appwrite.models.Session = { io.appwrite.models.Session.from(map = it) } return client.call( @@ -523,7 +523,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Session::class.java, - convert = convert, + converter, ) } @@ -574,7 +574,7 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Session = { + val converter: (Map) -> io.appwrite.models.Session = { io.appwrite.models.Session.from(map = it) } return client.call( @@ -583,7 +583,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Session::class.java, - convert = convert, + converter, ) } @@ -622,7 +622,7 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Token = { + val converter: (Map) -> io.appwrite.models.Token = { io.appwrite.models.Token.from(map = it) } return client.call( @@ -631,7 +631,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Token::class.java, - convert = convert, + converter, ) } @@ -668,7 +668,7 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Session = { + val converter: (Map) -> io.appwrite.models.Session = { io.appwrite.models.Session.from(map = it) } return client.call( @@ -677,7 +677,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Session::class.java, - convert = convert, + converter, ) } @@ -783,7 +783,7 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Session = { + val converter: (Map) -> io.appwrite.models.Session = { io.appwrite.models.Session.from(map = it) } return client.call( @@ -792,7 +792,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Session::class.java, - convert = convert, + converter, ) } @@ -813,7 +813,7 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Session = { + val converter: (Map) -> io.appwrite.models.Session = { io.appwrite.models.Session.from(map = it) } return client.call( @@ -822,7 +822,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Session::class.java, - convert = convert, + converter, ) } @@ -891,7 +891,7 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Token = { + val converter: (Map) -> io.appwrite.models.Token = { io.appwrite.models.Token.from(map = it) } return client.call( @@ -900,7 +900,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Token::class.java, - convert = convert, + converter, ) } @@ -930,7 +930,7 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Token = { + val converter: (Map) -> io.appwrite.models.Token = { io.appwrite.models.Token.from(map = it) } return client.call( @@ -939,7 +939,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Token::class.java, - convert = convert, + converter, ) } diff --git a/library/src/main/java/io/appwrite/services/Database.kt b/library/src/main/java/io/appwrite/services/Database.kt index 8db1ac2..85a04ca 100644 --- a/library/src/main/java/io/appwrite/services/Database.kt +++ b/library/src/main/java/io/appwrite/services/Database.kt @@ -53,7 +53,7 @@ class Database(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.DocumentList = { + val converter: (Map) -> io.appwrite.models.DocumentList = { io.appwrite.models.DocumentList.from(map = it) } return client.call( @@ -62,7 +62,7 @@ class Database(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.DocumentList::class.java, - convert = convert, + converter, ) } @@ -100,7 +100,7 @@ class Database(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Document = { + val converter: (Map) -> io.appwrite.models.Document = { io.appwrite.models.Document.from(map = it) } return client.call( @@ -109,7 +109,7 @@ class Database(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Document::class.java, - convert = convert, + converter, ) } @@ -135,7 +135,7 @@ class Database(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Document = { + val converter: (Map) -> io.appwrite.models.Document = { io.appwrite.models.Document.from(map = it) } return client.call( @@ -144,7 +144,7 @@ class Database(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Document::class.java, - convert = convert, + converter, ) } @@ -179,7 +179,7 @@ class Database(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Document = { + val converter: (Map) -> io.appwrite.models.Document = { io.appwrite.models.Document.from(map = it) } return client.call( @@ -188,7 +188,7 @@ class Database(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Document::class.java, - convert = convert, + converter, ) } diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index 36f6b33..85a1f2c 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -77,7 +77,7 @@ class Functions(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.ExecutionList = { + val converter: (Map) -> io.appwrite.models.ExecutionList = { io.appwrite.models.ExecutionList.from(map = it) } return client.call( @@ -86,7 +86,7 @@ class Functions(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.ExecutionList::class.java, - convert = convert, + converter, ) } @@ -118,7 +118,7 @@ class Functions(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Execution = { + val converter: (Map) -> io.appwrite.models.Execution = { io.appwrite.models.Execution.from(map = it) } return client.call( @@ -127,7 +127,7 @@ class Functions(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Execution::class.java, - convert = convert, + converter, ) } @@ -152,7 +152,7 @@ class Functions(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Execution = { + val converter: (Map) -> io.appwrite.models.Execution = { io.appwrite.models.Execution.from(map = it) } return client.call( @@ -161,7 +161,7 @@ class Functions(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Execution::class.java, - convert = convert, + converter, ) } diff --git a/library/src/main/java/io/appwrite/services/Locale.kt b/library/src/main/java/io/appwrite/services/Locale.kt index c8837b4..21b297c 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -31,7 +31,7 @@ class Locale(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Locale = { + val converter: (Map) -> io.appwrite.models.Locale = { io.appwrite.models.Locale.from(map = it) } return client.call( @@ -40,7 +40,7 @@ class Locale(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Locale::class.java, - convert = convert, + converter, ) } @@ -61,7 +61,7 @@ class Locale(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.ContinentList = { + val converter: (Map) -> io.appwrite.models.ContinentList = { io.appwrite.models.ContinentList.from(map = it) } return client.call( @@ -70,7 +70,7 @@ class Locale(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.ContinentList::class.java, - convert = convert, + converter, ) } @@ -91,7 +91,7 @@ class Locale(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.CountryList = { + val converter: (Map) -> io.appwrite.models.CountryList = { io.appwrite.models.CountryList.from(map = it) } return client.call( @@ -100,7 +100,7 @@ class Locale(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.CountryList::class.java, - convert = convert, + converter, ) } @@ -121,7 +121,7 @@ class Locale(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.CountryList = { + val converter: (Map) -> io.appwrite.models.CountryList = { io.appwrite.models.CountryList.from(map = it) } return client.call( @@ -130,7 +130,7 @@ class Locale(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.CountryList::class.java, - convert = convert, + converter, ) } @@ -151,7 +151,7 @@ class Locale(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.PhoneList = { + val converter: (Map) -> io.appwrite.models.PhoneList = { io.appwrite.models.PhoneList.from(map = it) } return client.call( @@ -160,7 +160,7 @@ class Locale(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.PhoneList::class.java, - convert = convert, + converter, ) } @@ -182,7 +182,7 @@ class Locale(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.CurrencyList = { + val converter: (Map) -> io.appwrite.models.CurrencyList = { io.appwrite.models.CurrencyList.from(map = it) } return client.call( @@ -191,7 +191,7 @@ class Locale(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.CurrencyList::class.java, - convert = convert, + converter, ) } @@ -212,7 +212,7 @@ class Locale(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.LanguageList = { + val converter: (Map) -> io.appwrite.models.LanguageList = { io.appwrite.models.LanguageList.from(map = it) } return client.call( @@ -221,7 +221,7 @@ class Locale(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.LanguageList::class.java, - convert = convert, + converter, ) } diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index 0117a62..927829b 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -51,7 +51,7 @@ class Storage(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.FileList = { + val converter: (Map) -> io.appwrite.models.FileList = { io.appwrite.models.FileList.from(map = it) } return client.call( @@ -60,7 +60,7 @@ class Storage(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.FileList::class.java, - convert = convert, + converter, ) } @@ -112,17 +112,20 @@ class Storage(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "multipart/form-data" ) - val convert: (Map) -> io.appwrite.models.File = { + val converter: (Map) -> io.appwrite.models.File = { io.appwrite.models.File.from(map = it) } + val idParamName: String? = "fileId" + idParamName = "fileId" val paramName = "file" return client.chunkedUpload( path, headers, params, responseType = io.appwrite.models.File::class.java, - convert = convert, + converter, paramName, + idParamName, onProgress, ) } @@ -149,7 +152,7 @@ class Storage(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.File = { + val converter: (Map) -> io.appwrite.models.File = { io.appwrite.models.File.from(map = it) } return client.call( @@ -158,7 +161,7 @@ class Storage(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.File::class.java, - convert = convert, + converter, ) } @@ -190,7 +193,7 @@ class Storage(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.File = { + val converter: (Map) -> io.appwrite.models.File = { io.appwrite.models.File.from(map = it) } return client.call( @@ -199,7 +202,7 @@ class Storage(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.File::class.java, - convert = convert, + converter, ) } diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index f58df7c..e8b232c 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -49,7 +49,7 @@ class Teams(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.TeamList = { + val converter: (Map) -> io.appwrite.models.TeamList = { io.appwrite.models.TeamList.from(map = it) } return client.call( @@ -58,7 +58,7 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.TeamList::class.java, - convert = convert, + converter, ) } @@ -90,7 +90,7 @@ class Teams(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Team = { + val converter: (Map) -> io.appwrite.models.Team = { io.appwrite.models.Team.from(map = it) } return client.call( @@ -99,7 +99,7 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Team::class.java, - convert = convert, + converter, ) } @@ -122,7 +122,7 @@ class Teams(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Team = { + val converter: (Map) -> io.appwrite.models.Team = { io.appwrite.models.Team.from(map = it) } return client.call( @@ -131,7 +131,7 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Team::class.java, - convert = convert, + converter, ) } @@ -158,7 +158,7 @@ class Teams(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Team = { + val converter: (Map) -> io.appwrite.models.Team = { io.appwrite.models.Team.from(map = it) } return client.call( @@ -167,7 +167,7 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Team::class.java, - convert = convert, + converter, ) } @@ -238,7 +238,7 @@ class Teams(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.MembershipList = { + val converter: (Map) -> io.appwrite.models.MembershipList = { io.appwrite.models.MembershipList.from(map = it) } return client.call( @@ -247,7 +247,7 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.MembershipList::class.java, - convert = convert, + converter, ) } @@ -296,7 +296,7 @@ class Teams(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Membership = { + val converter: (Map) -> io.appwrite.models.Membership = { io.appwrite.models.Membership.from(map = it) } return client.call( @@ -305,7 +305,7 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Membership::class.java, - convert = convert, + converter, ) } @@ -331,7 +331,7 @@ class Teams(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.MembershipList = { + val converter: (Map) -> io.appwrite.models.MembershipList = { io.appwrite.models.MembershipList.from(map = it) } return client.call( @@ -340,7 +340,7 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.MembershipList::class.java, - convert = convert, + converter, ) } @@ -370,7 +370,7 @@ class Teams(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Membership = { + val converter: (Map) -> io.appwrite.models.Membership = { io.appwrite.models.Membership.from(map = it) } return client.call( @@ -379,7 +379,7 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Membership::class.java, - convert = convert, + converter, ) } @@ -448,7 +448,7 @@ class Teams(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Membership = { + val converter: (Map) -> io.appwrite.models.Membership = { io.appwrite.models.Membership.from(map = it) } return client.call( @@ -457,7 +457,7 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Membership::class.java, - convert = convert, + converter, ) } From d739daa65a1ed22d4e0c48796e5f9b35f7f7b440 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 13 Apr 2022 18:27:30 +1200 Subject: [PATCH 030/118] Merge conflict fix --- library/src/main/java/io/appwrite/services/Storage.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index 927829b..a632fd2 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -115,8 +115,7 @@ class Storage(client: Client) : Service(client) { val converter: (Map) -> io.appwrite.models.File = { io.appwrite.models.File.from(map = it) } - val idParamName: String? = "fileId" - idParamName = "fileId" + val idParamName: String? = "fileId" val paramName = "file" return client.chunkedUpload( path, From 12da1a341d461ba051fe618fcfe700c841a06a1a Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Mon, 16 May 2022 18:36:09 +0200 Subject: [PATCH 031/118] feat: support for 0.14.x --- README.md | 8 +-- .../account/{delete.md => update-status.md} | 2 +- .../account/{delete.md => update-status.md} | 2 +- .../main/java/io/appwrite/models/Execution.kt | 10 +-- .../java/io/appwrite/models/Membership.kt | 35 ++++++---- .../main/java/io/appwrite/services/Account.kt | 70 ++++++++++--------- .../main/java/io/appwrite/services/Avatars.kt | 42 +++++++++-- .../java/io/appwrite/services/Database.kt | 12 ++-- .../main/java/io/appwrite/services/Storage.kt | 3 +- .../main/java/io/appwrite/services/Teams.kt | 6 +- 10 files changed, 117 insertions(+), 73 deletions(-) rename docs/examples/java/account/{delete.md => update-status.md} (96%) rename docs/examples/kotlin/account/{delete.md => update-status.md} (93%) diff --git a/README.md b/README.md index 2b1d293..1f076d6 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-0.13.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-0.14.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 0.13.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).** +**This SDK is compatible with Appwrite server version 0.14.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:0.5.0") +implementation("io.appwrite:sdk-for-android:0.6.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 0.5.0 + 0.6.0 ``` diff --git a/docs/examples/java/account/delete.md b/docs/examples/java/account/update-status.md similarity index 96% rename from docs/examples/java/account/delete.md rename to docs/examples/java/account/update-status.md index aec96f1..0ef6a6e 100644 --- a/docs/examples/java/account/delete.md +++ b/docs/examples/java/account/update-status.md @@ -18,7 +18,7 @@ public class MainActivity extends AppCompatActivity { Account account = new Account(client); - account.delete(new Continuation() { + account.updateStatus(new Continuation() { @NotNull @Override public CoroutineContext getContext() { diff --git a/docs/examples/kotlin/account/delete.md b/docs/examples/kotlin/account/update-status.md similarity index 93% rename from docs/examples/kotlin/account/delete.md rename to docs/examples/kotlin/account/update-status.md index 7bfe95e..e138751 100644 --- a/docs/examples/kotlin/account/delete.md +++ b/docs/examples/kotlin/account/update-status.md @@ -17,7 +17,7 @@ class MainActivity : AppCompatActivity() { val account = Account(client) GlobalScope.launch { - val response = account.delete() + val response = account.updateStatus() val json = response.body?.string() } } diff --git a/library/src/main/java/io/appwrite/models/Execution.kt b/library/src/main/java/io/appwrite/models/Execution.kt index c8f2ae2..06c2811 100644 --- a/library/src/main/java/io/appwrite/models/Execution.kt +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -56,11 +56,11 @@ data class Execution( val statusCode: Long, /** - * The script stdout output string. Logs the last 4,000 characters of the execution stdout output. + * The script response output string. Logs the last 4,000 characters of the execution response output. * */ - @SerializedName("stdout") - val stdout: String, + @SerializedName("response") + val response: String, /** * The script stderr output string. Logs the last 4,000 characters of the execution stderr output @@ -86,7 +86,7 @@ data class Execution( trigger = map["trigger"] as String, status = map["status"] as String, statusCode = (map["statusCode"] as Number).toLong(), - stdout = map["stdout"] as String, + response = map["response"] as String, stderr = map["stderr"] as String, time = (map["time"] as Number).toDouble() ) @@ -100,7 +100,7 @@ data class Execution( "trigger" to trigger as Any, "status" to status as Any, "statusCode" to statusCode as Any, - "stdout" to stdout as Any, + "response" to response as Any, "stderr" to stderr as Any, "time" to time as Any ) diff --git a/library/src/main/java/io/appwrite/models/Membership.kt b/library/src/main/java/io/appwrite/models/Membership.kt index 45b42c8..3df7b69 100644 --- a/library/src/main/java/io/appwrite/models/Membership.kt +++ b/library/src/main/java/io/appwrite/models/Membership.kt @@ -21,25 +21,32 @@ data class Membership( val userId: String, /** - * Team ID. + * User name. * */ - @SerializedName("teamId") - val teamId: String, + @SerializedName("userName") + val userName: String, /** - * User name. + * User email address. * */ - @SerializedName("name") - val name: String, + @SerializedName("userEmail") + val userEmail: String, /** - * User email address. + * Team ID. + * + */ + @SerializedName("teamId") + val teamId: String, + + /** + * Team name. * */ - @SerializedName("email") - val email: String, + @SerializedName("teamName") + val teamName: String, /** * Date, the user has been invited to join the team in Unix timestamp. @@ -74,9 +81,10 @@ data class Membership( fun from(map: Map) = Membership( id = map["\$id"] as String, userId = map["userId"] as String, + userName = map["userName"] as String, + userEmail = map["userEmail"] as String, teamId = map["teamId"] as String, - name = map["name"] as String, - email = map["email"] as String, + teamName = map["teamName"] as String, invited = (map["invited"] as Number).toLong(), joined = (map["joined"] as Number).toLong(), confirm = map["confirm"] as Boolean, @@ -87,9 +95,10 @@ data class Membership( fun toMap(): Map = mapOf( "\$id" to id as Any, "userId" to userId as Any, + "userName" to userName as Any, + "userEmail" to userEmail as Any, "teamId" to teamId as Any, - "name" to name as Any, - "email" to email as Any, + "teamName" to teamName as Any, "invited" to invited as Any, "joined" to joined as Any, "confirm" to confirm as Any, diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index d47a521..8f144de 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -90,35 +90,6 @@ class Account(client: Client) : Service(client) { ) } - /** - * Delete Account - * - * Delete a currently logged in user account. Behind the scene, the user - * record is not deleted but permanently blocked from any access. This is done - * to avoid deleted accounts being overtaken by new users with the same email - * address. Any user-related resources like documents or storage files should - * be deleted separately. - * - * @return [Any] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun delete(): Any { - val path = "/account" - val params = mutableMapOf( - ) - val headers = mutableMapOf( - "content-type" to "application/json" - ) - return client.call( - "DELETE", - path, - headers, - params, - responseType = Any::class.java, - ) - } - /** * Update Account Email * @@ -270,7 +241,7 @@ class Account(client: Client) : Service(client) { * * 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 and Team Invites, oldPassword is optional. + * 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. @@ -697,10 +668,10 @@ class Account(client: Client) : Service(client) { * user.. * * - * @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, bitbucket, bitly, box, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, notion, paypal, paypalSandbox, salesforce, slack, spotify, tradeshift, tradeshiftBox, twitch, vk, yahoo, yammer, yandex, wordpress, stripe. + * @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, bitbucket, bitly, box, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, notion, okta, paypal, paypalSandbox, salesforce, slack, spotify, tradeshift, tradeshiftBox, twitch, zoom, yahoo, yammer, yandex, wordpress, stripe. * @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. + * @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 128 characters long. * */ @JvmOverloads @@ -799,6 +770,10 @@ class Account(client: Client) : Service(client) { /** * Update 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. + * * @param sessionId Session ID. Use the string 'current' to update the current device session. * @return [io.appwrite.models.Session] */ @@ -857,6 +832,37 @@ class Account(client: Client) : Service(client) { ) } + /** + * Update Account 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.User] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updateStatus(): io.appwrite.models.User { + val path = "/account/status" + val params = mutableMapOf( + ) + val headers = mutableMapOf( + "content-type" to "application/json" + ) + val converter: (Map) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.User::class.java, + converter, + ) + } + /** * Create Email Verification * diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt index 09afbc6..20e1f54 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -16,9 +16,14 @@ class Avatars(client: Client) : Service(client) { * 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 - * /account/sessions endpoint. Use width, height and quality arguments to - * change the output settings. + * 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. @@ -55,6 +60,12 @@ class Avatars(client: Client) : Service(client) { * 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. @@ -119,6 +130,12 @@ class Avatars(client: Client) : Service(client) { * 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. + * + * 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. @@ -156,10 +173,16 @@ class Avatars(client: Client) : Service(client) { * 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. - * @param height Resize preview image height, Pass an integer between 0 to 2000. + * @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] */ @JvmOverloads @@ -197,6 +220,12 @@ class Avatars(client: Client) : Service(client) { * 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. @@ -236,9 +265,10 @@ class Avatars(client: Client) : Service(client) { * * 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 0 to 1000. Defaults to 400. + * @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] diff --git a/library/src/main/java/io/appwrite/services/Database.kt b/library/src/main/java/io/appwrite/services/Database.kt index 85a04ca..74bced3 100644 --- a/library/src/main/java/io/appwrite/services/Database.kt +++ b/library/src/main/java/io/appwrite/services/Database.kt @@ -19,13 +19,13 @@ class Database(client: Client) : Service(client) { * modes](/docs/admin). * * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). - * @param queries Array of query strings. + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/database#querying-documents). Maximum of 100 queries are allowed, each 128 characters long. * @param limit Maximum number of documents to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. * @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) * @param cursor ID of the document used as the starting point for the query, excluding the document itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) * @param cursorDirection Direction of the cursor. - * @param orderAttributes Array of attributes used to sort results. - * @param orderTypes Array of order directions for sorting attribtues. Possible values are DESC for descending order, or ASC for ascending order. + * @param orderAttributes Array of attributes used to sort results. Maximum of 100 order attributes are allowed, each 128 characters long. + * @param orderTypes Array of order directions for sorting attribtues. Possible values are DESC for descending order, or ASC for ascending order. Maximum of 100 order types are allowed. * @return [io.appwrite.models.DocumentList] */ @JvmOverloads @@ -156,7 +156,7 @@ class Database(client: Client) : Service(client) { * * @param collectionId Collection ID. * @param documentId Document ID. - * @param data Document data as JSON object. + * @param data Document data as JSON object. Include only attribute and value pairs to be updated. * @param read An array of strings with read permissions. By default inherits the existing read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. * @param write An array of strings with write permissions. By default inherits the existing write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. * @return [io.appwrite.models.Document] @@ -195,9 +195,7 @@ class Database(client: Client) : Service(client) { /** * Delete Document * - * Delete a document by its unique ID. This endpoint deletes only the parent - * documents, its attributes and relations to other documents. Child documents - * **will not** be deleted. + * Delete a document by its unique ID. * * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). * @param documentId Document ID. diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index a632fd2..927829b 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -115,7 +115,8 @@ class Storage(client: Client) : Service(client) { val converter: (Map) -> io.appwrite.models.File = { io.appwrite.models.File.from(map = it) } - val idParamName: String? = "fileId" + val idParamName: String? = "fileId" + idParamName = "fileId" val paramName = "file" return client.chunkedUpload( path, diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index e8b232c..5b74d1d 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -71,7 +71,7 @@ class Teams(client: Client) : Service(client) { * * @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 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). Max length for each role is 32 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] */ @JvmOverloads @@ -272,7 +272,7 @@ class Teams(client: Client) : Service(client) { * * @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). Max length for each role is 32 chars. + * @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] @@ -353,7 +353,7 @@ class Teams(client: Client) : Service(client) { * * @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). Max length for each role is 32 chars. + * @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] */ @JvmOverloads From bbed3c1d79e7f89a426a8a43946112daf19686ef Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Tue, 17 May 2022 10:45:35 +0200 Subject: [PATCH 032/118] feat: add response format for 0.14.0 --- library/src/main/java/io/appwrite/Client.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index be3fe85..4e5e78f 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -85,7 +85,7 @@ class Client @JvmOverloads constructor( "origin" to "appwrite-android://${context.packageName}", "user-agent" to "${context.packageName}/${appVersion}, ${System.getProperty("http.agent")}", "x-sdk-version" to "appwrite:android:${BuildConfig.SDK_VERSION}", - "x-appwrite-response-format" to "0.13.0" + "x-appwrite-response-format" to "0.14.0" ) config = mutableMapOf() From 0fdccea7ddb57184eed26e8bcc8e494023ba4537 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Tue, 17 May 2022 14:15:18 +0200 Subject: [PATCH 033/118] fix: realtime event payload --- docs/examples/java/storage/create-file.md | 2 +- docs/examples/kotlin/storage/create-file.md | 2 +- library/src/main/java/io/appwrite/models/RealtimeModels.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/examples/java/storage/create-file.md b/docs/examples/java/storage/create-file.md index bc1df1a..3b7099e 100644 --- a/docs/examples/java/storage/create-file.md +++ b/docs/examples/java/storage/create-file.md @@ -21,7 +21,7 @@ public class MainActivity extends AppCompatActivity { storage.createFile( "[BUCKET_ID]", "[FILE_ID]", - File("./path-to-files/image.jpg"), + File("file.png"), new Continuation() { @NotNull @Override diff --git a/docs/examples/kotlin/storage/create-file.md b/docs/examples/kotlin/storage/create-file.md index 437bdeb..c5cc6a3 100644 --- a/docs/examples/kotlin/storage/create-file.md +++ b/docs/examples/kotlin/storage/create-file.md @@ -20,7 +20,7 @@ class MainActivity : AppCompatActivity() { val response = storage.createFile( bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]", - file = File("./path-to-files/image.jpg"), + file = File("file.png"), ) val json = response.body?.string() } diff --git a/library/src/main/java/io/appwrite/models/RealtimeModels.kt b/library/src/main/java/io/appwrite/models/RealtimeModels.kt index 4237638..9041554 100644 --- a/library/src/main/java/io/appwrite/models/RealtimeModels.kt +++ b/library/src/main/java/io/appwrite/models/RealtimeModels.kt @@ -21,7 +21,7 @@ open class RealtimeResponse( ) data class RealtimeResponseEvent( - val event: String, + val events: Collection, val channels: Collection, val timestamp: Long, var payload: T From 384f9fae2050d8ccb1dafe9470c33ee5a04f7538 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Tue, 17 May 2022 19:43:55 +0400 Subject: [PATCH 034/118] feat: update for appwrite 0.14.x --- .github/workflows/publish.yml | 6 +- LICENSE.md | 2 +- README.md | 22 +- build.gradle | 6 +- .../account/create-magic-u-r-l-session.md | 2 +- docs/examples/java/account/create.md | 2 +- .../account/update-magic-u-r-l-session.md | 2 +- docs/examples/java/account/update-session.md | 48 +++ .../account/{delete.md => update-status.md} | 2 +- .../examples/java/database/create-document.md | 2 +- docs/examples/java/functions/retry-build.md | 50 +++ docs/examples/java/storage/create-file.md | 5 +- docs/examples/java/storage/delete-file.md | 1 + .../java/storage/get-file-download.md | 1 + .../examples/java/storage/get-file-preview.md | 1 + docs/examples/java/storage/get-file-view.md | 1 + docs/examples/java/storage/get-file.md | 1 + docs/examples/java/storage/list-files.md | 1 + docs/examples/java/storage/update-file.md | 3 +- docs/examples/java/teams/create.md | 2 +- .../account/create-magic-u-r-l-session.md | 2 +- docs/examples/kotlin/account/create.md | 2 +- .../account/update-magic-u-r-l-session.md | 2 +- .../examples/kotlin/account/update-session.md | 26 ++ .../account/{delete.md => update-status.md} | 2 +- .../kotlin/database/create-document.md | 2 +- docs/examples/kotlin/functions/retry-build.md | 28 ++ docs/examples/kotlin/storage/create-file.md | 5 +- docs/examples/kotlin/storage/delete-file.md | 1 + .../kotlin/storage/get-file-download.md | 1 + .../kotlin/storage/get-file-preview.md | 1 + docs/examples/kotlin/storage/get-file-view.md | 1 + docs/examples/kotlin/storage/get-file.md | 1 + docs/examples/kotlin/storage/list-files.md | 1 + docs/examples/kotlin/storage/update-file.md | 3 +- docs/examples/kotlin/teams/create.md | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- library/build.gradle | 3 +- library/src/main/java/io/appwrite/Client.kt | 133 +++++++- library/src/main/java/io/appwrite/Query.kt | 4 +- .../java/io/appwrite/cookies/Extensions.kt | 53 +++ .../io/appwrite/cookies/InternalCookie.kt | 49 +++ .../cookies/stores/InMemoryCookieStore.kt | 269 +++++++++++++++ .../stores/SharedPreferencesCookieStore.kt | 99 ++++++ .../appwrite/exceptions/AppwriteException.kt | 1 + .../main/java/io/appwrite/models/Continent.kt | 4 + .../java/io/appwrite/models/ContinentList.kt | 12 +- .../main/java/io/appwrite/models/Country.kt | 4 + .../java/io/appwrite/models/CountryList.kt | 12 +- .../main/java/io/appwrite/models/Currency.kt | 13 +- .../java/io/appwrite/models/CurrencyList.kt | 12 +- .../main/java/io/appwrite/models/Document.kt | 6 + .../java/io/appwrite/models/DocumentList.kt | 12 +- .../main/java/io/appwrite/models/Execution.kt | 32 +- .../java/io/appwrite/models/ExecutionList.kt | 12 +- .../src/main/java/io/appwrite/models/File.kt | 45 ++- .../main/java/io/appwrite/models/FileList.kt | 12 +- .../src/main/java/io/appwrite/models/Jwt.kt | 3 + .../main/java/io/appwrite/models/Language.kt | 5 + .../java/io/appwrite/models/LanguageList.kt | 12 +- .../main/java/io/appwrite/models/Locale.kt | 9 + .../src/main/java/io/appwrite/models/Log.kt | 25 +- .../main/java/io/appwrite/models/LogList.kt | 12 +- .../java/io/appwrite/models/Membership.kt | 44 ++- .../java/io/appwrite/models/MembershipList.kt | 12 +- .../src/main/java/io/appwrite/models/Phone.kt | 5 + .../main/java/io/appwrite/models/PhoneList.kt | 12 +- .../java/io/appwrite/models/Preferences.kt | 2 + .../java/io/appwrite/models/RealtimeModels.kt | 3 +- .../main/java/io/appwrite/models/Session.kt | 52 ++- .../java/io/appwrite/models/SessionList.kt | 12 +- .../src/main/java/io/appwrite/models/Team.kt | 16 +- .../main/java/io/appwrite/models/TeamList.kt | 12 +- .../src/main/java/io/appwrite/models/Token.kt | 8 +- .../java/io/appwrite/models/UploadProgress.kt | 9 + .../src/main/java/io/appwrite/models/User.kt | 14 +- .../main/java/io/appwrite/services/Account.kt | 310 ++++++++++-------- .../main/java/io/appwrite/services/Avatars.kt | 56 +++- .../java/io/appwrite/services/Database.kt | 80 +++-- .../java/io/appwrite/services/Functions.kt | 75 +++-- .../main/java/io/appwrite/services/Locale.kt | 56 ++-- .../main/java/io/appwrite/services/Storage.kt | 140 +++++--- .../main/java/io/appwrite/services/Teams.kt | 188 ++++++----- 83 files changed, 1672 insertions(+), 529 deletions(-) create mode 100644 docs/examples/java/account/update-session.md rename docs/examples/java/account/{delete.md => update-status.md} (96%) create mode 100644 docs/examples/java/functions/retry-build.md create mode 100644 docs/examples/kotlin/account/update-session.md rename docs/examples/kotlin/account/{delete.md => update-status.md} (93%) create mode 100644 docs/examples/kotlin/functions/retry-build.md create mode 100644 library/src/main/java/io/appwrite/cookies/Extensions.kt create mode 100644 library/src/main/java/io/appwrite/cookies/InternalCookie.kt create mode 100644 library/src/main/java/io/appwrite/cookies/stores/InMemoryCookieStore.kt create mode 100644 library/src/main/java/io/appwrite/cookies/stores/SharedPreferencesCookieStore.kt create mode 100644 library/src/main/java/io/appwrite/models/UploadProgress.kt diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5b97b1c..ae9090b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -28,7 +28,7 @@ jobs: # Builds the release artifacts of the library - name: Build Release Artifacts - run: ./gradlew --info library:assembleRelease + run: ./gradlew library:assembleRelease # Generates other artifacts (javadocJar is optional) - name: Generate Source jar @@ -39,10 +39,10 @@ jobs: run: | if ${{ endswith(github.event.release.tag_name, '-SNAPSHOT') }}; then echo "Publising Snapshot Version ${{ github.event.release.tag_name}} to Snapshot repository" - ./gradlew publishReleasePublicationToSonatypeRepository + ./gradlew publishToSonatype else echo "Publising Release Version ${{ github.event.release.tag_name}} to Staging repository" - ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository + ./gradlew publishToSonatype --max-workers 1 closeAndReleaseSonatypeStagingRepository fi env: OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} diff --git a/LICENSE.md b/LICENSE.md index d73a6e9..96201c4 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2021 Appwrite (https://appwrite.io) and individual contributors. +Copyright (c) 2022 Appwrite (https://appwrite.io) and individual contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/README.md b/README.md index c2e2888..1f076d6 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-0.11.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-0.14.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_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io) +[![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 0.11.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).** +**This SDK is compatible with Appwrite server version 0.14.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,11 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -<<<<<<< HEAD -implementation("io.appwrite:sdk-for-android:0.3.0-SNAPSHOT") -======= -implementation("io.appwrite:sdk-for-android:0.2.1") ->>>>>>> de10694090d63c4d6b8d39a3f651f5b6cc21d0c0 +implementation("io.appwrite:sdk-for-android:0.6.0") ``` ### Maven @@ -53,11 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android -<<<<<<< HEAD - 0.3.0-SNAPSHOT -======= - 0.2.1 ->>>>>>> de10694090d63c4d6b8d39a3f651f5b6cc21d0c0 + 0.6.0 ``` @@ -116,6 +108,7 @@ When trying to connect to Appwrite from an emulator or a mobile device, localhos // Register User val account = Account(client) val response = account.create( + "[USER_ID]", "email@example.com", "password" ) @@ -134,6 +127,7 @@ val client = Client(context) val account = Account(client) val response = account.create( + "[USER_ID]", "email@example.com", "password" ) @@ -144,7 +138,7 @@ The Appwrite Android SDK raises an `AppwriteException` object with `message`, `c ```kotlin try { - var response = account.create("email@example.com", "password") + var response = account.create("[USER_ID]", "email@example.com", "password") Log.d("Appwrite response", response.body?.string()) } catch(e : AppwriteException) { Log.e("AppwriteException",e.message.toString()) diff --git a/build.gradle b/build.gradle index 9d95f15..79f6b0b 100644 --- a/build.gradle +++ b/build.gradle @@ -2,15 +2,15 @@ apply plugin: 'io.github.gradle-nexus.publish-plugin' // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = "1.4.31" - version '0.2.1' + ext.kotlin_version = "1.5.31" + version System.getenv("SDK_VERSION") repositories { maven { url "https://plugins.gradle.org/m2/" } google() mavenCentral() } dependencies { - classpath "com.android.tools.build:gradle:7.0.3" + classpath "com.android.tools.build:gradle:4.2.0" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'io.github.gradle-nexus:publish-plugin:1.1.0' 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 de630ad..6c9fa7c 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 @@ -19,7 +19,7 @@ public class MainActivity extends AppCompatActivity { Account account = new Account(client); account.createMagicURLSession( - "", + "[USER_ID]", "email@example.com", new Continuation() { @NotNull diff --git a/docs/examples/java/account/create.md b/docs/examples/java/account/create.md index 1f10de2..11a5168 100644 --- a/docs/examples/java/account/create.md +++ b/docs/examples/java/account/create.md @@ -19,7 +19,7 @@ public class MainActivity extends AppCompatActivity { Account account = new Account(client); account.create( - "", + "[USER_ID]", "email@example.com", "password", new Continuation() { 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 f8375b9..d0734e1 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 @@ -19,7 +19,7 @@ public class MainActivity extends AppCompatActivity { Account account = new Account(client); account.updateMagicURLSession( - "", + "[USER_ID]", "[SECRET]" new Continuation() { @NotNull diff --git a/docs/examples/java/account/update-session.md b/docs/examples/java/account/update-session.md new file mode 100644 index 0000000..80aff11 --- /dev/null +++ b/docs/examples/java/account/update-session.md @@ -0,0 +1,48 @@ +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.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 diff --git a/docs/examples/java/account/delete.md b/docs/examples/java/account/update-status.md similarity index 96% rename from docs/examples/java/account/delete.md rename to docs/examples/java/account/update-status.md index aec96f1..0ef6a6e 100644 --- a/docs/examples/java/account/delete.md +++ b/docs/examples/java/account/update-status.md @@ -18,7 +18,7 @@ public class MainActivity extends AppCompatActivity { Account account = new Account(client); - account.delete(new Continuation() { + account.updateStatus(new Continuation() { @NotNull @Override public CoroutineContext getContext() { diff --git a/docs/examples/java/database/create-document.md b/docs/examples/java/database/create-document.md index 7f1ff4c..059a42e 100644 --- a/docs/examples/java/database/create-document.md +++ b/docs/examples/java/database/create-document.md @@ -20,7 +20,7 @@ public class MainActivity extends AppCompatActivity { database.createDocument( "[COLLECTION_ID]", - "", + "[DOCUMENT_ID]", mapOf( "a" to "b" ), new Continuation() { @NotNull diff --git a/docs/examples/java/functions/retry-build.md b/docs/examples/java/functions/retry-build.md new file mode 100644 index 0000000..96501a0 --- /dev/null +++ b/docs/examples/java/functions/retry-build.md @@ -0,0 +1,50 @@ +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/storage/create-file.md b/docs/examples/java/storage/create-file.md index f20ba26..3b7099e 100644 --- a/docs/examples/java/storage/create-file.md +++ b/docs/examples/java/storage/create-file.md @@ -19,8 +19,9 @@ public class MainActivity extends AppCompatActivity { Storage storage = new Storage(client); storage.createFile( - "", - File("./path-to-files/image.jpg"), + "[BUCKET_ID]", + "[FILE_ID]", + File("file.png"), new Continuation() { @NotNull @Override diff --git a/docs/examples/java/storage/delete-file.md b/docs/examples/java/storage/delete-file.md index aafae2c..585593a 100644 --- a/docs/examples/java/storage/delete-file.md +++ b/docs/examples/java/storage/delete-file.md @@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity { Storage storage = new Storage(client); storage.deleteFile( + "[BUCKET_ID]", "[FILE_ID]" new Continuation() { @NotNull diff --git a/docs/examples/java/storage/get-file-download.md b/docs/examples/java/storage/get-file-download.md index d56f293..b162248 100644 --- a/docs/examples/java/storage/get-file-download.md +++ b/docs/examples/java/storage/get-file-download.md @@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity { Storage storage = new Storage(client); storage.getFileDownload( + "[BUCKET_ID]", "[FILE_ID]" new Continuation() { @NotNull diff --git a/docs/examples/java/storage/get-file-preview.md b/docs/examples/java/storage/get-file-preview.md index 00b54f2..583c1a0 100644 --- a/docs/examples/java/storage/get-file-preview.md +++ b/docs/examples/java/storage/get-file-preview.md @@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity { Storage storage = new Storage(client); storage.getFilePreview( + "[BUCKET_ID]", "[FILE_ID]", new Continuation() { @NotNull diff --git a/docs/examples/java/storage/get-file-view.md b/docs/examples/java/storage/get-file-view.md index 087a48b..21a5074 100644 --- a/docs/examples/java/storage/get-file-view.md +++ b/docs/examples/java/storage/get-file-view.md @@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity { Storage storage = new Storage(client); storage.getFileView( + "[BUCKET_ID]", "[FILE_ID]" new Continuation() { @NotNull diff --git a/docs/examples/java/storage/get-file.md b/docs/examples/java/storage/get-file.md index 9473cab..61740a9 100644 --- a/docs/examples/java/storage/get-file.md +++ b/docs/examples/java/storage/get-file.md @@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity { Storage storage = new Storage(client); storage.getFile( + "[BUCKET_ID]", "[FILE_ID]" new Continuation() { @NotNull diff --git a/docs/examples/java/storage/list-files.md b/docs/examples/java/storage/list-files.md index e2eab69..a7ea06e 100644 --- a/docs/examples/java/storage/list-files.md +++ b/docs/examples/java/storage/list-files.md @@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity { Storage storage = new Storage(client); storage.listFiles( + "[BUCKET_ID]", new Continuation() { @NotNull @Override diff --git a/docs/examples/java/storage/update-file.md b/docs/examples/java/storage/update-file.md index 1477615..b3e8e90 100644 --- a/docs/examples/java/storage/update-file.md +++ b/docs/examples/java/storage/update-file.md @@ -19,9 +19,8 @@ public class MainActivity extends AppCompatActivity { Storage storage = new Storage(client); storage.updateFile( + "[BUCKET_ID]", "[FILE_ID]", - listOf(), - listOf() new Continuation() { @NotNull @Override diff --git a/docs/examples/java/teams/create.md b/docs/examples/java/teams/create.md index c3e3093..3723b30 100644 --- a/docs/examples/java/teams/create.md +++ b/docs/examples/java/teams/create.md @@ -19,7 +19,7 @@ public class MainActivity extends AppCompatActivity { Teams teams = new Teams(client); teams.create( - "", + "[TEAM_ID]", "[NAME]", new Continuation() { @NotNull 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 7ac9a30..15fa1c7 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 @@ -18,7 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = account.createMagicURLSession( - userId = "", + userId = "[USER_ID]", email = "email@example.com", ) val json = response.body?.string() diff --git a/docs/examples/kotlin/account/create.md b/docs/examples/kotlin/account/create.md index 068fa5f..ab2534f 100644 --- a/docs/examples/kotlin/account/create.md +++ b/docs/examples/kotlin/account/create.md @@ -18,7 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = account.create( - userId = "", + userId = "[USER_ID]", 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 923574e..3fe1b7c 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 @@ -18,7 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = account.updateMagicURLSession( - userId = "", + userId = "[USER_ID]", secret = "[SECRET]" ) val json = response.body?.string() diff --git a/docs/examples/kotlin/account/update-session.md b/docs/examples/kotlin/account/update-session.md new file mode 100644 index 0000000..465320d --- /dev/null +++ b/docs/examples/kotlin/account/update-session.md @@ -0,0 +1,26 @@ +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.updateSession( + sessionId = "[SESSION_ID]" + ) + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete.md b/docs/examples/kotlin/account/update-status.md similarity index 93% rename from docs/examples/kotlin/account/delete.md rename to docs/examples/kotlin/account/update-status.md index 7bfe95e..e138751 100644 --- a/docs/examples/kotlin/account/delete.md +++ b/docs/examples/kotlin/account/update-status.md @@ -17,7 +17,7 @@ class MainActivity : AppCompatActivity() { val account = Account(client) GlobalScope.launch { - val response = account.delete() + val response = account.updateStatus() val json = response.body?.string() } } diff --git a/docs/examples/kotlin/database/create-document.md b/docs/examples/kotlin/database/create-document.md index 89ada64..d207383 100644 --- a/docs/examples/kotlin/database/create-document.md +++ b/docs/examples/kotlin/database/create-document.md @@ -19,7 +19,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = database.createDocument( collectionId = "[COLLECTION_ID]", - documentId = "", + documentId = "[DOCUMENT_ID]", data = mapOf( "a" to "b" ), ) val json = response.body?.string() diff --git a/docs/examples/kotlin/functions/retry-build.md b/docs/examples/kotlin/functions/retry-build.md new file mode 100644 index 0000000..597421c --- /dev/null +++ b/docs/examples/kotlin/functions/retry-build.md @@ -0,0 +1,28 @@ +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/storage/create-file.md b/docs/examples/kotlin/storage/create-file.md index f4f36c9..c5cc6a3 100644 --- a/docs/examples/kotlin/storage/create-file.md +++ b/docs/examples/kotlin/storage/create-file.md @@ -18,8 +18,9 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = storage.createFile( - fileId = "", - file = File("./path-to-files/image.jpg"), + bucketId = "[BUCKET_ID]", + fileId = "[FILE_ID]", + file = File("file.png"), ) val json = response.body?.string() } diff --git a/docs/examples/kotlin/storage/delete-file.md b/docs/examples/kotlin/storage/delete-file.md index f26acac..1a4a5b9 100644 --- a/docs/examples/kotlin/storage/delete-file.md +++ b/docs/examples/kotlin/storage/delete-file.md @@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = storage.deleteFile( + bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]" ) val json = response.body?.string() diff --git a/docs/examples/kotlin/storage/get-file-download.md b/docs/examples/kotlin/storage/get-file-download.md index b7d3d4a..3970fb8 100644 --- a/docs/examples/kotlin/storage/get-file-download.md +++ b/docs/examples/kotlin/storage/get-file-download.md @@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val result = storage.getFileDownload( + bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]" ) println(result); // Resource URL diff --git a/docs/examples/kotlin/storage/get-file-preview.md b/docs/examples/kotlin/storage/get-file-preview.md index 9f1d459..7804527 100644 --- a/docs/examples/kotlin/storage/get-file-preview.md +++ b/docs/examples/kotlin/storage/get-file-preview.md @@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val result = storage.getFilePreview( + bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]", ) println(result); // Resource URL diff --git a/docs/examples/kotlin/storage/get-file-view.md b/docs/examples/kotlin/storage/get-file-view.md index 0b4fe07..107ad45 100644 --- a/docs/examples/kotlin/storage/get-file-view.md +++ b/docs/examples/kotlin/storage/get-file-view.md @@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val result = storage.getFileView( + bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]" ) println(result); // Resource URL diff --git a/docs/examples/kotlin/storage/get-file.md b/docs/examples/kotlin/storage/get-file.md index b534d3b..30f640b 100644 --- a/docs/examples/kotlin/storage/get-file.md +++ b/docs/examples/kotlin/storage/get-file.md @@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = storage.getFile( + bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]" ) val json = response.body?.string() diff --git a/docs/examples/kotlin/storage/list-files.md b/docs/examples/kotlin/storage/list-files.md index 7d63837..20a253a 100644 --- a/docs/examples/kotlin/storage/list-files.md +++ b/docs/examples/kotlin/storage/list-files.md @@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = storage.listFiles( + bucketId = "[BUCKET_ID]", ) val json = response.body?.string() } diff --git a/docs/examples/kotlin/storage/update-file.md b/docs/examples/kotlin/storage/update-file.md index 31dfb38..35b1afb 100644 --- a/docs/examples/kotlin/storage/update-file.md +++ b/docs/examples/kotlin/storage/update-file.md @@ -18,9 +18,8 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = storage.updateFile( + bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]", - read = listOf(), - write = listOf() ) val json = response.body?.string() } diff --git a/docs/examples/kotlin/teams/create.md b/docs/examples/kotlin/teams/create.md index fcce1e0..73857b8 100644 --- a/docs/examples/kotlin/teams/create.md +++ b/docs/examples/kotlin/teams/create.md @@ -18,7 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = teams.create( - teamId = "", + teamId = "[TEAM_ID]", name = "[NAME]", ) val json = response.body?.string() diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 710f6bd..2dadb9d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Tue Jun 01 15:55:54 IST 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/library/build.gradle b/library/build.gradle index cb15537..7045591 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -19,6 +19,8 @@ ext { GITHUB_SCM_CONNECTION = 'scm:git:git://github.com/appwrite/sdk-for-android.git' } +version PUBLISH_VERSION + android { compileSdkVersion(31) @@ -61,7 +63,6 @@ dependencies { implementation("com.squareup.okhttp3:logging-interceptor") implementation("com.google.code.gson:gson:2.8.7") - implementation("net.gotev:cookie-store:1.3.5") 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") diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 162357e..4e5e78f 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -5,14 +5,15 @@ import android.content.pm.PackageManager import com.google.gson.GsonBuilder import com.google.gson.reflect.TypeToken import io.appwrite.appwrite.BuildConfig +import io.appwrite.cookies.stores.SharedPreferencesCookieStore import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.fromJson import io.appwrite.json.PreciseNumberAdapter +import io.appwrite.models.UploadProgress import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.suspendCancellableCoroutine -import net.gotev.cookiestore.SharedPreferencesCookieStore import okhttp3.* import okhttp3.Headers.Companion.toHeaders import okhttp3.HttpUrl.Companion.toHttpUrl @@ -22,6 +23,7 @@ import okhttp3.RequestBody.Companion.toRequestBody import java.io.BufferedInputStream import java.io.BufferedReader import java.io.File +import java.io.RandomAccessFile import java.io.IOException import java.net.CookieManager import java.net.CookiePolicy @@ -42,6 +44,10 @@ class Client @JvmOverloads constructor( private var selfSigned: Boolean = false ) : CoroutineScope { + companion object { + const val CHUNK_SIZE = 5*1024*1024; // 5MB + } + override val coroutineContext: CoroutineContext get() = Dispatchers.Main + job @@ -79,7 +85,7 @@ class Client @JvmOverloads constructor( "origin" to "appwrite-android://${context.packageName}", "user-agent" to "${context.packageName}/${appVersion}, ${System.getProperty("http.agent")}", "x-sdk-version" to "appwrite:android:${BuildConfig.SDK_VERSION}", - "x-appwrite-response-format" to "0.11.0" + "x-appwrite-response-format" to "0.14.0" ) config = mutableMapOf() @@ -231,7 +237,7 @@ class Client @JvmOverloads constructor( * @param headers * @param params * - * @return [Response] + * @return [T] */ @Throws(AppwriteException::class) suspend fun call( @@ -240,7 +246,7 @@ class Client @JvmOverloads constructor( headers: Map = mapOf(), params: Map = mapOf(), responseType: Class, - convert: ((Map) -> T)? = null + converter: ((Map) -> T)? = null ): T { val filteredParams = params.filterValues { it != null } @@ -276,7 +282,7 @@ class Client @JvmOverloads constructor( .get() .build() - return awaitResponse(request, responseType, convert) + return awaitResponse(request, responseType, converter) } val body = if (MultipartBody.FORM.toString() == headers["content-type"]) { @@ -285,8 +291,7 @@ class Client @JvmOverloads constructor( filteredParams.forEach { when { it.key == "file" -> { - val file = it.value as File - builder.addFormDataPart(it.key, file.name, file.asRequestBody()) + builder.addPart(it.value as MultipartBody.Part) } it.value is List<*> -> { val list = it.value as List<*> @@ -314,7 +319,101 @@ class Client @JvmOverloads constructor( .method(method, body) .build() - return awaitResponse(request, responseType, convert) + return awaitResponse(request, responseType, converter) + } + + /** + * Upload a file in chunks + * + * @param path + * @param headers + * @param params + * + * @return [T] + */ + @Throws(AppwriteException::class) + suspend fun chunkedUpload( + path: String, + headers: MutableMap, + params: MutableMap, + responseType: Class, + converter: ((Map) -> T), + paramName: String, + idParamName: String? = null, + onProgress: ((UploadProgress) -> Unit)? = null, + ): T { + val file = params[paramName] as File + val size = file.length() + + if (size < CHUNK_SIZE) { + params[paramName] = MultipartBody.Part.createFormData( + paramName, + file.name, + file.asRequestBody() + ) + return call( + method = "POST", + path, + headers, + params, + responseType, + converter + ) + } + + val input = RandomAccessFile(file, "r") + val buffer = ByteArray(CHUNK_SIZE) + var offset = 0L + var result: Map<*, *>? = null + + if (idParamName?.isNotEmpty() == true && params[idParamName] != "unique()") { + // Make a request to check if a file already exists + val current = call( + method = "GET", + path = "$path/${params[idParamName]}", + headers = headers, + params = emptyMap(), + responseType = Map::class.java, + ) + val chunksUploaded = current["chunksUploaded"] as Long + offset = (chunksUploaded * CHUNK_SIZE).coerceAtMost(size) + } + + while (offset < size) { + input.seek(offset) + input.read(buffer) + + params[paramName] = MultipartBody.Part.createFormData( + paramName, + file.name, + buffer.toRequestBody() + ) + + headers["Content-Range"] = + "bytes $offset-${((offset + CHUNK_SIZE) - 1).coerceAtMost(size)}/$size" + + result = call( + method = "POST", + path, + headers, + params, + responseType = Map::class.java + ) + + offset += CHUNK_SIZE + headers["x-appwrite-id"] = result!!["\$id"].toString() + onProgress?.invoke( + UploadProgress( + id = result!!["\$id"].toString(), + progress = offset.coerceAtMost(size).toDouble() / size * 100, + sizeUploaded = offset.coerceAtMost(size), + chunksTotal = result!!["chunksTotal"].toString().toInt(), + chunksUploaded = result!!["chunksUploaded"].toString().toInt(), + ) + ) + } + + return converter(result as Map) } /** @@ -322,7 +421,7 @@ class Client @JvmOverloads constructor( * * @param request * @param responseType - * @param convert + * @param converter * * @return [T] */ @@ -330,7 +429,7 @@ class Client @JvmOverloads constructor( private suspend fun awaitResponse( request: Request, responseType: Class, - convert: ((Map) -> T)? = null + converter: ((Map) -> T)? = null ) = suspendCancellableCoroutine { http.newCall(request).enqueue(object : Callback { override fun onFailure(call: Call, e: IOException) { @@ -347,8 +446,18 @@ class Client @JvmOverloads constructor( .charStream() .buffered() .use(BufferedReader::readText) + val error = if (response.headers["content-type"]?.contains("application/json") == true) { - body.fromJson() + val map = gson.fromJson>( + body, + object : TypeToken>(){}.type + ) + AppwriteException( + map["message"] as? String ?: "", + (map["code"] as Number).toInt(), + map["type"] as? String ?: "", + body + ) } else { AppwriteException(body, response.code) } @@ -386,7 +495,7 @@ class Client @JvmOverloads constructor( object : TypeToken>(){}.type ) it.resume( - convert?.invoke(map) ?: map as T + converter?.invoke(map) ?: map as T ) } }) diff --git a/library/src/main/java/io/appwrite/Query.kt b/library/src/main/java/io/appwrite/Query.kt index 1b3098d..b86507b 100644 --- a/library/src/main/java/io/appwrite/Query.kt +++ b/library/src/main/java/io/appwrite/Query.kt @@ -13,8 +13,8 @@ class Query { fun greater(attribute: String, value: Any) = Query.addQuery(attribute, "greater", value) fun greaterEqual(attribute: String, value: Any) = Query.addQuery(attribute, "greaterEqual", value) - - fun contains(attribute: String, value: List) = Query.addQuery(attribute, "contains", value) + + fun search(attribute: String, value: String) = Query.addQuery(attribute, "search", value) private fun addQuery(attribute: String, oper: String, value: Any): String { return when (value) { diff --git a/library/src/main/java/io/appwrite/cookies/Extensions.kt b/library/src/main/java/io/appwrite/cookies/Extensions.kt new file mode 100644 index 0000000..257c904 --- /dev/null +++ b/library/src/main/java/io/appwrite/cookies/Extensions.kt @@ -0,0 +1,53 @@ +package io.appwrite.cookies + +import android.os.Build +import java.net.CookieStore +import java.net.HttpCookie +import java.text.SimpleDateFormat +import java.util.Calendar +import java.util.Locale +import java.util.TimeZone + +fun HttpCookie.toSetCookieString(): String { + val expires = if (maxAge != -1L) { + val dateFormat = SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.UK).apply { + timeZone = TimeZone.getTimeZone("GMT") + } + + val calendar = Calendar.getInstance(Locale.UK).apply { set(Calendar.SECOND, maxAge.toInt()) } + + "; expires=${dateFormat.format(calendar.time)}" + } else { + "" + } + + val path = if (path != null) "; path=$path" else "" + val domain = if (domain != null) "; domain=$domain" else "" + val secure = if (secure) "; secure" else "" + val httpOnly = if (Build.VERSION.SDK_INT >= 24) { + if (isHttpOnly) "; httponly" else "" + } else { + "" + } + + return "$name=$value$expires$path$domain$secure$httpOnly" +} + +@Synchronized +fun CookieStore.syncToWebKitCookieManager() { + val webKitCookieManager = android.webkit.CookieManager.getInstance() + + cookies.forEach { + val hostUrl = "${if (it.secure) "https" else "http"}://${it.domain}" + webKitCookieManager.setCookie(hostUrl, it.toSetCookieString()) + } + + webKitCookieManager.flush() +} + +@Synchronized +@Suppress("DEPRECATION") +fun android.webkit.CookieManager.removeAll() { + removeAllCookies(null) + flush() +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/cookies/InternalCookie.kt b/library/src/main/java/io/appwrite/cookies/InternalCookie.kt new file mode 100644 index 0000000..c4ea22a --- /dev/null +++ b/library/src/main/java/io/appwrite/cookies/InternalCookie.kt @@ -0,0 +1,49 @@ +package io.appwrite.cookies + +import android.os.Build +import java.net.HttpCookie + +data class InternalCookie( + val comment: String?, + val commentURL: String?, + val discard: Boolean?, + val domain: String, + val maxAge: Long?, + val name: String, + val path: String?, + val portlist: String?, + val secure: Boolean?, + val value: String, + val version: Int?, + var httpOnly: Boolean? = null +) { + constructor(cookie: HttpCookie) : this( + cookie.comment, + cookie.commentURL, + cookie.discard, + cookie.domain, + cookie.maxAge, + cookie.name, + cookie.path, + cookie.portlist, + cookie.secure, + cookie.value, + cookie.version + ) + + fun toHttpCookie() = HttpCookie(name, value).apply { + comment = this@InternalCookie.comment + commentURL = this@InternalCookie.commentURL + discard = this@InternalCookie.discard == true + domain = this@InternalCookie.domain + maxAge = this@InternalCookie.maxAge ?: 0 + path = this@InternalCookie.path + portlist = this@InternalCookie.portlist + secure = this@InternalCookie.secure == true + version = this@InternalCookie.version ?: 0 + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + isHttpOnly = (this@InternalCookie.httpOnly == true) + } + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/cookies/stores/InMemoryCookieStore.kt b/library/src/main/java/io/appwrite/cookies/stores/InMemoryCookieStore.kt new file mode 100644 index 0000000..7de9ec9 --- /dev/null +++ b/library/src/main/java/io/appwrite/cookies/stores/InMemoryCookieStore.kt @@ -0,0 +1,269 @@ +package io.appwrite.cookies.stores + +import android.os.Build +import android.util.Log +import java.net.CookieStore +import java.net.HttpCookie +import java.net.URI +import java.net.URISyntaxException +import java.util.Collections +import java.util.concurrent.locks.ReentrantLock + +open class InMemoryCookieStore(private val name: String) : CookieStore { + + internal val uriIndex = mutableMapOf>() + private val lock = ReentrantLock(false) + + override fun removeAll(): Boolean { + lock.lock() + + return try { + uriIndex.clear() + uriIndex.isEmpty() + } finally { + lock.unlock() + } + } + + override fun add(uri: URI?, cookie: HttpCookie?) { + if (cookie == null) { + Log.i( + javaClass.simpleName, + "tried to add null cookie in cookie store named $name. Doing nothing." + ) + return + } + + if (uri == null) { + Log.i( + javaClass.simpleName, + "tried to add null URI in cookie store named $name. Doing nothing." + ) + return + } + + lock.lock() + try { + addIndex(getEffectiveURI(uri), cookie) + } finally { + lock.unlock() + } + } + + override fun getCookies(): List { + val cookies = mutableListOf() + + lock.lock() + try { + for (list in uriIndex.values) { + val it = list.iterator() + while (it.hasNext()) { + val cookie = it.next() + if (cookie.hasExpired()) { + it.remove() + } else if (!cookies.contains(cookie)) { + cookies.add(cookie) + } + } + } + } finally { + lock.unlock() + } + + return cookies + } + + override fun getURIs(): List { + val uris = mutableListOf() + + lock.lock() + return try { + uriIndex.keys.toList() + } finally { + uris.addAll(uriIndex.keys) + lock.unlock() + } + } + + override fun remove(uri: URI?, cookie: HttpCookie?): Boolean { + if (cookie == null) { + Log.i( + javaClass.simpleName, + "tried to remove null cookie from cookie store named $name. Doing nothing." + ) + return true + } + + if (uri == null) { + Log.i( + javaClass.simpleName, + "tried to remove null URI from cookie store named $name. Doing nothing." + ) + return true + } + + lock.lock() + + return try { + val lintedURI = getEffectiveURI(uri) + + if (uriIndex[lintedURI] == null) { + false + } else { + val cookies = uriIndex[lintedURI] + cookies?.remove(cookie) ?: false + } + } finally { + lock.unlock() + } + } + + override fun get(uri: URI?): List { + if (uri == null) { + Log.i( + javaClass.simpleName, + "getting cookies from cookie store named $name for null URI results in empty list" + ) + return emptyList() + } + + val cookies = arrayListOf() + + lock.lock() + try { + uri.host?.let { cookies.addAll(getInternal1(it)) } + val internal2 = getInternal2(getEffectiveURI(uri)).filter { !cookies.contains(it) } + cookies.addAll(internal2) + } finally { + lock.unlock() + } + + return cookies + } + + internal fun getEffectiveURI(uri: URI): URI { + return try { + URI(uri.scheme ?: "http", uri.host, null, null, null) + } catch (ignored: URISyntaxException) { + uri + } + } + + private fun addIndex(index: URI, cookie: HttpCookie) { + val cookies = uriIndex[index] + + if (cookies != null) { + cookies.remove(cookie) + cookies.add(cookie) + } else { + val newCookies = mutableListOf() + newCookies.add(cookie) + uriIndex[index] = newCookies + } + } + + private fun netscapeDomainMatches(domain: String?, host: String?): Boolean { + if (domain == null || host == null) { + return false + } + + // If there's no embedded dot in domain and domain is not .local + val isLocalDomain = ".local".equals(domain, ignoreCase = true) + var embeddedDotInDomain = domain.indexOf('.') + if (embeddedDotInDomain == 0) { + embeddedDotInDomain = domain.indexOf('.', 1) + } + if (!isLocalDomain && (embeddedDotInDomain == -1 || embeddedDotInDomain == domain.length - 1)) { + return false + } + + // If the host name contains no dot and the domain name is .local + val firstDotInHost = host.indexOf('.') + if (firstDotInHost == -1 && isLocalDomain) { + return true + } + + val domainLength = domain.length + val lengthDiff = host.length - domainLength + if (lengthDiff == 0) { + // If the host name and the domain name are just string-compare euqal + return host.equals(domain, ignoreCase = true) + } else if (lengthDiff > 0) { + // need to check H & D component + val D = host.substring(lengthDiff) + + // Android-changed: b/26456024 targetSdkVersion based compatibility for domain matching + // Android M and earlier: Cookies with domain "foo.com" would not match "bar.foo.com". + // The RFC dictates that the user agent must treat those domains as if they had a + // leading period and must therefore match "bar.foo.com". + return if (Build.VERSION.SDK_INT <= 23 && !domain.startsWith(".")) { + false + } else D.equals(domain, ignoreCase = true) + } else if (lengthDiff == -1) { + // if domain is actually .host + return domain[0] == '.' && host.equals(domain.substring(1), ignoreCase = true) + } + + return false + } + + private fun getInternal1(host: String): List { + // BEGIN Android-changed: b/25897688 InMemoryCookieStore ignores scheme (http/https) + // Use a separate list to handle cookies that need to be removed so + // that there is no conflict with iterators. + val toRemove = mutableListOf() + val cookies = mutableListOf() + + for ((_, lst) in uriIndex) { + for (c in lst) { + val domain = c.domain + if (c.version == 0 && netscapeDomainMatches( + domain, + host + ) || c.version == 1 && HttpCookie.domainMatches(domain, host) + ) { + if (!c.hasExpired()) { + if (!cookies.contains(c)) { + cookies.add(c) + } + } else { + toRemove.add(c) + } + } + } + // Clean up the cookies that need to be removed + for (c in toRemove) { + lst.remove(c) + } + toRemove.clear() + } + return cookies + } + + private fun getInternal2(comparator: URI): List { + // BEGIN Android-changed: b/25897688 InMemoryCookieStore ignores scheme (http/https) + // Removed cookieJar + val cookies = mutableListOf() + + for (index in uriIndex.keys) { + if (index === comparator || comparator.compareTo(index) == 0) { + val indexedCookies = uriIndex[index] + // Check the list of cookies associated with this domain + if (indexedCookies != null) { + val it = indexedCookies.iterator() + while (it.hasNext()) { + val ck = it.next() + if (!ck.hasExpired()) { + if (!cookies.contains(ck)) + cookies.add(ck) + } else { + it.remove() + } + } + } + } + } + + return cookies + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/cookies/stores/SharedPreferencesCookieStore.kt b/library/src/main/java/io/appwrite/cookies/stores/SharedPreferencesCookieStore.kt new file mode 100644 index 0000000..83c677d --- /dev/null +++ b/library/src/main/java/io/appwrite/cookies/stores/SharedPreferencesCookieStore.kt @@ -0,0 +1,99 @@ +package io.appwrite.cookies.stores + +import io.appwrite.cookies.InternalCookie +import android.content.Context +import android.os.Build +import android.util.Log +import com.google.gson.Gson +import com.google.gson.reflect.TypeToken +import java.net.HttpCookie +import java.net.URI + +open class SharedPreferencesCookieStore( + context: Context, + private val name: String +) : InMemoryCookieStore(name) { + + private val preferences = context.getSharedPreferences(name, Context.MODE_PRIVATE) + private val gson = Gson() + + init { + synchronized(SharedPreferencesCookieStore::class.java) { + preferences.all.forEach { (key, value) -> + try { + val index = URI.create(key) + val listType = object : TypeToken>() {}.type + val internalCookies = + gson.fromJson>(value.toString(), listType) + val cookies = internalCookies.map { it.toHttpCookie() }.toMutableList() + uriIndex[index] = cookies + } catch (exception: Throwable) { + Log.e( + javaClass.simpleName, + "Error while loading key = $key, value = $value from cookie store named $name", + exception + ) + } + } + } + } + + override fun removeAll(): Boolean = + synchronized(SharedPreferencesCookieStore::class.java) { + super.removeAll() + preferences.edit().clear().apply() + true + } + + override fun add(uri: URI?, cookie: HttpCookie?) = + synchronized(SharedPreferencesCookieStore::class.java) { + uri ?: return@synchronized + + super.add(uri, cookie) + val index = getEffectiveURI(uri) + val cookies = uriIndex[index] ?: return@synchronized + + val internalCookies = cookies.map { + InternalCookie(it).apply { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + httpOnly = it.isHttpOnly + } + } + } + + val listType = object : TypeToken>() {}.type + val json = gson.toJson(internalCookies, listType) + + preferences + .edit() + .putString(index.toString(), json) + .apply() + } + + override fun remove(uri: URI?, cookie: HttpCookie?): Boolean = + synchronized(SharedPreferencesCookieStore::class.java) { + uri ?: return false + + val result = super.remove(uri, cookie) + val index = getEffectiveURI(uri) + val cookies = uriIndex[index] + val internalCookies = cookies?.map { + InternalCookie(it).apply { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + httpOnly = it.isHttpOnly + } + } + } + val listType = object : TypeToken>() {}.type + val json = gson.toJson(internalCookies, listType) + + preferences.edit().apply { + when (cookies) { + null -> remove(index.toString()) + else -> putString(index.toString(), json) + } + }.apply() + + return result + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/exceptions/AppwriteException.kt b/library/src/main/java/io/appwrite/exceptions/AppwriteException.kt index 1d22595..105f5ee 100644 --- a/library/src/main/java/io/appwrite/exceptions/AppwriteException.kt +++ b/library/src/main/java/io/appwrite/exceptions/AppwriteException.kt @@ -5,5 +5,6 @@ import java.lang.Exception class AppwriteException( override val message: String? = null, val code: Int? = null, + val type: String? = null, val response: String? = null ) : Exception(message) \ 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 da6eca6..ba8b5ae 100644 --- a/library/src/main/java/io/appwrite/models/Continent.kt +++ b/library/src/main/java/io/appwrite/models/Continent.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Continent */ @@ -8,12 +10,14 @@ data class Continent( * Continent name. * */ + @SerializedName("name") val name: String, /** * Continent two letter code. * */ + @SerializedName("code") val code: String ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/ContinentList.kt b/library/src/main/java/io/appwrite/models/ContinentList.kt index 9b076c4..6a09c92 100644 --- a/library/src/main/java/io/appwrite/models/ContinentList.kt +++ b/library/src/main/java/io/appwrite/models/ContinentList.kt @@ -1,31 +1,35 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Continents List */ data class ContinentList( /** - * Total number of items available on the server. + * Total number of continents documents that matched your query. * */ - val sum: Long, + @SerializedName("total") + val total: Long, /** * List of continents. * */ + @SerializedName("continents") val continents: List ) { companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = ContinentList( - sum = map["sum"] as Long, + total = (map["total"] as Number).toLong(), continents = (map["continents"] as List>).map { Continent.from(map = it) } ) } fun toMap(): Map = mapOf( - "sum" to sum as Any, + "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 8c1d608..51fee8f 100644 --- a/library/src/main/java/io/appwrite/models/Country.kt +++ b/library/src/main/java/io/appwrite/models/Country.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Country */ @@ -8,12 +10,14 @@ data class Country( * Country name. * */ + @SerializedName("name") val name: String, /** * Country two-character ISO 3166-1 alpha code. * */ + @SerializedName("code") val code: String ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/CountryList.kt b/library/src/main/java/io/appwrite/models/CountryList.kt index a1476a1..98dbfcd 100644 --- a/library/src/main/java/io/appwrite/models/CountryList.kt +++ b/library/src/main/java/io/appwrite/models/CountryList.kt @@ -1,31 +1,35 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Countries List */ data class CountryList( /** - * Total number of items available on the server. + * Total number of countries documents that matched your query. * */ - val sum: Long, + @SerializedName("total") + val total: Long, /** * List of countries. * */ + @SerializedName("countries") val countries: List ) { companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = CountryList( - sum = map["sum"] as Long, + total = (map["total"] as Number).toLong(), countries = (map["countries"] as List>).map { Country.from(map = it) } ) } fun toMap(): Map = mapOf( - "sum" to sum as Any, + "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 58002c2..df6e230 100644 --- a/library/src/main/java/io/appwrite/models/Currency.kt +++ b/library/src/main/java/io/appwrite/models/Currency.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Currency */ @@ -8,42 +10,49 @@ 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 ) { companion object { @@ -52,8 +61,8 @@ data class Currency( symbol = map["symbol"] as String, name = map["name"] as String, symbolNative = map["symbolNative"] as String, - decimalDigits = map["decimalDigits"] as Long, - rounding = map["rounding"] as Double, + decimalDigits = (map["decimalDigits"] as Number).toLong(), + rounding = (map["rounding"] as Number).toDouble(), code = map["code"] as String, namePlural = map["namePlural"] as String ) diff --git a/library/src/main/java/io/appwrite/models/CurrencyList.kt b/library/src/main/java/io/appwrite/models/CurrencyList.kt index d2863d9..abc719d 100644 --- a/library/src/main/java/io/appwrite/models/CurrencyList.kt +++ b/library/src/main/java/io/appwrite/models/CurrencyList.kt @@ -1,31 +1,35 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Currencies List */ data class CurrencyList( /** - * Total number of items available on the server. + * Total number of currencies documents that matched your query. * */ - val sum: Long, + @SerializedName("total") + val total: Long, /** * List of currencies. * */ + @SerializedName("currencies") val currencies: List ) { companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = CurrencyList( - sum = map["sum"] as Long, + total = (map["total"] as Number).toLong(), currencies = (map["currencies"] as List>).map { Currency.from(map = it) } ) } fun toMap(): Map = mapOf( - "sum" to sum as Any, + "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 f443676..a83a844 100644 --- a/library/src/main/java/io/appwrite/models/Document.kt +++ b/library/src/main/java/io/appwrite/models/Document.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Document */ @@ -8,24 +10,28 @@ data class Document( * Document ID. * */ + @SerializedName("\$id") val id: String, /** * Collection ID. * */ + @SerializedName("\$collection") val collection: String, /** * Document read permissions. * */ + @SerializedName("\$read") val read: List, /** * Document write permissions. * */ + @SerializedName("\$write") val write: List, val data: Map diff --git a/library/src/main/java/io/appwrite/models/DocumentList.kt b/library/src/main/java/io/appwrite/models/DocumentList.kt index c05899f..f8e41b5 100644 --- a/library/src/main/java/io/appwrite/models/DocumentList.kt +++ b/library/src/main/java/io/appwrite/models/DocumentList.kt @@ -1,31 +1,35 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Documents List */ data class DocumentList( /** - * Total number of items available on the server. + * Total number of documents documents that matched your query. * */ - val sum: Long, + @SerializedName("total") + val total: Long, /** * List of documents. * */ + @SerializedName("documents") val documents: List ) { companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = DocumentList( - sum = map["sum"] as Long, + total = (map["total"] as Number).toLong(), documents = (map["documents"] as List>).map { Document.from(map = it) } ) } fun toMap(): Map = mapOf( - "sum" to sum as Any, + "total" to total as Any, "documents" to documents.map { it.toMap() } as Any ) diff --git a/library/src/main/java/io/appwrite/models/Execution.kt b/library/src/main/java/io/appwrite/models/Execution.kt index 2d25a73..06c2811 100644 --- a/library/src/main/java/io/appwrite/models/Execution.kt +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Execution */ @@ -8,60 +10,70 @@ data class Execution( * Execution ID. * */ + @SerializedName("\$id") val id: String, /** * Execution read permissions. * */ + @SerializedName("\$read") val read: List, /** * Function ID. * */ + @SerializedName("functionId") val functionId: String, /** * The execution creation date in Unix timestamp. * */ + @SerializedName("dateCreated") val dateCreated: Long, /** * 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 exit code. + * The script status code. * */ - val exitCode: Long, + @SerializedName("statusCode") + val statusCode: Long, /** - * The script stdout output string. Logs the last 4,000 characters of the execution stdout output. + * The script response output string. Logs the last 4,000 characters of the execution response output. * */ - val stdout: String, + @SerializedName("response") + val response: String, /** * The script stderr output string. Logs the last 4,000 characters of the execution stderr output * */ + @SerializedName("stderr") val stderr: String, /** * The script execution time in seconds. * */ + @SerializedName("time") val time: Double ) { companion object { @@ -70,13 +82,13 @@ data class Execution( id = map["\$id"] as String, read = map["\$read"] as List, functionId = map["functionId"] as String, - dateCreated = map["dateCreated"] as Long, + dateCreated = (map["dateCreated"] as Number).toLong(), trigger = map["trigger"] as String, status = map["status"] as String, - exitCode = map["exitCode"] as Long, - stdout = map["stdout"] as String, + statusCode = (map["statusCode"] as Number).toLong(), + response = map["response"] as String, stderr = map["stderr"] as String, - time = map["time"] as Double + time = (map["time"] as Number).toDouble() ) } @@ -87,8 +99,8 @@ data class Execution( "dateCreated" to dateCreated as Any, "trigger" to trigger as Any, "status" to status as Any, - "exitCode" to exitCode as Any, - "stdout" to stdout as Any, + "statusCode" to statusCode as Any, + "response" to response as Any, "stderr" to stderr as Any, "time" to time as Any ) diff --git a/library/src/main/java/io/appwrite/models/ExecutionList.kt b/library/src/main/java/io/appwrite/models/ExecutionList.kt index 5ab06b7..2131ffc 100644 --- a/library/src/main/java/io/appwrite/models/ExecutionList.kt +++ b/library/src/main/java/io/appwrite/models/ExecutionList.kt @@ -1,31 +1,35 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Executions List */ data class ExecutionList( /** - * Total number of items available on the server. + * Total number of executions documents that matched your query. * */ - val sum: Long, + @SerializedName("total") + val total: Long, /** * List of executions. * */ + @SerializedName("executions") val executions: List ) { companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = ExecutionList( - sum = map["sum"] as Long, + total = (map["total"] as Number).toLong(), executions = (map["executions"] as List>).map { Execution.from(map = it) } ) } fun toMap(): Map = mapOf( - "sum" to sum as Any, + "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 1546c61..2faa1e4 100644 --- a/library/src/main/java/io/appwrite/models/File.kt +++ b/library/src/main/java/io/appwrite/models/File.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * File */ @@ -8,72 +10,107 @@ data class File( * File ID. * */ + @SerializedName("\$id") val id: String, + /** + * Bucket ID. + * + */ + @SerializedName("bucketId") + val bucketId: String, + /** * File read permissions. * */ + @SerializedName("\$read") val read: List, /** * File write permissions. * */ + @SerializedName("\$write") val write: List, /** * File name. * */ + @SerializedName("name") val name: String, /** * File creation date in Unix timestamp. * */ + @SerializedName("dateCreated") val dateCreated: Long, /** * File MD5 signature. * */ + @SerializedName("signature") val signature: String, /** * File mime type. * */ + @SerializedName("mimeType") val mimeType: String, /** * File original size in bytes. * */ - val sizeOriginal: Long + @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 ) { companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = File( id = map["\$id"] as String, + bucketId = map["bucketId"] as String, read = map["\$read"] as List, write = map["\$write"] as List, name = map["name"] as String, - dateCreated = map["dateCreated"] as Long, + dateCreated = (map["dateCreated"] as Number).toLong(), signature = map["signature"] as String, mimeType = map["mimeType"] as String, - sizeOriginal = map["sizeOriginal"] as Long + sizeOriginal = (map["sizeOriginal"] as Number).toLong(), + chunksTotal = (map["chunksTotal"] as Number).toLong(), + chunksUploaded = (map["chunksUploaded"] as Number).toLong() ) } fun toMap(): Map = mapOf( "\$id" to id as Any, + "bucketId" to bucketId as Any, "\$read" to read as Any, "\$write" to write as Any, "name" to name as Any, "dateCreated" to dateCreated as Any, "signature" to signature as Any, "mimeType" to mimeType as Any, - "sizeOriginal" to sizeOriginal 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 4c9cf1c..477bad2 100644 --- a/library/src/main/java/io/appwrite/models/FileList.kt +++ b/library/src/main/java/io/appwrite/models/FileList.kt @@ -1,31 +1,35 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Files List */ data class FileList( /** - * Total number of items available on the server. + * Total number of files documents that matched your query. * */ - val sum: Long, + @SerializedName("total") + val total: Long, /** * List of files. * */ + @SerializedName("files") val files: List ) { companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = FileList( - sum = map["sum"] as Long, + total = (map["total"] as Number).toLong(), files = (map["files"] as List>).map { File.from(map = it) } ) } fun toMap(): Map = mapOf( - "sum" to sum as Any, + "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 4012643..c871237 100644 --- a/library/src/main/java/io/appwrite/models/Jwt.kt +++ b/library/src/main/java/io/appwrite/models/Jwt.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * JWT */ @@ -8,6 +10,7 @@ data class Jwt( * JWT encoded string. * */ + @SerializedName("jwt") val jwt: String ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/Language.kt b/library/src/main/java/io/appwrite/models/Language.kt index 0f050a8..045202f 100644 --- a/library/src/main/java/io/appwrite/models/Language.kt +++ b/library/src/main/java/io/appwrite/models/Language.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Language */ @@ -8,18 +10,21 @@ 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 ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/LanguageList.kt b/library/src/main/java/io/appwrite/models/LanguageList.kt index 813c99b..8ca4f5f 100644 --- a/library/src/main/java/io/appwrite/models/LanguageList.kt +++ b/library/src/main/java/io/appwrite/models/LanguageList.kt @@ -1,31 +1,35 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Languages List */ data class LanguageList( /** - * Total number of items available on the server. + * Total number of languages documents that matched your query. * */ - val sum: Long, + @SerializedName("total") + val total: Long, /** * List of languages. * */ + @SerializedName("languages") val languages: List ) { companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = LanguageList( - sum = map["sum"] as Long, + total = (map["total"] as Number).toLong(), languages = (map["languages"] as List>).map { Language.from(map = it) } ) } fun toMap(): Map = mapOf( - "sum" to sum as Any, + "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 6e812c5..d8d3fcf 100644 --- a/library/src/main/java/io/appwrite/models/Locale.kt +++ b/library/src/main/java/io/appwrite/models/Locale.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Locale */ @@ -8,42 +10,49 @@ 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 ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/Log.kt b/library/src/main/java/io/appwrite/models/Log.kt index 05a0786..fb4de88 100644 --- a/library/src/main/java/io/appwrite/models/Log.kt +++ b/library/src/main/java/io/appwrite/models/Log.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Log */ @@ -8,126 +10,147 @@ 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 time in Unix timestamp. * */ + @SerializedName("time") val time: Long, /** * 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 ) { companion object { @@ -139,7 +162,7 @@ data class Log( userName = map["userName"] as String, mode = map["mode"] as String, ip = map["ip"] as String, - time = map["time"] as Long, + time = (map["time"] as Number).toLong(), osCode = map["osCode"] as String, osName = map["osName"] as String, osVersion = map["osVersion"] as String, diff --git a/library/src/main/java/io/appwrite/models/LogList.kt b/library/src/main/java/io/appwrite/models/LogList.kt index a6bbd4a..47d5680 100644 --- a/library/src/main/java/io/appwrite/models/LogList.kt +++ b/library/src/main/java/io/appwrite/models/LogList.kt @@ -1,31 +1,35 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Logs List */ data class LogList( /** - * Total number of items available on the server. + * Total number of logs documents that matched your query. * */ - val sum: Long, + @SerializedName("total") + val total: Long, /** * List of logs. * */ + @SerializedName("logs") val logs: List ) { companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = LogList( - sum = map["sum"] as Long, + total = (map["total"] as Number).toLong(), logs = (map["logs"] as List>).map { Log.from(map = it) } ) } fun toMap(): Map = mapOf( - "sum" to sum as Any, + "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 9e0266f..3df7b69 100644 --- a/library/src/main/java/io/appwrite/models/Membership.kt +++ b/library/src/main/java/io/appwrite/models/Membership.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Membership */ @@ -8,54 +10,70 @@ data class Membership( * Membership ID. * */ + @SerializedName("\$id") val id: String, /** * User ID. * */ + @SerializedName("userId") val userId: String, /** - * Team ID. + * User name. * */ - val teamId: String, + @SerializedName("userName") + val userName: String, /** - * User name. + * User email address. * */ - val name: String, + @SerializedName("userEmail") + val userEmail: String, /** - * User email address. + * Team ID. + * + */ + @SerializedName("teamId") + val teamId: String, + + /** + * Team name. * */ - val email: String, + @SerializedName("teamName") + val teamName: String, /** * Date, the user has been invited to join the team in Unix timestamp. * */ + @SerializedName("invited") val invited: Long, /** * Date, the user has accepted the invitation to join the team in Unix timestamp. * */ + @SerializedName("joined") val joined: Long, /** * 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 ) { companion object { @@ -63,11 +81,12 @@ data class Membership( fun from(map: Map) = Membership( id = map["\$id"] as String, userId = map["userId"] as String, + userName = map["userName"] as String, + userEmail = map["userEmail"] as String, teamId = map["teamId"] as String, - name = map["name"] as String, - email = map["email"] as String, - invited = map["invited"] as Long, - joined = map["joined"] as Long, + teamName = map["teamName"] as String, + invited = (map["invited"] as Number).toLong(), + joined = (map["joined"] as Number).toLong(), confirm = map["confirm"] as Boolean, roles = map["roles"] as List ) @@ -76,9 +95,10 @@ data class Membership( fun toMap(): Map = mapOf( "\$id" to id as Any, "userId" to userId as Any, + "userName" to userName as Any, + "userEmail" to userEmail as Any, "teamId" to teamId as Any, - "name" to name as Any, - "email" to email as Any, + "teamName" to teamName as Any, "invited" to invited as Any, "joined" to joined as Any, "confirm" to confirm as Any, diff --git a/library/src/main/java/io/appwrite/models/MembershipList.kt b/library/src/main/java/io/appwrite/models/MembershipList.kt index 3935263..1b7549d 100644 --- a/library/src/main/java/io/appwrite/models/MembershipList.kt +++ b/library/src/main/java/io/appwrite/models/MembershipList.kt @@ -1,31 +1,35 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Memberships List */ data class MembershipList( /** - * Total number of items available on the server. + * Total number of memberships documents that matched your query. * */ - val sum: Long, + @SerializedName("total") + val total: Long, /** * List of memberships. * */ + @SerializedName("memberships") val memberships: List ) { companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = MembershipList( - sum = map["sum"] as Long, + total = (map["total"] as Number).toLong(), memberships = (map["memberships"] as List>).map { Membership.from(map = it) } ) } fun toMap(): Map = mapOf( - "sum" to sum as Any, + "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 a11de9d..bfa3113 100644 --- a/library/src/main/java/io/appwrite/models/Phone.kt +++ b/library/src/main/java/io/appwrite/models/Phone.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Phone */ @@ -8,18 +10,21 @@ 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 ) { companion object { diff --git a/library/src/main/java/io/appwrite/models/PhoneList.kt b/library/src/main/java/io/appwrite/models/PhoneList.kt index a7b92d0..6dee844 100644 --- a/library/src/main/java/io/appwrite/models/PhoneList.kt +++ b/library/src/main/java/io/appwrite/models/PhoneList.kt @@ -1,31 +1,35 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Phones List */ data class PhoneList( /** - * Total number of items available on the server. + * Total number of phones documents that matched your query. * */ - val sum: Long, + @SerializedName("total") + val total: Long, /** * List of phones. * */ + @SerializedName("phones") val phones: List ) { companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = PhoneList( - sum = map["sum"] as Long, + total = (map["total"] as Number).toLong(), phones = (map["phones"] as List>).map { Phone.from(map = it) } ) } fun toMap(): Map = mapOf( - "sum" to sum as Any, + "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 a95850f..0b11e85 100644 --- a/library/src/main/java/io/appwrite/models/Preferences.kt +++ b/library/src/main/java/io/appwrite/models/Preferences.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Preferences */ diff --git a/library/src/main/java/io/appwrite/models/RealtimeModels.kt b/library/src/main/java/io/appwrite/models/RealtimeModels.kt index e2b012a..9041554 100644 --- a/library/src/main/java/io/appwrite/models/RealtimeModels.kt +++ b/library/src/main/java/io/appwrite/models/RealtimeModels.kt @@ -1,5 +1,6 @@ package io.appwrite.models +import kotlin.collections.Collection import java.io.Closeable data class RealtimeSubscription( @@ -20,7 +21,7 @@ open class RealtimeResponse( ) data class RealtimeResponseEvent( - val event: String, + val events: Collection, val channels: Collection, val timestamp: Long, var payload: T diff --git a/library/src/main/java/io/appwrite/models/Session.kt b/library/src/main/java/io/appwrite/models/Session.kt index fa8a91f..1abd909 100644 --- a/library/src/main/java/io/appwrite/models/Session.kt +++ b/library/src/main/java/io/appwrite/models/Session.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Session */ @@ -8,132 +10,168 @@ data class Session( * Session ID. * */ + @SerializedName("\$id") val id: String, /** * User ID. * */ + @SerializedName("userId") val userId: String, /** * Session expiration date in Unix timestamp. * */ + @SerializedName("expire") val expire: Long, /** * Session Provider. * */ + @SerializedName("provider") val provider: String, /** * Session Provider User ID. * */ + @SerializedName("providerUid") val providerUid: String, /** - * Session Provider Token. + * Session Provider Access Token. + * + */ + @SerializedName("providerAccessToken") + val providerAccessToken: String, + + /** + * Date, the Unix timestamp of when the access token expires. + * + */ + @SerializedName("providerAccessTokenExpiry") + val providerAccessTokenExpiry: Long, + + /** + * Session Provider Refresh Token. * */ - val providerToken: String, + @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 ) { companion object { @@ -141,10 +179,12 @@ data class Session( fun from(map: Map) = Session( id = map["\$id"] as String, userId = map["userId"] as String, - expire = map["expire"] as Long, + expire = (map["expire"] as Number).toLong(), provider = map["provider"] as String, providerUid = map["providerUid"] as String, - providerToken = map["providerToken"] as String, + providerAccessToken = map["providerAccessToken"] as String, + providerAccessTokenExpiry = (map["providerAccessTokenExpiry"] as Number).toLong(), + providerRefreshToken = map["providerRefreshToken"] as String, ip = map["ip"] as String, osCode = map["osCode"] as String, osName = map["osName"] as String, @@ -170,7 +210,9 @@ data class Session( "expire" to expire as Any, "provider" to provider as Any, "providerUid" to providerUid as Any, - "providerToken" to providerToken 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, diff --git a/library/src/main/java/io/appwrite/models/SessionList.kt b/library/src/main/java/io/appwrite/models/SessionList.kt index 655701d..9891102 100644 --- a/library/src/main/java/io/appwrite/models/SessionList.kt +++ b/library/src/main/java/io/appwrite/models/SessionList.kt @@ -1,31 +1,35 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Sessions List */ data class SessionList( /** - * Total number of items available on the server. + * Total number of sessions documents that matched your query. * */ - val sum: Long, + @SerializedName("total") + val total: Long, /** * List of sessions. * */ + @SerializedName("sessions") val sessions: List ) { companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = SessionList( - sum = map["sum"] as Long, + total = (map["total"] as Number).toLong(), sessions = (map["sessions"] as List>).map { Session.from(map = it) } ) } fun toMap(): Map = mapOf( - "sum" to sum as Any, + "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 414886a..f502375 100644 --- a/library/src/main/java/io/appwrite/models/Team.kt +++ b/library/src/main/java/io/appwrite/models/Team.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Team */ @@ -8,33 +10,37 @@ data class Team( * Team ID. * */ + @SerializedName("\$id") val id: String, /** * Team name. * */ + @SerializedName("name") val name: String, /** * Team creation date in Unix timestamp. * */ + @SerializedName("dateCreated") val dateCreated: Long, /** - * Total sum of team members. + * Total number of team members. * */ - val sum: Long + @SerializedName("total") + val total: Long ) { companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = Team( id = map["\$id"] as String, name = map["name"] as String, - dateCreated = map["dateCreated"] as Long, - sum = map["sum"] as Long + dateCreated = (map["dateCreated"] as Number).toLong(), + total = (map["total"] as Number).toLong() ) } @@ -42,6 +48,6 @@ data class Team( "\$id" to id as Any, "name" to name as Any, "dateCreated" to dateCreated as Any, - "sum" to sum 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 3adca8d..4f210b3 100644 --- a/library/src/main/java/io/appwrite/models/TeamList.kt +++ b/library/src/main/java/io/appwrite/models/TeamList.kt @@ -1,31 +1,35 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Teams List */ data class TeamList( /** - * Total number of items available on the server. + * Total number of teams documents that matched your query. * */ - val sum: Long, + @SerializedName("total") + val total: Long, /** * List of teams. * */ + @SerializedName("teams") val teams: List ) { companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = TeamList( - sum = map["sum"] as Long, + total = (map["total"] as Number).toLong(), teams = (map["teams"] as List>).map { Team.from(map = it) } ) } fun toMap(): Map = mapOf( - "sum" to sum as Any, + "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 5041d1a..d555f45 100644 --- a/library/src/main/java/io/appwrite/models/Token.kt +++ b/library/src/main/java/io/appwrite/models/Token.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * Token */ @@ -8,24 +10,28 @@ data class Token( * Token ID. * */ + @SerializedName("\$id") val id: 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 Unix timestamp. * */ + @SerializedName("expire") val expire: Long ) { companion object { @@ -34,7 +40,7 @@ data class Token( id = map["\$id"] as String, userId = map["userId"] as String, secret = map["secret"] as String, - expire = map["expire"] as Long + expire = (map["expire"] as Number).toLong() ) } diff --git a/library/src/main/java/io/appwrite/models/UploadProgress.kt b/library/src/main/java/io/appwrite/models/UploadProgress.kt new file mode 100644 index 0000000..4199694 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/UploadProgress.kt @@ -0,0 +1,9 @@ +package io.appwrite.models + +data class UploadProgress( + val id: String, + val progress: Double, + val sizeUploaded: Long, + val chunksTotal: Int, + val chunksUploaded: Int +) \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/User.kt b/library/src/main/java/io/appwrite/models/User.kt index 0af27cc..032391e 100644 --- a/library/src/main/java/io/appwrite/models/User.kt +++ b/library/src/main/java/io/appwrite/models/User.kt @@ -1,5 +1,7 @@ package io.appwrite.models +import com.google.gson.annotations.SerializedName + /** * User */ @@ -8,48 +10,56 @@ data class User( * User ID. * */ + @SerializedName("\$id") val id: String, /** * User name. * */ + @SerializedName("name") val name: String, /** * User registration date in Unix timestamp. * */ + @SerializedName("registration") val registration: Long, /** * User status. Pass `true` for enabled and `false` for disabled. * */ + @SerializedName("status") val status: Boolean, /** * Unix timestamp of the most recent password update * */ + @SerializedName("passwordUpdate") val passwordUpdate: Long, /** * User email address. * */ + @SerializedName("email") val email: String, /** * Email verification status. * */ + @SerializedName("emailVerification") val emailVerification: Boolean, /** * User preferences as a key-value object * */ + @SerializedName("prefs") val prefs: Preferences ) { companion object { @@ -57,9 +67,9 @@ data class User( fun from(map: Map) = User( id = map["\$id"] as String, name = map["name"] as String, - registration = map["registration"] as Long, + registration = (map["registration"] as Number).toLong(), status = map["status"] as Boolean, - passwordUpdate = map["passwordUpdate"] as Long, + passwordUpdate = (map["passwordUpdate"] as Number).toLong(), email = map["email"] as String, emailVerification = map["emailVerification"] as Boolean, prefs = Preferences.from(map = map["prefs"] as Map) diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 521c741..8f144de 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -25,12 +25,12 @@ class Account(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun get(): io.appwrite.models.User { val path = "/account" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.User = { + val converter: (Map) -> io.appwrite.models.User = { io.appwrite.models.User.from(map = it) } return client.call( @@ -39,7 +39,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.User::class.java, - convert = convert + converter, ) } @@ -53,9 +53,9 @@ class Account(client: Client) : Service(client) { * 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 "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 between 6 to 32 chars. + * @param password User password. Must be at least 8 chars. * @param name User name. Max length: 128 chars. * @return [io.appwrite.models.User] */ @@ -68,16 +68,16 @@ class Account(client: Client) : Service(client) { name: String? = null ): io.appwrite.models.User { val path = "/account" - val params = mapOf( + val params = mutableMapOf( "userId" to userId, "email" to email, "password" to password, "name" to name ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.User = { + val converter: (Map) -> io.appwrite.models.User = { io.appwrite.models.User.from(map = it) } return client.call( @@ -86,36 +86,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.User::class.java, - convert = convert - ) - } - - /** - * Delete Account - * - * Delete a currently logged in user account. Behind the scene, the user - * record is not deleted but permanently blocked from any access. This is done - * to avoid deleted accounts being overtaken by new users with the same email - * address. Any user-related resources like documents or storage files should - * be deleted separately. - * - * @return [Any] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun delete(): Any { - val path = "/account" - val params = mapOf( - ) - val headers = mapOf( - "content-type" to "application/json" - ) - return client.call( - "DELETE", - path, - headers, - params, - responseType = Any::class.java, + converter, ) } @@ -123,14 +94,16 @@ class Account(client: Client) : Service(client) { * Update Account Email * * Update currently logged in user account email address. After changing user - * address, user confirmation status is being reset and a new confirmation - * mail is sent. For security measures, user password is required to complete - * this request. + * 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 between 6 to 32 chars. + * @param password User password. Must be at least 8 chars. * @return [io.appwrite.models.User] */ @JvmOverloads @@ -140,14 +113,14 @@ class Account(client: Client) : Service(client) { password: String ): io.appwrite.models.User { val path = "/account/email" - val params = mapOf( + val params = mutableMapOf( "email" to email, "password" to password ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.User = { + val converter: (Map) -> io.appwrite.models.User = { io.appwrite.models.User.from(map = it) } return client.call( @@ -156,7 +129,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.User::class.java, - convert = convert + converter, ) } @@ -175,12 +148,12 @@ class Account(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun createJWT(): io.appwrite.models.Jwt { val path = "/account/jwt" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Jwt = { + val converter: (Map) -> io.appwrite.models.Jwt = { io.appwrite.models.Jwt.from(map = it) } return client.call( @@ -189,7 +162,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Jwt::class.java, - convert = convert + converter, ) } @@ -199,8 +172,8 @@ class Account(client: Client) : Service(client) { * 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 limit Maximum number of logs to return in response. Use this value to manage pagination. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Offset value. The default value is 0. Use this param to manage pagination. + * @param limit Maximum number of logs to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. + * @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) * @return [io.appwrite.models.LogList] */ @JvmOverloads @@ -210,14 +183,14 @@ class Account(client: Client) : Service(client) { offset: Long? = null ): io.appwrite.models.LogList { val path = "/account/logs" - val params = mapOf( + val params = mutableMapOf( "limit" to limit, "offset" to offset ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.LogList = { + val converter: (Map) -> io.appwrite.models.LogList = { io.appwrite.models.LogList.from(map = it) } return client.call( @@ -226,7 +199,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.LogList::class.java, - convert = convert + converter, ) } @@ -244,13 +217,13 @@ class Account(client: Client) : Service(client) { name: String ): io.appwrite.models.User { val path = "/account/name" - val params = mapOf( + val params = mutableMapOf( "name" to name ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.User = { + val converter: (Map) -> io.appwrite.models.User = { io.appwrite.models.User.from(map = it) } return client.call( @@ -259,7 +232,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.User::class.java, - convert = convert + converter, ) } @@ -268,10 +241,10 @@ class Account(client: Client) : Service(client) { * * 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 and Team Invites, oldPassword is optional. + * OAuth, Team Invites and Magic URL, oldPassword is optional. * - * @param password New user password. Must be between 6 to 32 chars. - * @param oldPassword Old user password. Must be between 6 to 32 chars. + * @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.User] */ @JvmOverloads @@ -281,14 +254,14 @@ class Account(client: Client) : Service(client) { oldPassword: String? = null ): io.appwrite.models.User { val path = "/account/password" - val params = mapOf( + val params = mutableMapOf( "password" to password, "oldPassword" to oldPassword ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.User = { + val converter: (Map) -> io.appwrite.models.User = { io.appwrite.models.User.from(map = it) } return client.call( @@ -297,7 +270,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.User::class.java, - convert = convert + converter, ) } @@ -312,12 +285,12 @@ class Account(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun getPrefs(): io.appwrite.models.Preferences { val path = "/account/prefs" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Preferences = { + val converter: (Map) -> io.appwrite.models.Preferences = { io.appwrite.models.Preferences.from(map = it) } return client.call( @@ -326,15 +299,16 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Preferences::class.java, - convert = convert + converter, ) } /** * Update Account Preferences * - * Update currently logged in user account preferences. You can pass only the - * specific settings you wish to update. + * 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.User] @@ -345,13 +319,13 @@ class Account(client: Client) : Service(client) { prefs: Any ): io.appwrite.models.User { val path = "/account/prefs" - val params = mapOf( + val params = mutableMapOf( "prefs" to prefs ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.User = { + val converter: (Map) -> io.appwrite.models.User = { io.appwrite.models.User.from(map = it) } return client.call( @@ -360,7 +334,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.User::class.java, - convert = convert + converter, ) } @@ -387,14 +361,14 @@ class Account(client: Client) : Service(client) { url: String ): io.appwrite.models.Token { val path = "/account/recovery" - val params = mapOf( + val params = mutableMapOf( "email" to email, "url" to url ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Token = { + val converter: (Map) -> io.appwrite.models.Token = { io.appwrite.models.Token.from(map = it) } return client.call( @@ -403,7 +377,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Token::class.java, - convert = convert + converter, ) } @@ -420,10 +394,10 @@ class Account(client: Client) : Service(client) { * the only valid redirect URLs are the ones from domains you have set when * adding your platforms in the console interface. * - * @param userId User account UID address. + * @param userId User ID. * @param secret Valid reset token. - * @param password New password. Must be between 6 to 32 chars. - * @param passwordAgain New password again. Must be between 6 to 32 chars. + * @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] */ @JvmOverloads @@ -435,16 +409,16 @@ class Account(client: Client) : Service(client) { passwordAgain: String ): io.appwrite.models.Token { val path = "/account/recovery" - val params = mapOf( + val params = mutableMapOf( "userId" to userId, "secret" to secret, "password" to password, "passwordAgain" to passwordAgain ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Token = { + val converter: (Map) -> io.appwrite.models.Token = { io.appwrite.models.Token.from(map = it) } return client.call( @@ -453,7 +427,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Token::class.java, - convert = convert + converter, ) } @@ -469,12 +443,12 @@ class Account(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun getSessions(): io.appwrite.models.SessionList { val path = "/account/sessions" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.SessionList = { + val converter: (Map) -> io.appwrite.models.SessionList = { io.appwrite.models.SessionList.from(map = it) } return client.call( @@ -483,7 +457,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.SessionList::class.java, - convert = convert + converter, ) } @@ -494,7 +468,7 @@ class Account(client: Client) : Service(client) { * password combination. This route will create a new session for the user. * * @param email User email. - * @param password User password. Must be between 6 to 32 chars. + * @param password User password. Must be at least 8 chars. * @return [io.appwrite.models.Session] */ @JvmOverloads @@ -504,14 +478,14 @@ class Account(client: Client) : Service(client) { password: String ): io.appwrite.models.Session { val path = "/account/sessions" - val params = mapOf( + val params = mutableMapOf( "email" to email, "password" to password ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Session = { + val converter: (Map) -> io.appwrite.models.Session = { io.appwrite.models.Session.from(map = it) } return client.call( @@ -520,7 +494,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Session::class.java, - convert = convert + converter, ) } @@ -536,9 +510,9 @@ class Account(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun deleteSessions(): Any { val path = "/account/sessions" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) return client.call( @@ -566,12 +540,12 @@ class Account(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun createAnonymousSession(): io.appwrite.models.Session { val path = "/account/sessions/anonymous" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Session = { + val converter: (Map) -> io.appwrite.models.Session = { io.appwrite.models.Session.from(map = it) } return client.call( @@ -580,7 +554,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Session::class.java, - convert = convert + converter, ) } @@ -598,7 +572,7 @@ class Account(client: Client) : Service(client) { * 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. + * @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 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] @@ -611,15 +585,15 @@ class Account(client: Client) : Service(client) { url: String? = null ): io.appwrite.models.Token { val path = "/account/sessions/magic-url" - val params = mapOf( + val params = mutableMapOf( "userId" to userId, "email" to email, "url" to url ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Token = { + val converter: (Map) -> io.appwrite.models.Token = { io.appwrite.models.Token.from(map = it) } return client.call( @@ -628,7 +602,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Token::class.java, - convert = convert + converter, ) } @@ -647,7 +621,7 @@ class Account(client: Client) : Service(client) { * the only valid redirect URLs are the ones from domains you have set when * adding your platforms in the console interface. * - * @param userId User unique ID. + * @param userId User ID. * @param secret Valid verification token. * @return [io.appwrite.models.Session] */ @@ -658,14 +632,14 @@ class Account(client: Client) : Service(client) { secret: String ): io.appwrite.models.Session { val path = "/account/sessions/magic-url" - val params = mapOf( + val params = mutableMapOf( "userId" to userId, "secret" to secret ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Session = { + val converter: (Map) -> io.appwrite.models.Session = { io.appwrite.models.Session.from(map = it) } return client.call( @@ -674,7 +648,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Session::class.java, - convert = convert + converter, ) } @@ -694,10 +668,10 @@ class Account(client: Client) : Service(client) { * user.. * * - * @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, bitbucket, bitly, box, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, paypal, paypalSandbox, salesforce, slack, spotify, tradeshift, tradeshiftBox, twitch, vk, yahoo, yandex, wordpress. + * @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, bitbucket, bitly, box, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, notion, okta, paypal, paypalSandbox, salesforce, slack, spotify, tradeshift, tradeshiftBox, twitch, zoom, yahoo, yammer, yandex, wordpress, stripe. * @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. + * @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 128 characters long. * */ @JvmOverloads @@ -710,7 +684,7 @@ class Account(client: Client) : Service(client) { scopes: List? = null ) { val path = "/account/sessions/oauth2/{provider}".replace("{provider}", provider) - val params = mapOf( + val params = mutableMapOf( "success" to success, "failure" to failure, "scopes" to scopes, @@ -766,7 +740,7 @@ class Account(client: Client) : Service(client) { * 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 unique ID. Use the string 'current' to get the current device session. + * @param sessionId Session ID. Use the string 'current' to get the current device session. * @return [io.appwrite.models.Session] */ @JvmOverloads @@ -775,12 +749,12 @@ class Account(client: Client) : Service(client) { sessionId: String ): io.appwrite.models.Session { val path = "/account/sessions/{sessionId}".replace("{sessionId}", sessionId) - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Session = { + val converter: (Map) -> io.appwrite.models.Session = { io.appwrite.models.Session.from(map = it) } return client.call( @@ -789,7 +763,41 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Session::class.java, - convert = convert + converter, + ) + } + + /** + * Update 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. + * + * @param sessionId Session ID. Use the string 'current' to update the current device 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) + val params = mutableMapOf( + ) + val headers = mutableMapOf( + "content-type" to "application/json" + ) + val converter: (Map) -> io.appwrite.models.Session = { + io.appwrite.models.Session.from(map = it) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.Session::class.java, + converter, ) } @@ -798,9 +806,10 @@ class Account(client: Client) : Service(client) { * * 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 - * option id argument, only the session unique ID provider will be deleted. + * Session ID argument, only the unique session ID provided is deleted. + * * - * @param sessionId Session unique ID. Use the string 'current' to delete the current device session. + * @param sessionId Session ID. Use the string 'current' to delete the current device session. * @return [Any] */ @JvmOverloads @@ -809,9 +818,9 @@ class Account(client: Client) : Service(client) { sessionId: String ): Any { val path = "/account/sessions/{sessionId}".replace("{sessionId}", sessionId) - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) return client.call( @@ -823,6 +832,37 @@ class Account(client: Client) : Service(client) { ) } + /** + * Update Account 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.User] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updateStatus(): io.appwrite.models.User { + val path = "/account/status" + val params = mutableMapOf( + ) + val headers = mutableMapOf( + "content-type" to "application/json" + ) + val converter: (Map) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.User::class.java, + converter, + ) + } + /** * Create Email Verification * @@ -851,13 +891,13 @@ class Account(client: Client) : Service(client) { url: String ): io.appwrite.models.Token { val path = "/account/verification" - val params = mapOf( + val params = mutableMapOf( "url" to url ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Token = { + val converter: (Map) -> io.appwrite.models.Token = { io.appwrite.models.Token.from(map = it) } return client.call( @@ -866,7 +906,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Token::class.java, - convert = convert + converter, ) } @@ -878,7 +918,7 @@ class Account(client: Client) : Service(client) { * to verify the user email ownership. If confirmed this route will return a * 200 status code. * - * @param userId User unique ID. + * @param userId User ID. * @param secret Valid verification token. * @return [io.appwrite.models.Token] */ @@ -889,14 +929,14 @@ class Account(client: Client) : Service(client) { secret: String ): io.appwrite.models.Token { val path = "/account/verification" - val params = mapOf( + val params = mutableMapOf( "userId" to userId, "secret" to secret ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Token = { + val converter: (Map) -> io.appwrite.models.Token = { io.appwrite.models.Token.from(map = it) } return client.call( @@ -905,7 +945,7 @@ class Account(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Token::class.java, - convert = convert + converter, ) } diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt index 912b1e5..20e1f54 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -16,9 +16,14 @@ class Avatars(client: Client) : Service(client) { * 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 - * /account/sessions endpoint. Use width, height and quality arguments to - * change the output settings. + * 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. @@ -35,7 +40,7 @@ class Avatars(client: Client) : Service(client) { quality: Long? = null ): ByteArray { val path = "/avatars/browsers/{code}".replace("{code}", code) - val params = mapOf( + val params = mutableMapOf( "width" to width, "height" to height, "quality" to quality, @@ -55,6 +60,12 @@ class Avatars(client: Client) : Service(client) { * 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. @@ -71,7 +82,7 @@ class Avatars(client: Client) : Service(client) { quality: Long? = null ): ByteArray { val path = "/avatars/credit-cards/{code}".replace("{code}", code) - val params = mapOf( + val params = mutableMapOf( "width" to width, "height" to height, "quality" to quality, @@ -101,7 +112,7 @@ class Avatars(client: Client) : Service(client) { url: String ): ByteArray { val path = "/avatars/favicon" - val params = mapOf( + val params = mutableMapOf( "url" to url, "project" to client.config["project"] ) @@ -119,6 +130,12 @@ class Avatars(client: Client) : Service(client) { * 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. + * + * 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. @@ -135,7 +152,7 @@ class Avatars(client: Client) : Service(client) { quality: Long? = null ): ByteArray { val path = "/avatars/flags/{code}".replace("{code}", code) - val params = mapOf( + val params = mutableMapOf( "width" to width, "height" to height, "quality" to quality, @@ -156,10 +173,16 @@ class Avatars(client: Client) : Service(client) { * 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. - * @param height Resize preview image height, Pass an integer between 0 to 2000. + * @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] */ @JvmOverloads @@ -170,7 +193,7 @@ class Avatars(client: Client) : Service(client) { height: Long? = null ): ByteArray { val path = "/avatars/image" - val params = mapOf( + val params = mutableMapOf( "url" to url, "width" to width, "height" to height, @@ -197,6 +220,12 @@ class Avatars(client: Client) : Service(client) { * 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. @@ -215,7 +244,7 @@ class Avatars(client: Client) : Service(client) { background: String? = null ): ByteArray { val path = "/avatars/initials" - val params = mapOf( + val params = mutableMapOf( "name" to name, "width" to width, "height" to height, @@ -236,9 +265,10 @@ class Avatars(client: Client) : Service(client) { * * 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 0 to 1000. Defaults to 400. + * @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] @@ -252,7 +282,7 @@ class Avatars(client: Client) : Service(client) { download: Boolean? = null ): ByteArray { val path = "/avatars/qr" - val params = mapOf( + val params = mutableMapOf( "text" to text, "size" to size, "margin" to margin, diff --git a/library/src/main/java/io/appwrite/services/Database.kt b/library/src/main/java/io/appwrite/services/Database.kt index 357796a..74bced3 100644 --- a/library/src/main/java/io/appwrite/services/Database.kt +++ b/library/src/main/java/io/appwrite/services/Database.kt @@ -18,14 +18,14 @@ class Database(client: Client) : Service(client) { * of the project's documents. [Learn more about different API * modes](/docs/admin). * - * @param collectionId Collection unique ID. You can create a new collection using the Database service [server integration](/docs/server/database#createCollection). - * @param queries Array of query strings. - * @param limit Maximum number of documents to return in response. Use this value to manage pagination. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Offset value. The default value is 0. Use this param to manage pagination. - * @param cursor ID of the document used as the starting point for the query, excluding the document itself. Should be used for efficient pagination when working with large sets of data. + * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/database#querying-documents). Maximum of 100 queries are allowed, each 128 characters long. + * @param limit Maximum number of documents to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. + * @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) + * @param cursor ID of the document used as the starting point for the query, excluding the document itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) * @param cursorDirection Direction of the cursor. - * @param orderAttributes Array of attributes used to sort results. - * @param orderTypes Array of order directions for sorting attribtues. Possible values are DESC for descending order, or ASC for ascending order. + * @param orderAttributes Array of attributes used to sort results. Maximum of 100 order attributes are allowed, each 128 characters long. + * @param orderTypes Array of order directions for sorting attribtues. Possible values are DESC for descending order, or ASC for ascending order. Maximum of 100 order types are allowed. * @return [io.appwrite.models.DocumentList] */ @JvmOverloads @@ -41,7 +41,7 @@ class Database(client: Client) : Service(client) { orderTypes: List? = null ): io.appwrite.models.DocumentList { val path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId) - val params = mapOf( + val params = mutableMapOf( "queries" to queries, "limit" to limit, "offset" to offset, @@ -50,10 +50,10 @@ class Database(client: Client) : Service(client) { "orderAttributes" to orderAttributes, "orderTypes" to orderTypes ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.DocumentList = { + val converter: (Map) -> io.appwrite.models.DocumentList = { io.appwrite.models.DocumentList.from(map = it) } return client.call( @@ -62,7 +62,7 @@ class Database(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.DocumentList::class.java, - convert = convert + converter, ) } @@ -74,11 +74,11 @@ class Database(client: Client) : Service(client) { * integration](/docs/server/database#databaseCreateCollection) API or * directly from your database console. * - * @param collectionId Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection). - * @param documentId 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 collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). 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 data Document data as JSON object. - * @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. - * @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. + * @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. + * @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. * @return [io.appwrite.models.Document] */ @JvmOverloads @@ -91,16 +91,16 @@ class Database(client: Client) : Service(client) { write: List? = null ): io.appwrite.models.Document { val path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId) - val params = mapOf( + val params = mutableMapOf( "documentId" to documentId, "data" to data, "read" to read, "write" to write ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Document = { + val converter: (Map) -> io.appwrite.models.Document = { io.appwrite.models.Document.from(map = it) } return client.call( @@ -109,7 +109,7 @@ class Database(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Document::class.java, - convert = convert + converter, ) } @@ -119,8 +119,8 @@ class Database(client: Client) : Service(client) { * Get a document by its unique ID. This endpoint response returns a JSON * object with the document data. * - * @param collectionId Collection unique ID. You can create a new collection using the Database service [server integration](/docs/server/database#createCollection). - * @param documentId Document unique ID. + * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). + * @param documentId Document ID. * @return [io.appwrite.models.Document] */ @JvmOverloads @@ -130,12 +130,12 @@ class Database(client: Client) : Service(client) { documentId: String ): io.appwrite.models.Document { val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId) - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Document = { + val converter: (Map) -> io.appwrite.models.Document = { io.appwrite.models.Document.from(map = it) } return client.call( @@ -144,7 +144,7 @@ class Database(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Document::class.java, - convert = convert + converter, ) } @@ -154,11 +154,11 @@ class Database(client: Client) : Service(client) { * Update a document by its unique ID. Using the patch method you can pass * only specific fields that will get updated. * - * @param collectionId Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection). - * @param documentId Document unique ID. - * @param data Document data as JSON object. - * @param read An array of strings with read permissions. By default inherits the existing read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. - * @param write An array of strings with write permissions. By default inherits the existing write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. + * @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 read An array of strings with read permissions. By default inherits the existing read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. + * @param write An array of strings with write permissions. By default inherits the existing write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. * @return [io.appwrite.models.Document] */ @JvmOverloads @@ -171,15 +171,15 @@ class Database(client: Client) : Service(client) { write: List? = null ): io.appwrite.models.Document { val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId) - val params = mapOf( + val params = mutableMapOf( "data" to data, "read" to read, "write" to write ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Document = { + val converter: (Map) -> io.appwrite.models.Document = { io.appwrite.models.Document.from(map = it) } return client.call( @@ -188,19 +188,17 @@ class Database(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Document::class.java, - convert = convert + converter, ) } /** * Delete Document * - * Delete a document by its unique ID. This endpoint deletes only the parent - * documents, its attributes and relations to other documents. Child documents - * **will not** be deleted. + * Delete a document by its unique ID. * - * @param collectionId Collection unique ID. You can create a new collection using the Database service [server integration](/docs/server/database#createCollection). - * @param documentId Document unique ID. + * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). + * @param documentId Document ID. * @return [Any] */ @JvmOverloads @@ -210,9 +208,9 @@ class Database(client: Client) : Service(client) { documentId: String ): Any { val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId) - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) return client.call( diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index 742f2b4..85a1f2c 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -10,6 +10,36 @@ import java.io.File class Functions(client: Client) : Service(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 * @@ -18,11 +48,11 @@ class Functions(client: Client) : Service(client) { * return a list of all of the project's executions. [Learn more about * different API modes](/docs/admin). * - * @param functionId Function unique ID. - * @param limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Results offset. The default value is 0. Use this param to manage pagination. + * @param functionId Function ID. + * @param limit Maximum number of executions to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. + * @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) * @param search Search term to filter your list results. Max length: 256 chars. - * @param cursor ID of the execution used as the starting point for the query, excluding the execution itself. Should be used for efficient pagination when working with large sets of data. + * @param cursor ID of the execution used as the starting point for the query, excluding the execution itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) * @param cursorDirection Direction of the cursor. * @return [io.appwrite.models.ExecutionList] */ @@ -37,17 +67,17 @@ class Functions(client: Client) : Service(client) { cursorDirection: String? = null ): io.appwrite.models.ExecutionList { val path = "/functions/{functionId}/executions".replace("{functionId}", functionId) - val params = mapOf( + val params = mutableMapOf( "limit" to limit, "offset" to offset, "search" to search, "cursor" to cursor, "cursorDirection" to cursorDirection ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.ExecutionList = { + val converter: (Map) -> io.appwrite.models.ExecutionList = { io.appwrite.models.ExecutionList.from(map = it) } return client.call( @@ -56,7 +86,7 @@ class Functions(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.ExecutionList::class.java, - convert = convert + converter, ) } @@ -68,24 +98,27 @@ class Functions(client: Client) : Service(client) { * updates on the current execution status. Once this endpoint is called, your * function execution process will start asynchronously. * - * @param functionId Function unique ID. + * @param functionId Function ID. * @param data String of custom data to send to function. + * @param async Execute code asynchronously. Default value is true. * @return [io.appwrite.models.Execution] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun createExecution( functionId: String, - data: String? = null + data: String? = null, + async: Boolean? = null ): io.appwrite.models.Execution { val path = "/functions/{functionId}/executions".replace("{functionId}", functionId) - val params = mapOf( - "data" to data + val params = mutableMapOf( + "data" to data, + "async" to async ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Execution = { + val converter: (Map) -> io.appwrite.models.Execution = { io.appwrite.models.Execution.from(map = it) } return client.call( @@ -94,7 +127,7 @@ class Functions(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Execution::class.java, - convert = convert + converter, ) } @@ -103,8 +136,8 @@ class Functions(client: Client) : Service(client) { * * Get a function execution log by its unique ID. * - * @param functionId Function unique ID. - * @param executionId Execution unique ID. + * @param functionId Function ID. + * @param executionId Execution ID. * @return [io.appwrite.models.Execution] */ @JvmOverloads @@ -114,12 +147,12 @@ class Functions(client: Client) : Service(client) { executionId: String ): io.appwrite.models.Execution { val path = "/functions/{functionId}/executions/{executionId}".replace("{functionId}", functionId).replace("{executionId}", executionId) - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Execution = { + val converter: (Map) -> io.appwrite.models.Execution = { io.appwrite.models.Execution.from(map = it) } return client.call( @@ -128,7 +161,7 @@ class Functions(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Execution::class.java, - convert = convert + converter, ) } diff --git a/library/src/main/java/io/appwrite/services/Locale.kt b/library/src/main/java/io/appwrite/services/Locale.kt index 423a323..21b297c 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -26,12 +26,12 @@ class Locale(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun get(): io.appwrite.models.Locale { val path = "/locale" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Locale = { + val converter: (Map) -> io.appwrite.models.Locale = { io.appwrite.models.Locale.from(map = it) } return client.call( @@ -40,7 +40,7 @@ class Locale(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Locale::class.java, - convert = convert + converter, ) } @@ -56,12 +56,12 @@ class Locale(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun getContinents(): io.appwrite.models.ContinentList { val path = "/locale/continents" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.ContinentList = { + val converter: (Map) -> io.appwrite.models.ContinentList = { io.appwrite.models.ContinentList.from(map = it) } return client.call( @@ -70,7 +70,7 @@ class Locale(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.ContinentList::class.java, - convert = convert + converter, ) } @@ -86,12 +86,12 @@ class Locale(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun getCountries(): io.appwrite.models.CountryList { val path = "/locale/countries" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.CountryList = { + val converter: (Map) -> io.appwrite.models.CountryList = { io.appwrite.models.CountryList.from(map = it) } return client.call( @@ -100,7 +100,7 @@ class Locale(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.CountryList::class.java, - convert = convert + converter, ) } @@ -116,12 +116,12 @@ class Locale(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun getCountriesEU(): io.appwrite.models.CountryList { val path = "/locale/countries/eu" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.CountryList = { + val converter: (Map) -> io.appwrite.models.CountryList = { io.appwrite.models.CountryList.from(map = it) } return client.call( @@ -130,7 +130,7 @@ class Locale(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.CountryList::class.java, - convert = convert + converter, ) } @@ -146,12 +146,12 @@ class Locale(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun getCountriesPhones(): io.appwrite.models.PhoneList { val path = "/locale/countries/phones" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.PhoneList = { + val converter: (Map) -> io.appwrite.models.PhoneList = { io.appwrite.models.PhoneList.from(map = it) } return client.call( @@ -160,7 +160,7 @@ class Locale(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.PhoneList::class.java, - convert = convert + converter, ) } @@ -177,12 +177,12 @@ class Locale(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun getCurrencies(): io.appwrite.models.CurrencyList { val path = "/locale/currencies" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.CurrencyList = { + val converter: (Map) -> io.appwrite.models.CurrencyList = { io.appwrite.models.CurrencyList.from(map = it) } return client.call( @@ -191,7 +191,7 @@ class Locale(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.CurrencyList::class.java, - convert = convert + converter, ) } @@ -207,12 +207,12 @@ class Locale(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun getLanguages(): io.appwrite.models.LanguageList { val path = "/locale/languages" - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.LanguageList = { + val converter: (Map) -> io.appwrite.models.LanguageList = { io.appwrite.models.LanguageList.from(map = it) } return client.call( @@ -221,7 +221,7 @@ class Locale(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.LanguageList::class.java, - convert = convert + converter, ) } diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index 8e68487..c1e0abc 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -19,10 +19,11 @@ class Storage(client: Client) : Service(client) { * 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). * + * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket). * @param search Search term to filter your list results. Max length: 256 chars. - * @param limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Results offset. The default value is 0. Use this param to manage pagination. - * @param cursor ID of the file used as the starting point for the query, excluding the file itself. Should be used for efficient pagination when working with large sets of data. + * @param limit Maximum number of files to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. + * @param offset Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) + * @param cursor ID of the file used as the starting point for the query, excluding the file itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) * @param cursorDirection Direction of the cursor. * @param orderType Order result by ASC or DESC order. * @return [io.appwrite.models.FileList] @@ -30,6 +31,7 @@ class Storage(client: Client) : Service(client) { @JvmOverloads @Throws(AppwriteException::class) suspend fun listFiles( + bucketId: String, search: String? = null, limit: Long? = null, offset: Long? = null, @@ -37,8 +39,8 @@ class Storage(client: Client) : Service(client) { cursorDirection: String? = null, orderType: String? = null ): io.appwrite.models.FileList { - val path = "/storage/files" - val params = mapOf( + val path = "/storage/buckets/{bucketId}/files".replace("{bucketId}", bucketId) + val params = mutableMapOf( "search" to search, "limit" to limit, "offset" to offset, @@ -46,10 +48,10 @@ class Storage(client: Client) : Service(client) { "cursorDirection" to cursorDirection, "orderType" to orderType ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.FileList = { + val converter: (Map) -> io.appwrite.models.FileList = { io.appwrite.models.FileList.from(map = it) } return client.call( @@ -58,51 +60,72 @@ class Storage(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.FileList::class.java, - convert = convert + converter, ) } /** * Create File * - * Create a new file. The user who creates the file will automatically be - * assigned to read and write access unless he has passed custom values for - * read and write arguments. + * Create a new file. Before using this route, you should create a new bucket + * resource using either a [server + * integration](/docs/server/database#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 fileId 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 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 file Binary file. - * @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. - * @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. + * @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. + * @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. * @return [io.appwrite.models.File] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun createFile( + bucketId: String, fileId: String, file: File, read: List? = null, - write: List? = null + write: List? = null, onProgress: ((UploadProgress) -> Unit)? = null ): io.appwrite.models.File { - val path = "/storage/files" - val params = mapOf( + val path = "/storage/buckets/{bucketId}/files".replace("{bucketId}", bucketId) + val params = mutableMapOf( "fileId" to fileId, "file" to file, "read" to read, "write" to write ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "multipart/form-data" ) - val convert: (Map) -> io.appwrite.models.File = { + val converter: (Map) -> io.appwrite.models.File = { io.appwrite.models.File.from(map = it) } - return client.call( - "POST", + val idParamName: String? = "fileId" + val paramName = "file" + return client.chunkedUpload( path, headers, params, responseType = io.appwrite.models.File::class.java, - convert = convert + converter, + paramName, + idParamName, + onProgress, ) } @@ -112,21 +135,23 @@ class Storage(client: Client) : Service(client) { * Get a file by its unique ID. This endpoint response returns a JSON object * with the file metadata. * - * @param fileId File unique ID. + * @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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getFile( + bucketId: String, fileId: String ): io.appwrite.models.File { - val path = "/storage/files/{fileId}".replace("{fileId}", fileId) - val params = mapOf( + val path = "/storage/buckets/{bucketId}/files/{fileId}".replace("{bucketId}", bucketId).replace("{fileId}", fileId) + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.File = { + val converter: (Map) -> io.appwrite.models.File = { io.appwrite.models.File.from(map = it) } return client.call( @@ -135,7 +160,7 @@ class Storage(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.File::class.java, - convert = convert + converter, ) } @@ -145,27 +170,29 @@ class Storage(client: Client) : Service(client) { * 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 read An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. - * @param write An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions. + * @param read An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. + * @param write An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. * @return [io.appwrite.models.File] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun updateFile( + bucketId: String, fileId: String, - read: List, - write: List + read: List? = null, + write: List? = null ): io.appwrite.models.File { - val path = "/storage/files/{fileId}".replace("{fileId}", fileId) - val params = mapOf( + val path = "/storage/buckets/{bucketId}/files/{fileId}".replace("{bucketId}", bucketId).replace("{fileId}", fileId) + val params = mutableMapOf( "read" to read, "write" to write ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.File = { + val converter: (Map) -> io.appwrite.models.File = { io.appwrite.models.File.from(map = it) } return client.call( @@ -174,7 +201,7 @@ class Storage(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.File::class.java, - convert = convert + converter, ) } @@ -184,18 +211,20 @@ class Storage(client: Client) : Service(client) { * Delete a file by its unique ID. Only users with write permissions have * access to delete this resource. * - * @param fileId File unique ID. + * @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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun deleteFile( + bucketId: String, fileId: String ): Any { - val path = "/storage/files/{fileId}".replace("{fileId}", fileId) - val params = mapOf( + val path = "/storage/buckets/{bucketId}/files/{fileId}".replace("{bucketId}", bucketId).replace("{fileId}", fileId) + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) return client.call( @@ -214,16 +243,18 @@ class Storage(client: Client) : Service(client) { * 'Content-Disposition: attachment' header that tells the browser to start * downloading the file to user downloads directory. * - * @param fileId File unique ID. + * @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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getFileDownload( + bucketId: String, fileId: String ): ByteArray { - val path = "/storage/files/{fileId}/download".replace("{fileId}", fileId) - val params = mapOf( + 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( @@ -240,9 +271,11 @@ class Storage(client: Client) : Service(client) { * 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. + * string arguments for cutting and resizing your preview image. Preview is + * supported only for image files smaller than 10MB. * - * @param fileId File unique ID + * @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 * @param width Resize preview image width, Pass an integer between 0 to 4000. * @param height Resize preview image height, Pass an integer between 0 to 4000. * @param gravity Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right @@ -251,7 +284,7 @@ class Storage(client: Client) : Service(client) { * @param borderColor Preview image border color. Use a valid HEX color, no # is needed for prefix. * @param borderRadius Preview image border radius in pixels. Pass an integer between 0 to 4000. * @param opacity Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1. - * @param rotation Preview image rotation in degrees. Pass an integer between 0 and 360. + * @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] @@ -259,6 +292,7 @@ class Storage(client: Client) : Service(client) { @JvmOverloads @Throws(AppwriteException::class) suspend fun getFilePreview( + bucketId: String, fileId: String, width: Long? = null, height: Long? = null, @@ -272,8 +306,8 @@ class Storage(client: Client) : Service(client) { background: String? = null, output: String? = null ): ByteArray { - val path = "/storage/files/{fileId}/preview".replace("{fileId}", fileId) - val params = mapOf( + val path = "/storage/buckets/{bucketId}/files/{fileId}/preview".replace("{bucketId}", bucketId).replace("{fileId}", fileId) + val params = mutableMapOf( "width" to width, "height" to height, "gravity" to gravity, @@ -302,16 +336,18 @@ class Storage(client: Client) : Service(client) { * download method but returns with no 'Content-Disposition: attachment' * header. * - * @param fileId File unique ID. + * @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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getFileView( + bucketId: String, fileId: String ): ByteArray { - val path = "/storage/files/{fileId}/view".replace("{fileId}", fileId) - val params = mapOf( + 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( diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 53bd147..5b74d1d 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -13,15 +13,16 @@ class Teams(client: Client) : Service(client) { /** * List Teams * - * Get a list of all the current user teams. 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 teams. [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. + * + * In admin mode, this endpoint returns a list of all the teams in the current + * project. [Learn more about different API modes](/docs/admin). * * @param search Search term to filter your list results. Max length: 256 chars. - * @param limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Results offset. The default value is 0. Use this param to manage pagination. - * @param cursor ID of the team used as the starting point for the query, excluding the team itself. Should be used for efficient pagination when working with large sets of data. + * @param limit Maximum number of teams to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. + * @param offset Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) + * @param cursor ID of the team used as the starting point for the query, excluding the team itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) * @param cursorDirection Direction of the cursor. * @param orderType Order result by ASC or DESC order. * @return [io.appwrite.models.TeamList] @@ -37,7 +38,7 @@ class Teams(client: Client) : Service(client) { orderType: String? = null ): io.appwrite.models.TeamList { val path = "/teams" - val params = mapOf( + val params = mutableMapOf( "search" to search, "limit" to limit, "offset" to offset, @@ -45,10 +46,10 @@ class Teams(client: Client) : Service(client) { "cursorDirection" to cursorDirection, "orderType" to orderType ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.TeamList = { + val converter: (Map) -> io.appwrite.models.TeamList = { io.appwrite.models.TeamList.from(map = it) } return client.call( @@ -57,7 +58,7 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.TeamList::class.java, - convert = convert + converter, ) } @@ -65,13 +66,12 @@ class Teams(client: Client) : Service(client) { * Create Team * * Create a new team. The user who creates the team will automatically be - * assigned as the owner of the team. The team owner can invite new members, - * who will be able add new owners and update or delete the team from your - * project. + * 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 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 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 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). Max length for each role is 32 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] */ @JvmOverloads @@ -82,15 +82,15 @@ class Teams(client: Client) : Service(client) { roles: List? = null ): io.appwrite.models.Team { val path = "/teams" - val params = mapOf( + val params = mutableMapOf( "teamId" to teamId, "name" to name, "roles" to roles ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Team = { + val converter: (Map) -> io.appwrite.models.Team = { io.appwrite.models.Team.from(map = it) } return client.call( @@ -99,17 +99,16 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Team::class.java, - convert = convert + converter, ) } /** * Get Team * - * Get a team by its unique ID. All team members have read access for this - * resource. + * Get a team by its ID. All team members have read access for this resource. * - * @param teamId Team unique ID. + * @param teamId Team ID. * @return [io.appwrite.models.Team] */ @JvmOverloads @@ -118,12 +117,12 @@ class Teams(client: Client) : Service(client) { teamId: String ): io.appwrite.models.Team { val path = "/teams/{teamId}".replace("{teamId}", teamId) - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Team = { + val converter: (Map) -> io.appwrite.models.Team = { io.appwrite.models.Team.from(map = it) } return client.call( @@ -132,18 +131,18 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Team::class.java, - convert = convert + converter, ) } /** * Update Team * - * Update a team by its unique ID. Only team owners have write access for this - * resource. + * Update a team using its ID. Only members with the owner role can update the + * team. * - * @param teamId Team unique ID. - * @param name Team name. Max length: 128 chars. + * @param teamId Team ID. + * @param name New team name. Max length: 128 chars. * @return [io.appwrite.models.Team] */ @JvmOverloads @@ -153,13 +152,13 @@ class Teams(client: Client) : Service(client) { name: String ): io.appwrite.models.Team { val path = "/teams/{teamId}".replace("{teamId}", teamId) - val params = mapOf( + val params = mutableMapOf( "name" to name ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Team = { + val converter: (Map) -> io.appwrite.models.Team = { io.appwrite.models.Team.from(map = it) } return client.call( @@ -168,17 +167,17 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Team::class.java, - convert = convert + converter, ) } /** * Delete Team * - * Delete a team by its unique ID. Only team owners have write access for this - * resource. + * Delete a team using its ID. Only team members with the owner role can + * delete the team. * - * @param teamId Team unique ID. + * @param teamId Team ID. * @return [Any] */ @JvmOverloads @@ -187,9 +186,9 @@ class Teams(client: Client) : Service(client) { teamId: String ): Any { val path = "/teams/{teamId}".replace("{teamId}", teamId) - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) return client.call( @@ -204,14 +203,14 @@ class Teams(client: Client) : Service(client) { /** * Get Team Memberships * - * Get a team members by the team unique ID. All team members have read access - * for this list of resources. + * 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 unique ID. + * @param teamId Team ID. * @param search Search term to filter your list results. Max length: 256 chars. - * @param limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Results offset. The default value is 0. Use this param to manage pagination. - * @param cursor ID of the membership used as the starting point for the query, excluding the membership itself. Should be used for efficient pagination when working with large sets of data. + * @param limit Maximum number of memberships to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. + * @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) + * @param cursor ID of the membership used as the starting point for the query, excluding the membership itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) * @param cursorDirection Direction of the cursor. * @param orderType Order result by ASC or DESC order. * @return [io.appwrite.models.MembershipList] @@ -228,7 +227,7 @@ class Teams(client: Client) : Service(client) { orderType: String? = null ): io.appwrite.models.MembershipList { val path = "/teams/{teamId}/memberships".replace("{teamId}", teamId) - val params = mapOf( + val params = mutableMapOf( "search" to search, "limit" to limit, "offset" to offset, @@ -236,10 +235,10 @@ class Teams(client: Client) : Service(client) { "cursorDirection" to cursorDirection, "orderType" to orderType ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.MembershipList = { + val converter: (Map) -> io.appwrite.models.MembershipList = { io.appwrite.models.MembershipList.from(map = it) } return client.call( @@ -248,35 +247,34 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.MembershipList::class.java, - convert = convert + converter, ) } /** * Create Team Membership * - * Use this endpoint to invite a new member to join your team. If initiated - * from Client SDK, an email with a link to join the team will be sent to the - * new member's email address if the member doesn't exist in the project it - * will be created automatically. If initiated from server side SDKs, new - * member will automatically be added to the team. + * 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 + * 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. While calling from side - * SDKs the redirect url can be empty string. + * the user to accept the invitation to the team. * - * Please note that in order to avoid a [Redirect - * Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) + * 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 - * added your platforms in the console interface. + * adding your platforms in the console interface. * - * @param teamId Team unique ID. - * @param email New team member email. - * @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). Max length for each role is 32 chars. + * @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 New team member name. Max length: 128 chars. + * @param name Name of the new team member. Max length: 128 chars. * @return [io.appwrite.models.Membership] */ @JvmOverloads @@ -289,16 +287,16 @@ class Teams(client: Client) : Service(client) { name: String? = null ): io.appwrite.models.Membership { val path = "/teams/{teamId}/memberships".replace("{teamId}", teamId) - val params = mapOf( + val params = mutableMapOf( "email" to email, "roles" to roles, "url" to url, "name" to name ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Membership = { + val converter: (Map) -> io.appwrite.models.Membership = { io.appwrite.models.Membership.from(map = it) } return client.call( @@ -307,7 +305,7 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Membership::class.java, - convert = convert + converter, ) } @@ -317,8 +315,8 @@ class Teams(client: Client) : Service(client) { * Get a team member by the membership unique id. All team members have read * access for this resource. * - * @param teamId Team unique ID. - * @param membershipId membership unique ID. + * @param teamId Team ID. + * @param membershipId Membership ID. * @return [io.appwrite.models.MembershipList] */ @JvmOverloads @@ -328,12 +326,12 @@ class Teams(client: Client) : Service(client) { membershipId: String ): io.appwrite.models.MembershipList { val path = "/teams/{teamId}/memberships/{membershipId}".replace("{teamId}", teamId).replace("{membershipId}", membershipId) - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.MembershipList = { + val converter: (Map) -> io.appwrite.models.MembershipList = { io.appwrite.models.MembershipList.from(map = it) } return client.call( @@ -342,16 +340,20 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.MembershipList::class.java, - convert = convert + converter, ) } /** * Update Membership Roles * - * @param teamId Team unique ID. + * 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 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). Max length for each role is 32 chars. + * @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] */ @JvmOverloads @@ -362,13 +364,13 @@ class Teams(client: Client) : Service(client) { roles: List ): io.appwrite.models.Membership { val path = "/teams/{teamId}/memberships/{membershipId}".replace("{teamId}", teamId).replace("{membershipId}", membershipId) - val params = mapOf( + val params = mutableMapOf( "roles" to roles ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Membership = { + val converter: (Map) -> io.appwrite.models.Membership = { io.appwrite.models.Membership.from(map = it) } return client.call( @@ -377,7 +379,7 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Membership::class.java, - convert = convert + converter, ) } @@ -388,7 +390,7 @@ class Teams(client: Client) : Service(client) { * 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 unique ID. + * @param teamId Team ID. * @param membershipId Membership ID. * @return [Any] */ @@ -399,9 +401,9 @@ class Teams(client: Client) : Service(client) { membershipId: String ): Any { val path = "/teams/{teamId}/memberships/{membershipId}".replace("{teamId}", teamId).replace("{membershipId}", membershipId) - val params = mapOf( + val params = mutableMapOf( ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) return client.call( @@ -417,12 +419,16 @@ class Teams(client: Client) : Service(client) { * 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 recieved + * 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 unique ID. + * @param teamId Team ID. * @param membershipId Membership ID. - * @param userId User unique ID. + * @param userId User ID. * @param secret Secret key. * @return [io.appwrite.models.Membership] */ @@ -435,14 +441,14 @@ class Teams(client: Client) : Service(client) { secret: String ): io.appwrite.models.Membership { val path = "/teams/{teamId}/memberships/{membershipId}/status".replace("{teamId}", teamId).replace("{membershipId}", membershipId) - val params = mapOf( + val params = mutableMapOf( "userId" to userId, "secret" to secret ) - val headers = mapOf( + val headers = mutableMapOf( "content-type" to "application/json" ) - val convert: (Map) -> io.appwrite.models.Membership = { + val converter: (Map) -> io.appwrite.models.Membership = { io.appwrite.models.Membership.from(map = it) } return client.call( @@ -451,7 +457,7 @@ class Teams(client: Client) : Service(client) { headers, params, responseType = io.appwrite.models.Membership::class.java, - convert = convert + converter, ) } From 62988881309f32cbc2a14fd55783f836882c492e Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Tue, 17 May 2022 19:52:16 +0400 Subject: [PATCH 035/118] feat: update CI file --- .github/workflows/publish.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ae9090b..281c954 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -25,10 +25,9 @@ jobs: git fetch --unshallow sudo bash -c "echo '$GPG_KEY_CONTENTS' | base64 -d > '$SIGNING_SECRET_KEY_RING_FILE'" chmod +x ./gradlew - # Builds the release artifacts of the library - name: Build Release Artifacts - run: ./gradlew library:assembleRelease + run: ./gradlew --info library:assembleRelease # Generates other artifacts (javadocJar is optional) - name: Generate Source jar @@ -39,10 +38,10 @@ jobs: run: | if ${{ endswith(github.event.release.tag_name, '-SNAPSHOT') }}; then echo "Publising Snapshot Version ${{ github.event.release.tag_name}} to Snapshot repository" - ./gradlew publishToSonatype + ./gradlew publishReleasePublicationToSonatypeRepository else echo "Publising Release Version ${{ github.event.release.tag_name}} to Staging repository" - ./gradlew publishToSonatype --max-workers 1 closeAndReleaseSonatypeStagingRepository + ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository fi env: OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} @@ -51,4 +50,4 @@ jobs: SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }} SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} - SDK_VERSION: ${{ github.event.release.tag_name }} + SDK_VERSION: ${{ github.event.release.tag_name }} \ No newline at end of file From 4790c599aeb99686ef3b3db72a757aca2955151f Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Tue, 17 May 2022 20:21:38 +0400 Subject: [PATCH 036/118] feat: update version --- .github/workflows/publish.yml | 7 ++++--- README.md | 4 ++-- library/src/main/java/io/appwrite/services/Storage.kt | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 281c954..c5be330 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -25,9 +25,10 @@ jobs: git fetch --unshallow sudo bash -c "echo '$GPG_KEY_CONTENTS' | base64 -d > '$SIGNING_SECRET_KEY_RING_FILE'" chmod +x ./gradlew + # Builds the release artifacts of the library - name: Build Release Artifacts - run: ./gradlew --info library:assembleRelease + run: ./gradlew library:assembleRelease # Generates other artifacts (javadocJar is optional) - name: Generate Source jar @@ -38,10 +39,10 @@ jobs: run: | if ${{ endswith(github.event.release.tag_name, '-SNAPSHOT') }}; then echo "Publising Snapshot Version ${{ github.event.release.tag_name}} to Snapshot repository" - ./gradlew publishReleasePublicationToSonatypeRepository + ./gradlew publishToSonatype else echo "Publising Release Version ${{ github.event.release.tag_name}} to Staging repository" - ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository + ./gradlew publishToSonatype --max-workers 1 closeAndReleaseSonatypeStagingRepository fi env: OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} diff --git a/README.md b/README.md index 1f076d6..f6ba544 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:0.6.0") +implementation("io.appwrite:sdk-for-android:0.6.1") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 0.6.0 + 0.6.1 ``` diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index a632fd2..c1e0abc 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -115,7 +115,7 @@ class Storage(client: Client) : Service(client) { val converter: (Map) -> io.appwrite.models.File = { io.appwrite.models.File.from(map = it) } - val idParamName: String? = "fileId" + val idParamName: String? = "fileId" val paramName = "file" return client.chunkedUpload( path, From 3f72f7540de71a00d8ee446b7b3470d628bf8f6d Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Tue, 28 Jun 2022 13:33:17 +0200 Subject: [PATCH 037/118] feat: introduce 0.15.x support --- README.md | 8 +- ...ate-session.md => create-email-session.md} | 2 +- .../java/account/create-phone-session.md | 49 +++ .../java/account/create-phone-verification.md | 46 +++ .../java/account/update-phone-session.md | 49 +++ .../java/account/update-phone-verification.md | 49 +++ docs/examples/java/account/update-phone.md | 49 +++ .../create-document.md | 6 +- .../delete-document.md | 6 +- .../{database => databases}/get-document.md | 6 +- .../{database => databases}/list-documents.md | 6 +- .../update-document.md | 7 +- docs/examples/java/storage/create-file.md | 2 +- ...ate-session.md => create-email-session.md} | 2 +- .../kotlin/account/create-phone-session.md | 27 ++ .../account/create-phone-verification.md | 24 ++ .../kotlin/account/update-phone-session.md | 27 ++ .../account/update-phone-verification.md | 27 ++ docs/examples/kotlin/account/update-phone.md | 27 ++ .../create-document.md | 6 +- .../delete-document.md | 6 +- .../{database => databases}/get-document.md | 6 +- .../{database => databases}/list-documents.md | 6 +- .../update-document.md | 7 +- docs/examples/kotlin/storage/create-file.md | 2 +- library/src/main/java/io/appwrite/Client.kt | 50 +++- .../main/java/io/appwrite/models/Document.kt | 18 ++ .../main/java/io/appwrite/models/Execution.kt | 27 +- .../src/main/java/io/appwrite/models/File.kt | 27 +- .../main/java/io/appwrite/models/InputFile.kt | 37 +++ .../java/io/appwrite/models/Membership.kt | 18 ++ .../main/java/io/appwrite/models/Session.kt | 9 + .../src/main/java/io/appwrite/models/Team.kt | 25 +- .../src/main/java/io/appwrite/models/Token.kt | 9 + .../src/main/java/io/appwrite/models/User.kt | 36 +++ .../main/java/io/appwrite/services/Account.kt | 281 +++++++++++++++--- .../main/java/io/appwrite/services/Avatars.kt | 4 +- .../services/{Database.kt => Databases.kt} | 44 +-- .../java/io/appwrite/services/Functions.kt | 6 +- .../main/java/io/appwrite/services/Locale.kt | 4 +- .../main/java/io/appwrite/services/Storage.kt | 8 +- .../main/java/io/appwrite/services/Teams.kt | 8 +- 42 files changed, 910 insertions(+), 153 deletions(-) rename docs/examples/java/account/{create-session.md => create-email-session.md} (97%) create mode 100644 docs/examples/java/account/create-phone-session.md create mode 100644 docs/examples/java/account/create-phone-verification.md create mode 100644 docs/examples/java/account/update-phone-session.md create mode 100644 docs/examples/java/account/update-phone-verification.md create mode 100644 docs/examples/java/account/update-phone.md rename docs/examples/java/{database => databases}/create-document.md (91%) rename docs/examples/java/{database => databases}/delete-document.md (91%) rename docs/examples/java/{database => databases}/get-document.md (91%) rename docs/examples/java/{database => databases}/list-documents.md (91%) rename docs/examples/java/{database => databases}/update-document.md (91%) rename docs/examples/kotlin/account/{create-session.md => create-email-session.md} (93%) create mode 100644 docs/examples/kotlin/account/create-phone-session.md create mode 100644 docs/examples/kotlin/account/create-phone-verification.md create mode 100644 docs/examples/kotlin/account/update-phone-session.md create mode 100644 docs/examples/kotlin/account/update-phone-verification.md create mode 100644 docs/examples/kotlin/account/update-phone.md rename docs/examples/kotlin/{database => databases}/create-document.md (84%) rename docs/examples/kotlin/{database => databases}/delete-document.md (83%) rename docs/examples/kotlin/{database => databases}/get-document.md (83%) rename docs/examples/kotlin/{database => databases}/list-documents.md (82%) rename docs/examples/kotlin/{database => databases}/update-document.md (81%) create mode 100644 library/src/main/java/io/appwrite/models/InputFile.kt rename library/src/main/java/io/appwrite/services/{Database.kt => Databases.kt} (81%) diff --git a/README.md b/README.md index f6ba544..859d5ca 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-0.14.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-0.15.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 0.14.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).** +**This SDK is compatible with Appwrite server version 0.15.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:0.6.1") +implementation("io.appwrite:sdk-for-android:0.7.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 0.6.1 + 0.7.0 ``` diff --git a/docs/examples/java/account/create-session.md b/docs/examples/java/account/create-email-session.md similarity index 97% rename from docs/examples/java/account/create-session.md rename to docs/examples/java/account/create-email-session.md index 34dfca5..055b828 100644 --- a/docs/examples/java/account/create-session.md +++ b/docs/examples/java/account/create-email-session.md @@ -18,7 +18,7 @@ public class MainActivity extends AppCompatActivity { Account account = new Account(client); - account.createSession( + account.createEmailSession( "email@example.com", "password" new Continuation() { diff --git a/docs/examples/java/account/create-phone-session.md b/docs/examples/java/account/create-phone-session.md new file mode 100644 index 0000000..78be922 --- /dev/null +++ b/docs/examples/java/account/create-phone-session.md @@ -0,0 +1,49 @@ +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.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 diff --git a/docs/examples/java/account/create-phone-verification.md b/docs/examples/java/account/create-phone-verification.md new file mode 100644 index 0000000..401b942 --- /dev/null +++ b/docs/examples/java/account/create-phone-verification.md @@ -0,0 +1,46 @@ +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.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()); + } + } + }); + } +} \ No newline at end of file diff --git a/docs/examples/java/account/update-phone-session.md b/docs/examples/java/account/update-phone-session.md new file mode 100644 index 0000000..f8d35c7 --- /dev/null +++ b/docs/examples/java/account/update-phone-session.md @@ -0,0 +1,49 @@ +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.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 diff --git a/docs/examples/java/account/update-phone-verification.md b/docs/examples/java/account/update-phone-verification.md new file mode 100644 index 0000000..7aec064 --- /dev/null +++ b/docs/examples/java/account/update-phone-verification.md @@ -0,0 +1,49 @@ +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.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 diff --git a/docs/examples/java/account/update-phone.md b/docs/examples/java/account/update-phone.md new file mode 100644 index 0000000..37c54c8 --- /dev/null +++ b/docs/examples/java/account/update-phone.md @@ -0,0 +1,49 @@ +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.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 diff --git a/docs/examples/java/database/create-document.md b/docs/examples/java/databases/create-document.md similarity index 91% rename from docs/examples/java/database/create-document.md rename to docs/examples/java/databases/create-document.md index 059a42e..96aea79 100644 --- a/docs/examples/java/database/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases public class MainActivity extends AppCompatActivity { @@ -16,9 +16,9 @@ public class MainActivity extends AppCompatActivity { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID - Database database = new Database(client); + Databases databases = new Databases(client, "[DATABASE_ID]"); - database.createDocument( + databases.createDocument( "[COLLECTION_ID]", "[DOCUMENT_ID]", mapOf( "a" to "b" ), diff --git a/docs/examples/java/database/delete-document.md b/docs/examples/java/databases/delete-document.md similarity index 91% rename from docs/examples/java/database/delete-document.md rename to docs/examples/java/databases/delete-document.md index 75877c4..e749a0a 100644 --- a/docs/examples/java/database/delete-document.md +++ b/docs/examples/java/databases/delete-document.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases public class MainActivity extends AppCompatActivity { @@ -16,9 +16,9 @@ public class MainActivity extends AppCompatActivity { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID - Database database = new Database(client); + Databases databases = new Databases(client, "[DATABASE_ID]"); - database.deleteDocument( + databases.deleteDocument( "[COLLECTION_ID]", "[DOCUMENT_ID]" new Continuation() { diff --git a/docs/examples/java/database/get-document.md b/docs/examples/java/databases/get-document.md similarity index 91% rename from docs/examples/java/database/get-document.md rename to docs/examples/java/databases/get-document.md index 69aff1d..2a7f227 100644 --- a/docs/examples/java/database/get-document.md +++ b/docs/examples/java/databases/get-document.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases public class MainActivity extends AppCompatActivity { @@ -16,9 +16,9 @@ public class MainActivity extends AppCompatActivity { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID - Database database = new Database(client); + Databases databases = new Databases(client, "[DATABASE_ID]"); - database.getDocument( + databases.getDocument( "[COLLECTION_ID]", "[DOCUMENT_ID]" new Continuation() { diff --git a/docs/examples/java/database/list-documents.md b/docs/examples/java/databases/list-documents.md similarity index 91% rename from docs/examples/java/database/list-documents.md rename to docs/examples/java/databases/list-documents.md index 711aa41..5f49d26 100644 --- a/docs/examples/java/database/list-documents.md +++ b/docs/examples/java/databases/list-documents.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases public class MainActivity extends AppCompatActivity { @@ -16,9 +16,9 @@ public class MainActivity extends AppCompatActivity { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID - Database database = new Database(client); + Databases databases = new Databases(client, "[DATABASE_ID]"); - database.listDocuments( + databases.listDocuments( "[COLLECTION_ID]", new Continuation() { @NotNull diff --git a/docs/examples/java/database/update-document.md b/docs/examples/java/databases/update-document.md similarity index 91% rename from docs/examples/java/database/update-document.md rename to docs/examples/java/databases/update-document.md index a14c91f..a9d361d 100644 --- a/docs/examples/java/database/update-document.md +++ b/docs/examples/java/databases/update-document.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases public class MainActivity extends AppCompatActivity { @@ -16,12 +16,11 @@ public class MainActivity extends AppCompatActivity { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID - Database database = new Database(client); + Databases databases = new Databases(client, "[DATABASE_ID]"); - database.updateDocument( + databases.updateDocument( "[COLLECTION_ID]", "[DOCUMENT_ID]", - mapOf( "a" to "b" ), new Continuation() { @NotNull @Override diff --git a/docs/examples/java/storage/create-file.md b/docs/examples/java/storage/create-file.md index 3b7099e..d87cfef 100644 --- a/docs/examples/java/storage/create-file.md +++ b/docs/examples/java/storage/create-file.md @@ -21,7 +21,7 @@ public class MainActivity extends AppCompatActivity { storage.createFile( "[BUCKET_ID]", "[FILE_ID]", - File("file.png"), + InputFile.fromPath("file.png"), new Continuation() { @NotNull @Override diff --git a/docs/examples/kotlin/account/create-session.md b/docs/examples/kotlin/account/create-email-session.md similarity index 93% rename from docs/examples/kotlin/account/create-session.md rename to docs/examples/kotlin/account/create-email-session.md index 4999232..5dcec23 100644 --- a/docs/examples/kotlin/account/create-session.md +++ b/docs/examples/kotlin/account/create-email-session.md @@ -17,7 +17,7 @@ class MainActivity : AppCompatActivity() { val account = Account(client) GlobalScope.launch { - val response = account.createSession( + val response = account.createEmailSession( email = "email@example.com", password = "password" ) diff --git a/docs/examples/kotlin/account/create-phone-session.md b/docs/examples/kotlin/account/create-phone-session.md new file mode 100644 index 0000000..899e3a3 --- /dev/null +++ b/docs/examples/kotlin/account/create-phone-session.md @@ -0,0 +1,27 @@ +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.createPhoneSession( + userId = "[USER_ID]", + number = "" + ) + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-phone-verification.md b/docs/examples/kotlin/account/create-phone-verification.md new file mode 100644 index 0000000..ab0eccf --- /dev/null +++ b/docs/examples/kotlin/account/create-phone-verification.md @@ -0,0 +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 + +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.createPhoneVerification() + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-phone-session.md b/docs/examples/kotlin/account/update-phone-session.md new file mode 100644 index 0000000..c981991 --- /dev/null +++ b/docs/examples/kotlin/account/update-phone-session.md @@ -0,0 +1,27 @@ +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.updatePhoneSession( + userId = "[USER_ID]", + secret = "[SECRET]" + ) + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-phone-verification.md b/docs/examples/kotlin/account/update-phone-verification.md new file mode 100644 index 0000000..aa5eea3 --- /dev/null +++ b/docs/examples/kotlin/account/update-phone-verification.md @@ -0,0 +1,27 @@ +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.updatePhoneVerification( + userId = "[USER_ID]", + secret = "[SECRET]" + ) + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-phone.md b/docs/examples/kotlin/account/update-phone.md new file mode 100644 index 0000000..b200b5b --- /dev/null +++ b/docs/examples/kotlin/account/update-phone.md @@ -0,0 +1,27 @@ +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.updatePhone( + number = "", + password = "password" + ) + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/database/create-document.md b/docs/examples/kotlin/databases/create-document.md similarity index 84% rename from docs/examples/kotlin/database/create-document.md rename to docs/examples/kotlin/databases/create-document.md index d207383..37e20de 100644 --- a/docs/examples/kotlin/database/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -14,10 +14,10 @@ class MainActivity : AppCompatActivity() { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID - val database = Database(client) + val databases = Databases(client, "[DATABASE_ID]") GlobalScope.launch { - val response = database.createDocument( + val response = databases.createDocument( collectionId = "[COLLECTION_ID]", documentId = "[DOCUMENT_ID]", data = mapOf( "a" to "b" ), diff --git a/docs/examples/kotlin/database/delete-document.md b/docs/examples/kotlin/databases/delete-document.md similarity index 83% rename from docs/examples/kotlin/database/delete-document.md rename to docs/examples/kotlin/databases/delete-document.md index 49a85c8..aa5e3ef 100644 --- a/docs/examples/kotlin/database/delete-document.md +++ b/docs/examples/kotlin/databases/delete-document.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -14,10 +14,10 @@ class MainActivity : AppCompatActivity() { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID - val database = Database(client) + val databases = Databases(client, "[DATABASE_ID]") GlobalScope.launch { - val response = database.deleteDocument( + val response = databases.deleteDocument( collectionId = "[COLLECTION_ID]", documentId = "[DOCUMENT_ID]" ) diff --git a/docs/examples/kotlin/database/get-document.md b/docs/examples/kotlin/databases/get-document.md similarity index 83% rename from docs/examples/kotlin/database/get-document.md rename to docs/examples/kotlin/databases/get-document.md index 3dd65c0..9acc860 100644 --- a/docs/examples/kotlin/database/get-document.md +++ b/docs/examples/kotlin/databases/get-document.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -14,10 +14,10 @@ class MainActivity : AppCompatActivity() { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID - val database = Database(client) + val databases = Databases(client, "[DATABASE_ID]") GlobalScope.launch { - val response = database.getDocument( + val response = databases.getDocument( collectionId = "[COLLECTION_ID]", documentId = "[DOCUMENT_ID]" ) diff --git a/docs/examples/kotlin/database/list-documents.md b/docs/examples/kotlin/databases/list-documents.md similarity index 82% rename from docs/examples/kotlin/database/list-documents.md rename to docs/examples/kotlin/databases/list-documents.md index 6511981..48295f4 100644 --- a/docs/examples/kotlin/database/list-documents.md +++ b/docs/examples/kotlin/databases/list-documents.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -14,10 +14,10 @@ class MainActivity : AppCompatActivity() { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID - val database = Database(client) + val databases = Databases(client, "[DATABASE_ID]") GlobalScope.launch { - val response = database.listDocuments( + val response = databases.listDocuments( collectionId = "[COLLECTION_ID]", ) val json = response.body?.string() diff --git a/docs/examples/kotlin/database/update-document.md b/docs/examples/kotlin/databases/update-document.md similarity index 81% rename from docs/examples/kotlin/database/update-document.md rename to docs/examples/kotlin/databases/update-document.md index e19ce4a..6e73fa1 100644 --- a/docs/examples/kotlin/database/update-document.md +++ b/docs/examples/kotlin/databases/update-document.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -14,13 +14,12 @@ class MainActivity : AppCompatActivity() { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID - val database = Database(client) + val databases = Databases(client, "[DATABASE_ID]") GlobalScope.launch { - val response = database.updateDocument( + val response = databases.updateDocument( collectionId = "[COLLECTION_ID]", documentId = "[DOCUMENT_ID]", - data = mapOf( "a" to "b" ), ) val json = response.body?.string() } diff --git a/docs/examples/kotlin/storage/create-file.md b/docs/examples/kotlin/storage/create-file.md index c5cc6a3..cf1727d 100644 --- a/docs/examples/kotlin/storage/create-file.md +++ b/docs/examples/kotlin/storage/create-file.md @@ -20,7 +20,7 @@ class MainActivity : AppCompatActivity() { val response = storage.createFile( bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]", - file = File("file.png"), + file = InputFile.fromPath("file.png"), ) val json = response.body?.string() } diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 4e5e78f..4f8a7e1 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -9,6 +9,7 @@ import io.appwrite.cookies.stores.SharedPreferencesCookieStore import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.fromJson import io.appwrite.json.PreciseNumberAdapter +import io.appwrite.models.InputFile import io.appwrite.models.UploadProgress import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -85,7 +86,7 @@ class Client @JvmOverloads constructor( "origin" to "appwrite-android://${context.packageName}", "user-agent" to "${context.packageName}/${appVersion}, ${System.getProperty("http.agent")}", "x-sdk-version" to "appwrite:android:${BuildConfig.SDK_VERSION}", - "x-appwrite-response-format" to "0.14.0" + "x-appwrite-response-format" to "0.15.0" ) config = mutableMapOf() @@ -342,14 +343,29 @@ class Client @JvmOverloads constructor( idParamName: String? = null, onProgress: ((UploadProgress) -> Unit)? = null, ): T { - val file = params[paramName] as File - val size = file.length() + var file: RandomAccessFile? = null + val input = params[paramName] as InputFile + val size: Long = when(input.sourceType) { + "path", "file" -> { + file = RandomAccessFile(input.path, "r") + file.length() + } + "bytes" -> { + (input.data as ByteArray).size.toLong() + } + else -> throw UnsupportedOperationException() + } if (size < CHUNK_SIZE) { + val data = when(input.sourceType) { + "file", "path" -> File(input.path).asRequestBody() + "bytes" -> (input.data as ByteArray).toRequestBody(input.mimeType.toMediaType()) + else -> throw UnsupportedOperationException() + } params[paramName] = MultipartBody.Part.createFormData( paramName, - file.name, - file.asRequestBody() + input.filename, + data ) return call( method = "POST", @@ -361,7 +377,6 @@ class Client @JvmOverloads constructor( ) } - val input = RandomAccessFile(file, "r") val buffer = ByteArray(CHUNK_SIZE) var offset = 0L var result: Map<*, *>? = null @@ -380,12 +395,29 @@ class Client @JvmOverloads constructor( } while (offset < size) { - input.seek(offset) - input.read(buffer) + when(input.sourceType) { + "file", "path" -> { + file!!.seek(offset) + file!!.read(buffer) + } + "bytes" -> { + val end = if (offset + CHUNK_SIZE < size) { + offset + CHUNK_SIZE + } else { + size - 1 + } + (input.data as ByteArray).copyInto( + buffer, + startIndex = offset.toInt(), + endIndex = end.toInt() + ) + } + else -> throw UnsupportedOperationException() + } params[paramName] = MultipartBody.Part.createFormData( paramName, - file.name, + input.filename, buffer.toRequestBody() ) diff --git a/library/src/main/java/io/appwrite/models/Document.kt b/library/src/main/java/io/appwrite/models/Document.kt index a83a844..a14d60b 100644 --- a/library/src/main/java/io/appwrite/models/Document.kt +++ b/library/src/main/java/io/appwrite/models/Document.kt @@ -20,6 +20,20 @@ data class Document( @SerializedName("\$collection") val collection: String, + /** + * Document creation date in Unix timestamp. + * + */ + @SerializedName("\$createdAt") + val createdAt: Long, + + /** + * Document update date in Unix timestamp. + * + */ + @SerializedName("\$updatedAt") + val updatedAt: Long, + /** * Document read permissions. * @@ -41,6 +55,8 @@ data class Document( fun from(map: Map) = Document( id = map["\$id"] as String, collection = map["\$collection"] as String, + createdAt = (map["\$createdAt"] as Number).toLong(), + updatedAt = (map["\$updatedAt"] as Number).toLong(), read = map["\$read"] as List, write = map["\$write"] as List, data = map @@ -50,6 +66,8 @@ data class Document( fun toMap(): Map = mapOf( "\$id" to id as Any, "\$collection" to collection as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, "\$read" to read as Any, "\$write" to write as Any, "data" to data diff --git a/library/src/main/java/io/appwrite/models/Execution.kt b/library/src/main/java/io/appwrite/models/Execution.kt index 06c2811..e036efd 100644 --- a/library/src/main/java/io/appwrite/models/Execution.kt +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -13,6 +13,20 @@ data class Execution( @SerializedName("\$id") val id: String, + /** + * Execution creation date in Unix timestamp. + * + */ + @SerializedName("\$createdAt") + val createdAt: Long, + + /** + * Execution update date in Unix timestamp. + * + */ + @SerializedName("\$updatedAt") + val updatedAt: Long, + /** * Execution read permissions. * @@ -27,13 +41,6 @@ data class Execution( @SerializedName("functionId") val functionId: String, - /** - * The execution creation date in Unix timestamp. - * - */ - @SerializedName("dateCreated") - val dateCreated: Long, - /** * The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. * @@ -80,9 +87,10 @@ data class Execution( @Suppress("UNCHECKED_CAST") fun from(map: Map) = Execution( id = map["\$id"] as String, + createdAt = (map["\$createdAt"] as Number).toLong(), + updatedAt = (map["\$updatedAt"] as Number).toLong(), read = map["\$read"] as List, functionId = map["functionId"] as String, - dateCreated = (map["dateCreated"] as Number).toLong(), trigger = map["trigger"] as String, status = map["status"] as String, statusCode = (map["statusCode"] as Number).toLong(), @@ -94,9 +102,10 @@ data class Execution( fun toMap(): Map = mapOf( "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, "\$read" to read as Any, "functionId" to functionId as Any, - "dateCreated" to dateCreated as Any, "trigger" to trigger as Any, "status" to status as Any, "statusCode" to statusCode as Any, diff --git a/library/src/main/java/io/appwrite/models/File.kt b/library/src/main/java/io/appwrite/models/File.kt index 2faa1e4..d4e6af0 100644 --- a/library/src/main/java/io/appwrite/models/File.kt +++ b/library/src/main/java/io/appwrite/models/File.kt @@ -20,6 +20,20 @@ data class File( @SerializedName("bucketId") val bucketId: String, + /** + * File creation date in Unix timestamp. + * + */ + @SerializedName("\$createdAt") + val createdAt: Long, + + /** + * File update date in Unix timestamp. + * + */ + @SerializedName("\$updatedAt") + val updatedAt: Long, + /** * File read permissions. * @@ -41,13 +55,6 @@ data class File( @SerializedName("name") val name: String, - /** - * File creation date in Unix timestamp. - * - */ - @SerializedName("dateCreated") - val dateCreated: Long, - /** * File MD5 signature. * @@ -88,10 +95,11 @@ data class File( fun from(map: Map) = File( id = map["\$id"] as String, bucketId = map["bucketId"] as String, + createdAt = (map["\$createdAt"] as Number).toLong(), + updatedAt = (map["\$updatedAt"] as Number).toLong(), read = map["\$read"] as List, write = map["\$write"] as List, name = map["name"] as String, - dateCreated = (map["dateCreated"] as Number).toLong(), signature = map["signature"] as String, mimeType = map["mimeType"] as String, sizeOriginal = (map["sizeOriginal"] as Number).toLong(), @@ -103,10 +111,11 @@ data class File( fun toMap(): Map = mapOf( "\$id" to id as Any, "bucketId" to bucketId as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, "\$read" to read as Any, "\$write" to write as Any, "name" to name as Any, - "dateCreated" to dateCreated as Any, "signature" to signature as Any, "mimeType" to mimeType as Any, "sizeOriginal" to sizeOriginal as Any, diff --git a/library/src/main/java/io/appwrite/models/InputFile.kt b/library/src/main/java/io/appwrite/models/InputFile.kt new file mode 100644 index 0000000..afbb2e9 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/InputFile.kt @@ -0,0 +1,37 @@ +package io.appwrite.models + +import java.io.File +import java.net.URLConnection +import java.nio.file.Files +import java.nio.file.Paths + +class InputFile private constructor() { + + lateinit var path: String + lateinit var filename: String + lateinit var mimeType: String + lateinit var sourceType: String + lateinit var data: Any + + companion object { + fun fromFile(file: File) = InputFile().apply { + path = file.canonicalPath + filename = file.name + mimeType = Files.probeContentType(Paths.get(file.canonicalPath)) + ?: URLConnection.guessContentTypeFromName(filename) + ?: "" + sourceType = "file" + } + + fun fromPath(path: String): InputFile = fromFile(File(path)).apply { + sourceType = "path" + } + + fun fromBytes(bytes: ByteArray, filename: String = "", mimeType: String = "") = InputFile().apply { + this.filename = filename + this.mimeType = mimeType + data = bytes + sourceType = "bytes" + } + } +} \ 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 3df7b69..0cf224e 100644 --- a/library/src/main/java/io/appwrite/models/Membership.kt +++ b/library/src/main/java/io/appwrite/models/Membership.kt @@ -13,6 +13,20 @@ data class Membership( @SerializedName("\$id") val id: String, + /** + * Membership creation date in Unix timestamp. + * + */ + @SerializedName("\$createdAt") + val createdAt: Long, + + /** + * Membership update date in Unix timestamp. + * + */ + @SerializedName("\$updatedAt") + val updatedAt: Long, + /** * User ID. * @@ -80,6 +94,8 @@ data class Membership( @Suppress("UNCHECKED_CAST") fun from(map: Map) = Membership( id = map["\$id"] as String, + createdAt = (map["\$createdAt"] as Number).toLong(), + updatedAt = (map["\$updatedAt"] as Number).toLong(), userId = map["userId"] as String, userName = map["userName"] as String, userEmail = map["userEmail"] as String, @@ -94,6 +110,8 @@ data class Membership( 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, diff --git a/library/src/main/java/io/appwrite/models/Session.kt b/library/src/main/java/io/appwrite/models/Session.kt index 1abd909..27a2195 100644 --- a/library/src/main/java/io/appwrite/models/Session.kt +++ b/library/src/main/java/io/appwrite/models/Session.kt @@ -13,6 +13,13 @@ data class Session( @SerializedName("\$id") val id: String, + /** + * Session creation date in Unix timestamp. + * + */ + @SerializedName("\$createdAt") + val createdAt: Long, + /** * User ID. * @@ -178,6 +185,7 @@ data class Session( @Suppress("UNCHECKED_CAST") fun from(map: Map) = Session( id = map["\$id"] as String, + createdAt = (map["\$createdAt"] as Number).toLong(), userId = map["userId"] as String, expire = (map["expire"] as Number).toLong(), provider = map["provider"] as String, @@ -206,6 +214,7 @@ data class Session( 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, diff --git a/library/src/main/java/io/appwrite/models/Team.kt b/library/src/main/java/io/appwrite/models/Team.kt index f502375..4a5dbcd 100644 --- a/library/src/main/java/io/appwrite/models/Team.kt +++ b/library/src/main/java/io/appwrite/models/Team.kt @@ -14,18 +14,25 @@ data class Team( val id: String, /** - * Team name. + * Team creation date in Unix timestamp. * */ - @SerializedName("name") - val name: String, + @SerializedName("\$createdAt") + val createdAt: Long, /** - * Team creation date in Unix timestamp. + * Team update date in Unix timestamp. + * + */ + @SerializedName("\$updatedAt") + val updatedAt: Long, + + /** + * Team name. * */ - @SerializedName("dateCreated") - val dateCreated: Long, + @SerializedName("name") + val name: String, /** * Total number of team members. @@ -38,16 +45,18 @@ data class Team( @Suppress("UNCHECKED_CAST") fun from(map: Map) = Team( id = map["\$id"] as String, + createdAt = (map["\$createdAt"] as Number).toLong(), + updatedAt = (map["\$updatedAt"] as Number).toLong(), name = map["name"] as String, - dateCreated = (map["dateCreated"] 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, - "dateCreated" to dateCreated as Any, "total" to total 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 d555f45..8cbd1f4 100644 --- a/library/src/main/java/io/appwrite/models/Token.kt +++ b/library/src/main/java/io/appwrite/models/Token.kt @@ -13,6 +13,13 @@ data class Token( @SerializedName("\$id") val id: String, + /** + * Token creation date in Unix timestamp. + * + */ + @SerializedName("\$createdAt") + val createdAt: Long, + /** * User ID. * @@ -38,6 +45,7 @@ data class Token( @Suppress("UNCHECKED_CAST") fun from(map: Map) = Token( id = map["\$id"] as String, + createdAt = (map["\$createdAt"] as Number).toLong(), userId = map["userId"] as String, secret = map["secret"] as String, expire = (map["expire"] as Number).toLong() @@ -46,6 +54,7 @@ data class Token( 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 diff --git a/library/src/main/java/io/appwrite/models/User.kt b/library/src/main/java/io/appwrite/models/User.kt index 032391e..4696e67 100644 --- a/library/src/main/java/io/appwrite/models/User.kt +++ b/library/src/main/java/io/appwrite/models/User.kt @@ -13,6 +13,20 @@ data class User( @SerializedName("\$id") val id: String, + /** + * User creation date in Unix timestamp. + * + */ + @SerializedName("\$createdAt") + val createdAt: Long, + + /** + * User update date in Unix timestamp. + * + */ + @SerializedName("\$updatedAt") + val updatedAt: Long, + /** * User name. * @@ -48,6 +62,13 @@ data class User( @SerializedName("email") val email: String, + /** + * User phone number in E.164 format. + * + */ + @SerializedName("phone") + val phone: String, + /** * Email verification status. * @@ -55,6 +76,13 @@ data class User( @SerializedName("emailVerification") val emailVerification: Boolean, + /** + * Phone verification status. + * + */ + @SerializedName("phoneVerification") + val phoneVerification: Boolean, + /** * User preferences as a key-value object * @@ -66,24 +94,32 @@ data class User( @Suppress("UNCHECKED_CAST") fun from(map: Map) = User( id = map["\$id"] as String, + createdAt = (map["\$createdAt"] as Number).toLong(), + updatedAt = (map["\$updatedAt"] as Number).toLong(), name = map["name"] as String, registration = (map["registration"] as Number).toLong(), status = map["status"] as Boolean, passwordUpdate = (map["passwordUpdate"] as Number).toLong(), email = map["email"] as String, + phone = map["phone"] as String, emailVerification = map["emailVerification"] as Boolean, + phoneVerification = map["phoneVerification"] as Boolean, prefs = Preferences.from(map = map["prefs"] as Map) ) } 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/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 8f144de..4b75dcc 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -12,7 +12,9 @@ import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import java.io.File -class Account(client: Client) : Service(client) { +class Account : Service { + + public constructor (client: Client) : super(client) { } /** * Get Account @@ -274,6 +276,45 @@ class Account(client: Client) : Service(client) { ) } + /** + * Update Account Phone + * + * Update currently logged in user account phone number. After changing phone + * number, the user confirmation status will get reset. A new confirmation SMS + * is not sent automatically however you can use the phone confirmation + * endpoint again to send the confirmation SMS. + * + * @param number 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.User] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updatePhone( + number: String, + password: String + ): io.appwrite.models.User { + val path = "/account/phone" + val params = mutableMapOf( + "number" to number, + "password" to password + ) + val headers = mutableMapOf( + "content-type" to "application/json" + ) + val converter: (Map) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.User::class.java, + converter, + ) + } + /** * Get Account Preferences * @@ -462,85 +503,85 @@ class Account(client: Client) : Service(client) { } /** - * Create Account Session + * Delete All Account Sessions * - * 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. + * Delete all sessions from the user account and remove any sessions cookies + * from the end client. * - * @param email User email. - * @param password User password. Must be at least 8 chars. - * @return [io.appwrite.models.Session] + * @return [Any] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun createSession( - email: String, - password: String - ): io.appwrite.models.Session { + suspend fun deleteSessions(): Any { val path = "/account/sessions" val params = mutableMapOf( - "email" to email, - "password" to password ) val headers = mutableMapOf( "content-type" to "application/json" ) - val converter: (Map) -> io.appwrite.models.Session = { - io.appwrite.models.Session.from(map = it) - } return client.call( - "POST", + "DELETE", path, headers, params, - responseType = io.appwrite.models.Session::class.java, - converter, + responseType = Any::class.java, ) } /** - * Delete All Account Sessions + * Create Anonymous Session * - * Delete all sessions from the user account and remove any sessions cookies - * from the end client. + * 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 [Any] + * @return [io.appwrite.models.Session] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun deleteSessions(): Any { - val path = "/account/sessions" + suspend fun createAnonymousSession(): io.appwrite.models.Session { + val path = "/account/sessions/anonymous" val params = mutableMapOf( ) val headers = mutableMapOf( "content-type" to "application/json" ) + val converter: (Map) -> io.appwrite.models.Session = { + io.appwrite.models.Session.from(map = it) + } return client.call( - "DELETE", + "POST", path, headers, params, - responseType = Any::class.java, + responseType = io.appwrite.models.Session::class.java, + converter, ) } /** - * Create Anonymous Session + * Create Account Session with Email * - * 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). + * 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. * + * @param email User email. + * @param password User password. Must be at least 8 chars. * @return [io.appwrite.models.Session] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun createAnonymousSession(): io.appwrite.models.Session { - val path = "/account/sessions/anonymous" + suspend fun createEmailSession( + email: String, + password: String + ): io.appwrite.models.Session { + val path = "/account/sessions/email" val params = mutableMapOf( + "email" to email, + "password" to password ) val headers = mutableMapOf( "content-type" to "application/json" @@ -668,10 +709,10 @@ class Account(client: Client) : Service(client) { * user.. * * - * @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, bitbucket, bitly, box, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, notion, okta, paypal, paypalSandbox, salesforce, slack, spotify, tradeshift, tradeshiftBox, twitch, zoom, yahoo, yammer, yandex, wordpress, stripe. + * @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, bitbucket, bitly, box, dailymotion, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, notion, okta, paypal, paypalSandbox, 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 128 characters long. + * @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 @@ -734,6 +775,92 @@ class Account(client: Client) : Service(client) { } } + /** + * Create Phone session + * + * Sends the user a SMS with a secret key for creating a session. Use the + * returned user ID and the secret to 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. + * + * @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 number Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @return [io.appwrite.models.Token] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createPhoneSession( + userId: String, + number: String + ): io.appwrite.models.Token { + val path = "/account/sessions/phone" + val params = mutableMapOf( + "userId" to userId, + "number" to number + ) + val headers = mutableMapOf( + "content-type" to "application/json" + ) + val converter: (Map) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Token::class.java, + converter, + ) + } + + /** + * Create Phone 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. + * + * @param userId User ID. + * @param secret Valid verification token. + * @return [io.appwrite.models.Session] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updatePhoneSession( + userId: String, + secret: String + ): io.appwrite.models.Session { + val path = "/account/sessions/phone" + val params = mutableMapOf( + "userId" to userId, + "secret" to secret + ) + val headers = mutableMapOf( + "content-type" to "application/json" + ) + val converter: (Map) -> io.appwrite.models.Session = { + io.appwrite.models.Session.from(map = it) + } + return client.call( + "PUT", + path, + headers, + params, + responseType = io.appwrite.models.Session::class.java, + converter, + ) + } + /** * Get Session By ID * @@ -873,8 +1000,8 @@ class Account(client: Client) : Service(client) { * 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#accountUpdateVerification). The verification - * link sent to the user's email address is valid for 7 days. + * 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), @@ -949,4 +1076,78 @@ class Account(client: Client) : Service(client) { ) } + /** + * Create Phone Verification + * + * Use this endpoint to send a verification message to your user's phone + * number to confirm they are the valid owners of that address. The provided + * secret should 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#accountUpdatePhoneVerification). The + * verification link sent to the user's phone number is valid for 15 minutes. + * + * @return [io.appwrite.models.Token] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createPhoneVerification(): io.appwrite.models.Token { + val path = "/account/verification/phone" + val params = mutableMapOf( + ) + val headers = mutableMapOf( + "content-type" to "application/json" + ) + val converter: (Map) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Token::class.java, + 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. + * + * @param userId User ID. + * @param secret Valid verification token. + * @return [io.appwrite.models.Token] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updatePhoneVerification( + userId: String, + secret: String + ): io.appwrite.models.Token { + val path = "/account/verification/phone" + val params = mutableMapOf( + "userId" to userId, + "secret" to secret + ) + val headers = mutableMapOf( + "content-type" to "application/json" + ) + val converter: (Map) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it) + } + return client.call( + "PUT", + path, + headers, + params, + responseType = io.appwrite.models.Token::class.java, + 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 20e1f54..dc67c3b 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -10,7 +10,9 @@ import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import java.io.File -class Avatars(client: Client) : Service(client) { +class Avatars : Service { + + public constructor (client: Client) : super(client) { } /** * Get Browser Icon diff --git a/library/src/main/java/io/appwrite/services/Database.kt b/library/src/main/java/io/appwrite/services/Databases.kt similarity index 81% rename from library/src/main/java/io/appwrite/services/Database.kt rename to library/src/main/java/io/appwrite/services/Databases.kt index 74bced3..a85150c 100644 --- a/library/src/main/java/io/appwrite/services/Database.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -8,23 +8,24 @@ import okhttp3.Cookie import okhttp3.Response import java.io.File -class Database(client: Client) : Service(client) { +class Databases : Service { + + val databaseId: String + + public constructor(client: Client, databaseId: String) : super(client) { + this.databaseId = databaseId + } /** * List Documents * - * Get a list of all the user documents. 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 documents. [Learn more about different API - * modes](/docs/admin). - * * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/database#querying-documents). Maximum of 100 queries are allowed, each 128 characters long. + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/database#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. * @param limit Maximum number of documents to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. * @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) * @param cursor ID of the document used as the starting point for the query, excluding the document itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursorDirection Direction of the cursor. - * @param orderAttributes Array of attributes used to sort results. Maximum of 100 order attributes are allowed, each 128 characters long. + * @param cursorDirection Direction of the cursor, can be either 'before' or 'after'. + * @param orderAttributes Array of attributes used to sort results. Maximum of 100 order attributes are allowed, each 4096 characters long. * @param orderTypes Array of order directions for sorting attribtues. Possible values are DESC for descending order, or ASC for ascending order. Maximum of 100 order types are allowed. * @return [io.appwrite.models.DocumentList] */ @@ -40,7 +41,7 @@ class Database(client: Client) : Service(client) { orderAttributes: List? = null, orderTypes: List? = null ): io.appwrite.models.DocumentList { - val path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId) + val path = "/databases/{databaseId}/collections/{collectionId}/documents".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId) val params = mutableMapOf( "queries" to queries, "limit" to limit, @@ -69,11 +70,6 @@ class Database(client: Client) : Service(client) { /** * Create Document * - * Create a new Document. Before using this route, you should create a new - * collection resource using either a [server - * integration](/docs/server/database#databaseCreateCollection) API or - * directly from your database console. - * * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). 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 data Document data as JSON object. @@ -90,7 +86,7 @@ class Database(client: Client) : Service(client) { read: List? = null, write: List? = null ): io.appwrite.models.Document { - val path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId) + val path = "/databases/{databaseId}/collections/{collectionId}/documents".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId) val params = mutableMapOf( "documentId" to documentId, "data" to data, @@ -116,9 +112,6 @@ class Database(client: Client) : Service(client) { /** * Get Document * - * Get a document by its unique ID. This endpoint response returns a JSON - * object with the document data. - * * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). * @param documentId Document ID. * @return [io.appwrite.models.Document] @@ -129,7 +122,7 @@ class Database(client: Client) : Service(client) { collectionId: String, documentId: String ): io.appwrite.models.Document { - val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId) + val path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId).replace("{documentId}", documentId) val params = mutableMapOf( ) val headers = mutableMapOf( @@ -151,9 +144,6 @@ class Database(client: Client) : Service(client) { /** * Update Document * - * Update a document by its unique ID. Using the patch method you can pass - * only specific fields that will get updated. - * * @param collectionId Collection ID. * @param documentId Document ID. * @param data Document data as JSON object. Include only attribute and value pairs to be updated. @@ -166,11 +156,11 @@ class Database(client: Client) : Service(client) { suspend fun updateDocument( collectionId: String, documentId: String, - data: Any, + data: Any? = null, read: List? = null, write: List? = null ): io.appwrite.models.Document { - val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId) + val path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId).replace("{documentId}", documentId) val params = mutableMapOf( "data" to data, "read" to read, @@ -195,8 +185,6 @@ class Database(client: Client) : Service(client) { /** * Delete Document * - * Delete a document by its unique ID. - * * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). * @param documentId Document ID. * @return [Any] @@ -207,7 +195,7 @@ class Database(client: Client) : Service(client) { collectionId: String, documentId: String ): Any { - val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId) + val path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId).replace("{documentId}", documentId) val params = mutableMapOf( ) val headers = mutableMapOf( diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index 85a1f2c..fc09098 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -8,7 +8,9 @@ import okhttp3.Cookie import okhttp3.Response import java.io.File -class Functions(client: Client) : Service(client) { +class Functions : Service { + + public constructor (client: Client) : super(client) { } /** * Retry Build @@ -53,7 +55,7 @@ class Functions(client: Client) : Service(client) { * @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) * @param search Search term to filter your list results. Max length: 256 chars. * @param cursor ID of the execution used as the starting point for the query, excluding the execution itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursorDirection Direction of the cursor. + * @param cursorDirection Direction of the cursor, can be either 'before' or 'after'. * @return [io.appwrite.models.ExecutionList] */ @JvmOverloads diff --git a/library/src/main/java/io/appwrite/services/Locale.kt b/library/src/main/java/io/appwrite/services/Locale.kt index 21b297c..b4ff685 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -8,7 +8,9 @@ import okhttp3.Cookie import okhttp3.Response import java.io.File -class Locale(client: Client) : Service(client) { +class Locale : Service { + + public constructor (client: Client) : super(client) { } /** * Get User Locale diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index c1e0abc..f147dce 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -10,7 +10,9 @@ import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import java.io.File -class Storage(client: Client) : Service(client) { +class Storage : Service { + + public constructor (client: Client) : super(client) { } /** * List Files @@ -24,7 +26,7 @@ class Storage(client: Client) : Service(client) { * @param limit Maximum number of files to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. * @param offset Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) * @param cursor ID of the file used as the starting point for the query, excluding the file itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursorDirection Direction of the cursor. + * @param cursorDirection Direction of the cursor, can be either 'before' or 'after'. * @param orderType Order result by ASC or DESC order. * @return [io.appwrite.models.FileList] */ @@ -98,7 +100,7 @@ class Storage(client: Client) : Service(client) { suspend fun createFile( bucketId: String, fileId: String, - file: File, + file: InputFile, read: List? = null, write: List? = null, onProgress: ((UploadProgress) -> Unit)? = null ): io.appwrite.models.File { diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 5b74d1d..c25380d 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -8,7 +8,9 @@ import okhttp3.Cookie import okhttp3.Response import java.io.File -class Teams(client: Client) : Service(client) { +class Teams : Service { + + public constructor (client: Client) : super(client) { } /** * List Teams @@ -23,7 +25,7 @@ class Teams(client: Client) : Service(client) { * @param limit Maximum number of teams to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. * @param offset Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) * @param cursor ID of the team used as the starting point for the query, excluding the team itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursorDirection Direction of the cursor. + * @param cursorDirection Direction of the cursor, can be either 'before' or 'after'. * @param orderType Order result by ASC or DESC order. * @return [io.appwrite.models.TeamList] */ @@ -211,7 +213,7 @@ class Teams(client: Client) : Service(client) { * @param limit Maximum number of memberships to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. * @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) * @param cursor ID of the membership used as the starting point for the query, excluding the membership itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursorDirection Direction of the cursor. + * @param cursorDirection Direction of the cursor, can be either 'before' or 'after'. * @param orderType Order result by ASC or DESC order. * @return [io.appwrite.models.MembershipList] */ From 525ac526bec5b55769daef7cd534d78eb0bbe600 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Mon, 5 Sep 2022 01:01:25 +0400 Subject: [PATCH 038/118] feat: update for 0.16.x --- .github/workflows/publish.yml | 2 +- LICENSE.md | 2 +- README.md | 8 +- ...ate-session.md => create-email-session.md} | 2 +- .../java/account/create-phone-session.md | 49 +++ .../java/account/create-phone-verification.md | 46 +++ .../java/account/update-phone-session.md | 49 +++ .../java/account/update-phone-verification.md | 49 +++ docs/examples/java/account/update-phone.md | 49 +++ .../create-document.md | 7 +- .../delete-document.md | 7 +- .../{database => databases}/get-document.md | 7 +- .../{database => databases}/list-documents.md | 7 +- .../update-document.md | 8 +- docs/examples/java/storage/create-file.md | 3 +- ...ate-session.md => create-email-session.md} | 2 +- .../kotlin/account/create-phone-session.md | 27 ++ .../account/create-phone-verification.md | 24 ++ .../kotlin/account/update-phone-session.md | 27 ++ .../account/update-phone-verification.md | 27 ++ docs/examples/kotlin/account/update-phone.md | 27 ++ .../create-document.md | 7 +- .../delete-document.md | 7 +- .../{database => databases}/get-document.md | 7 +- .../{database => databases}/list-documents.md | 7 +- .../update-document.md | 8 +- docs/examples/kotlin/storage/create-file.md | 3 +- library/src/main/java/io/appwrite/Client.kt | 57 ++- library/src/main/java/io/appwrite/ID.kt | 10 + .../src/main/java/io/appwrite/Permission.kt | 21 + library/src/main/java/io/appwrite/Query.kt | 26 +- library/src/main/java/io/appwrite/Role.kt | 22 ++ .../appwrite/models/{User.kt => Account.kt} | 54 ++- .../main/java/io/appwrite/models/Document.kt | 29 +- .../main/java/io/appwrite/models/Execution.kt | 46 ++- .../src/main/java/io/appwrite/models/File.kt | 36 +- .../main/java/io/appwrite/models/InputFile.kt | 37 ++ .../src/main/java/io/appwrite/models/Log.kt | 6 +- .../java/io/appwrite/models/Membership.kt | 30 +- .../main/java/io/appwrite/models/Session.kt | 21 +- .../src/main/java/io/appwrite/models/Team.kt | 25 +- .../src/main/java/io/appwrite/models/Token.kt | 15 +- .../main/java/io/appwrite/services/Account.kt | 364 ++++++++++++++---- .../main/java/io/appwrite/services/Avatars.kt | 7 +- .../services/{Database.kt => Databases.kt} | 86 ++--- .../java/io/appwrite/services/Functions.kt | 23 +- .../main/java/io/appwrite/services/Locale.kt | 4 +- .../main/java/io/appwrite/services/Storage.kt | 50 +-- .../main/java/io/appwrite/services/Teams.kt | 54 +-- 49 files changed, 1131 insertions(+), 360 deletions(-) rename docs/examples/java/account/{create-session.md => create-email-session.md} (97%) create mode 100644 docs/examples/java/account/create-phone-session.md create mode 100644 docs/examples/java/account/create-phone-verification.md create mode 100644 docs/examples/java/account/update-phone-session.md create mode 100644 docs/examples/java/account/update-phone-verification.md create mode 100644 docs/examples/java/account/update-phone.md rename docs/examples/java/{database => databases}/create-document.md (91%) rename docs/examples/java/{database => databases}/delete-document.md (91%) rename docs/examples/java/{database => databases}/get-document.md (91%) rename docs/examples/java/{database => databases}/list-documents.md (90%) rename docs/examples/java/{database => databases}/update-document.md (91%) rename docs/examples/kotlin/account/{create-session.md => create-email-session.md} (93%) create mode 100644 docs/examples/kotlin/account/create-phone-session.md create mode 100644 docs/examples/kotlin/account/create-phone-verification.md create mode 100644 docs/examples/kotlin/account/update-phone-session.md create mode 100644 docs/examples/kotlin/account/update-phone-verification.md create mode 100644 docs/examples/kotlin/account/update-phone.md rename docs/examples/kotlin/{database => databases}/create-document.md (81%) rename docs/examples/kotlin/{database => databases}/delete-document.md (80%) rename docs/examples/kotlin/{database => databases}/get-document.md (81%) rename docs/examples/kotlin/{database => databases}/list-documents.md (80%) rename docs/examples/kotlin/{database => databases}/update-document.md (80%) create mode 100644 library/src/main/java/io/appwrite/ID.kt create mode 100644 library/src/main/java/io/appwrite/Permission.kt create mode 100644 library/src/main/java/io/appwrite/Role.kt rename library/src/main/java/io/appwrite/models/{User.kt => Account.kt} (57%) create mode 100644 library/src/main/java/io/appwrite/models/InputFile.kt rename library/src/main/java/io/appwrite/services/{Database.kt => Databases.kt} (58%) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c5be330..ae9090b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -51,4 +51,4 @@ jobs: SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }} SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} - SDK_VERSION: ${{ github.event.release.tag_name }} \ No newline at end of file + SDK_VERSION: ${{ github.event.release.tag_name }} diff --git a/LICENSE.md b/LICENSE.md index 96201c4..b0761cc 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -9,4 +9,4 @@ Redistribution and use in source and binary forms, with or without modification, 3. Neither the name Appwrite nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +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 f6ba544..2aa502b 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-0.14.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.0.0-RC1-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 0.14.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.0.0-RC1. 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:0.6.1") +implementation("io.appwrite:sdk-for-android:0.8.0-SNAPSHOT") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 0.6.1 + 0.8.0-SNAPSHOT ``` diff --git a/docs/examples/java/account/create-session.md b/docs/examples/java/account/create-email-session.md similarity index 97% rename from docs/examples/java/account/create-session.md rename to docs/examples/java/account/create-email-session.md index 34dfca5..055b828 100644 --- a/docs/examples/java/account/create-session.md +++ b/docs/examples/java/account/create-email-session.md @@ -18,7 +18,7 @@ public class MainActivity extends AppCompatActivity { Account account = new Account(client); - account.createSession( + account.createEmailSession( "email@example.com", "password" new Continuation() { diff --git a/docs/examples/java/account/create-phone-session.md b/docs/examples/java/account/create-phone-session.md new file mode 100644 index 0000000..78be922 --- /dev/null +++ b/docs/examples/java/account/create-phone-session.md @@ -0,0 +1,49 @@ +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.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 diff --git a/docs/examples/java/account/create-phone-verification.md b/docs/examples/java/account/create-phone-verification.md new file mode 100644 index 0000000..401b942 --- /dev/null +++ b/docs/examples/java/account/create-phone-verification.md @@ -0,0 +1,46 @@ +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.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()); + } + } + }); + } +} \ No newline at end of file diff --git a/docs/examples/java/account/update-phone-session.md b/docs/examples/java/account/update-phone-session.md new file mode 100644 index 0000000..f8d35c7 --- /dev/null +++ b/docs/examples/java/account/update-phone-session.md @@ -0,0 +1,49 @@ +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.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 diff --git a/docs/examples/java/account/update-phone-verification.md b/docs/examples/java/account/update-phone-verification.md new file mode 100644 index 0000000..7aec064 --- /dev/null +++ b/docs/examples/java/account/update-phone-verification.md @@ -0,0 +1,49 @@ +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.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 diff --git a/docs/examples/java/account/update-phone.md b/docs/examples/java/account/update-phone.md new file mode 100644 index 0000000..37c54c8 --- /dev/null +++ b/docs/examples/java/account/update-phone.md @@ -0,0 +1,49 @@ +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.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 diff --git a/docs/examples/java/database/create-document.md b/docs/examples/java/databases/create-document.md similarity index 91% rename from docs/examples/java/database/create-document.md rename to docs/examples/java/databases/create-document.md index 059a42e..7fc322b 100644 --- a/docs/examples/java/database/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases public class MainActivity extends AppCompatActivity { @@ -16,9 +16,10 @@ public class MainActivity extends AppCompatActivity { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID - Database database = new Database(client); + Databases databases = new Databases(client); - database.createDocument( + databases.createDocument( + "[DATABASE_ID]", "[COLLECTION_ID]", "[DOCUMENT_ID]", mapOf( "a" to "b" ), diff --git a/docs/examples/java/database/delete-document.md b/docs/examples/java/databases/delete-document.md similarity index 91% rename from docs/examples/java/database/delete-document.md rename to docs/examples/java/databases/delete-document.md index 75877c4..f42a09b 100644 --- a/docs/examples/java/database/delete-document.md +++ b/docs/examples/java/databases/delete-document.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases public class MainActivity extends AppCompatActivity { @@ -16,9 +16,10 @@ public class MainActivity extends AppCompatActivity { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID - Database database = new Database(client); + Databases databases = new Databases(client); - database.deleteDocument( + databases.deleteDocument( + "[DATABASE_ID]", "[COLLECTION_ID]", "[DOCUMENT_ID]" new Continuation() { diff --git a/docs/examples/java/database/get-document.md b/docs/examples/java/databases/get-document.md similarity index 91% rename from docs/examples/java/database/get-document.md rename to docs/examples/java/databases/get-document.md index 69aff1d..f1a4d44 100644 --- a/docs/examples/java/database/get-document.md +++ b/docs/examples/java/databases/get-document.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases public class MainActivity extends AppCompatActivity { @@ -16,9 +16,10 @@ public class MainActivity extends AppCompatActivity { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID - Database database = new Database(client); + Databases databases = new Databases(client); - database.getDocument( + databases.getDocument( + "[DATABASE_ID]", "[COLLECTION_ID]", "[DOCUMENT_ID]" new Continuation() { diff --git a/docs/examples/java/database/list-documents.md b/docs/examples/java/databases/list-documents.md similarity index 90% rename from docs/examples/java/database/list-documents.md rename to docs/examples/java/databases/list-documents.md index 711aa41..93d7333 100644 --- a/docs/examples/java/database/list-documents.md +++ b/docs/examples/java/databases/list-documents.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases public class MainActivity extends AppCompatActivity { @@ -16,9 +16,10 @@ public class MainActivity extends AppCompatActivity { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID - Database database = new Database(client); + Databases databases = new Databases(client); - database.listDocuments( + databases.listDocuments( + "[DATABASE_ID]", "[COLLECTION_ID]", new Continuation() { @NotNull diff --git a/docs/examples/java/database/update-document.md b/docs/examples/java/databases/update-document.md similarity index 91% rename from docs/examples/java/database/update-document.md rename to docs/examples/java/databases/update-document.md index a14c91f..81e55d4 100644 --- a/docs/examples/java/database/update-document.md +++ b/docs/examples/java/databases/update-document.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases public class MainActivity extends AppCompatActivity { @@ -16,12 +16,12 @@ public class MainActivity extends AppCompatActivity { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID - Database database = new Database(client); + Databases databases = new Databases(client); - database.updateDocument( + databases.updateDocument( + "[DATABASE_ID]", "[COLLECTION_ID]", "[DOCUMENT_ID]", - mapOf( "a" to "b" ), new Continuation() { @NotNull @Override diff --git a/docs/examples/java/storage/create-file.md b/docs/examples/java/storage/create-file.md index 3b7099e..32e0fd0 100644 --- a/docs/examples/java/storage/create-file.md +++ b/docs/examples/java/storage/create-file.md @@ -3,6 +3,7 @@ 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 public class MainActivity extends AppCompatActivity { @@ -21,7 +22,7 @@ public class MainActivity extends AppCompatActivity { storage.createFile( "[BUCKET_ID]", "[FILE_ID]", - File("file.png"), + InputFile.fromPath("file.png"), new Continuation() { @NotNull @Override diff --git a/docs/examples/kotlin/account/create-session.md b/docs/examples/kotlin/account/create-email-session.md similarity index 93% rename from docs/examples/kotlin/account/create-session.md rename to docs/examples/kotlin/account/create-email-session.md index 4999232..5dcec23 100644 --- a/docs/examples/kotlin/account/create-session.md +++ b/docs/examples/kotlin/account/create-email-session.md @@ -17,7 +17,7 @@ class MainActivity : AppCompatActivity() { val account = Account(client) GlobalScope.launch { - val response = account.createSession( + val response = account.createEmailSession( email = "email@example.com", password = "password" ) diff --git a/docs/examples/kotlin/account/create-phone-session.md b/docs/examples/kotlin/account/create-phone-session.md new file mode 100644 index 0000000..2df83ad --- /dev/null +++ b/docs/examples/kotlin/account/create-phone-session.md @@ -0,0 +1,27 @@ +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.createPhoneSession( + userId = "[USER_ID]", + phone = "" + ) + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-phone-verification.md b/docs/examples/kotlin/account/create-phone-verification.md new file mode 100644 index 0000000..ab0eccf --- /dev/null +++ b/docs/examples/kotlin/account/create-phone-verification.md @@ -0,0 +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 + +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.createPhoneVerification() + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-phone-session.md b/docs/examples/kotlin/account/update-phone-session.md new file mode 100644 index 0000000..c981991 --- /dev/null +++ b/docs/examples/kotlin/account/update-phone-session.md @@ -0,0 +1,27 @@ +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.updatePhoneSession( + userId = "[USER_ID]", + secret = "[SECRET]" + ) + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-phone-verification.md b/docs/examples/kotlin/account/update-phone-verification.md new file mode 100644 index 0000000..aa5eea3 --- /dev/null +++ b/docs/examples/kotlin/account/update-phone-verification.md @@ -0,0 +1,27 @@ +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.updatePhoneVerification( + userId = "[USER_ID]", + secret = "[SECRET]" + ) + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-phone.md b/docs/examples/kotlin/account/update-phone.md new file mode 100644 index 0000000..8ffef51 --- /dev/null +++ b/docs/examples/kotlin/account/update-phone.md @@ -0,0 +1,27 @@ +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.updatePhone( + phone = "", + password = "password" + ) + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/database/create-document.md b/docs/examples/kotlin/databases/create-document.md similarity index 81% rename from docs/examples/kotlin/database/create-document.md rename to docs/examples/kotlin/databases/create-document.md index d207383..8a755a2 100644 --- a/docs/examples/kotlin/database/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -14,10 +14,11 @@ class MainActivity : AppCompatActivity() { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID - val database = Database(client) + val databases = Databases(client) GlobalScope.launch { - val response = database.createDocument( + val response = databases.createDocument( + databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", documentId = "[DOCUMENT_ID]", data = mapOf( "a" to "b" ), diff --git a/docs/examples/kotlin/database/delete-document.md b/docs/examples/kotlin/databases/delete-document.md similarity index 80% rename from docs/examples/kotlin/database/delete-document.md rename to docs/examples/kotlin/databases/delete-document.md index 49a85c8..f56293b 100644 --- a/docs/examples/kotlin/database/delete-document.md +++ b/docs/examples/kotlin/databases/delete-document.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -14,10 +14,11 @@ class MainActivity : AppCompatActivity() { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID - val database = Database(client) + val databases = Databases(client) GlobalScope.launch { - val response = database.deleteDocument( + val response = databases.deleteDocument( + databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", documentId = "[DOCUMENT_ID]" ) diff --git a/docs/examples/kotlin/database/get-document.md b/docs/examples/kotlin/databases/get-document.md similarity index 81% rename from docs/examples/kotlin/database/get-document.md rename to docs/examples/kotlin/databases/get-document.md index 3dd65c0..1f5bf29 100644 --- a/docs/examples/kotlin/database/get-document.md +++ b/docs/examples/kotlin/databases/get-document.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -14,10 +14,11 @@ class MainActivity : AppCompatActivity() { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID - val database = Database(client) + val databases = Databases(client) GlobalScope.launch { - val response = database.getDocument( + val response = databases.getDocument( + databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", documentId = "[DOCUMENT_ID]" ) diff --git a/docs/examples/kotlin/database/list-documents.md b/docs/examples/kotlin/databases/list-documents.md similarity index 80% rename from docs/examples/kotlin/database/list-documents.md rename to docs/examples/kotlin/databases/list-documents.md index 6511981..5277b46 100644 --- a/docs/examples/kotlin/database/list-documents.md +++ b/docs/examples/kotlin/databases/list-documents.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -14,10 +14,11 @@ class MainActivity : AppCompatActivity() { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID - val database = Database(client) + val databases = Databases(client) GlobalScope.launch { - val response = database.listDocuments( + val response = databases.listDocuments( + databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", ) val json = response.body?.string() diff --git a/docs/examples/kotlin/database/update-document.md b/docs/examples/kotlin/databases/update-document.md similarity index 80% rename from docs/examples/kotlin/database/update-document.md rename to docs/examples/kotlin/databases/update-document.md index e19ce4a..7807f52 100644 --- a/docs/examples/kotlin/database/update-document.md +++ b/docs/examples/kotlin/databases/update-document.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -14,13 +14,13 @@ class MainActivity : AppCompatActivity() { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID - val database = Database(client) + val databases = Databases(client) GlobalScope.launch { - val response = database.updateDocument( + val response = databases.updateDocument( + databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", documentId = "[DOCUMENT_ID]", - data = mapOf( "a" to "b" ), ) val json = response.body?.string() } diff --git a/docs/examples/kotlin/storage/create-file.md b/docs/examples/kotlin/storage/create-file.md index c5cc6a3..d3d7c60 100644 --- a/docs/examples/kotlin/storage/create-file.md +++ b/docs/examples/kotlin/storage/create-file.md @@ -3,6 +3,7 @@ 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() { @@ -20,7 +21,7 @@ class MainActivity : AppCompatActivity() { val response = storage.createFile( bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]", - file = File("file.png"), + file = InputFile.fromPath("file.png"), ) val json = response.body?.string() } diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 4e5e78f..761fbaa 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -9,6 +9,7 @@ import io.appwrite.cookies.stores.SharedPreferencesCookieStore import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.fromJson import io.appwrite.json.PreciseNumberAdapter +import io.appwrite.models.InputFile import io.appwrite.models.UploadProgress import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -39,7 +40,7 @@ import kotlin.coroutines.resume class Client @JvmOverloads constructor( context: Context, - var endPoint: String = "https://appwrite.io/v1", + var endPoint: String = "https://HOSTNAME/v1", var endPointRealtime: String? = null, private var selfSigned: Boolean = false ) : CoroutineScope { @@ -84,8 +85,11 @@ class Client @JvmOverloads constructor( "content-type" to "application/json", "origin" to "appwrite-android://${context.packageName}", "user-agent" to "${context.packageName}/${appVersion}, ${System.getProperty("http.agent")}", - "x-sdk-version" to "appwrite:android:${BuildConfig.SDK_VERSION}", - "x-appwrite-response-format" to "0.14.0" + "x-sdk-name" to "Android", + "x-sdk-platform" to "client", + "x-sdk-language" to "android", + "x-sdk-version" to "0.8.0-SNAPSHOT", + "x-appwrite-response-format" to "1.0.0-RC1" ) config = mutableMapOf() @@ -342,14 +346,29 @@ class Client @JvmOverloads constructor( idParamName: String? = null, onProgress: ((UploadProgress) -> Unit)? = null, ): T { - val file = params[paramName] as File - val size = file.length() + var file: RandomAccessFile? = null + val input = params[paramName] as InputFile + val size: Long = when(input.sourceType) { + "path", "file" -> { + file = RandomAccessFile(input.path, "r") + file.length() + } + "bytes" -> { + (input.data as ByteArray).size.toLong() + } + else -> throw UnsupportedOperationException() + } if (size < CHUNK_SIZE) { + val data = when(input.sourceType) { + "file", "path" -> File(input.path).asRequestBody() + "bytes" -> (input.data as ByteArray).toRequestBody(input.mimeType.toMediaType()) + else -> throw UnsupportedOperationException() + } params[paramName] = MultipartBody.Part.createFormData( paramName, - file.name, - file.asRequestBody() + input.filename, + data ) return call( method = "POST", @@ -361,7 +380,6 @@ class Client @JvmOverloads constructor( ) } - val input = RandomAccessFile(file, "r") val buffer = ByteArray(CHUNK_SIZE) var offset = 0L var result: Map<*, *>? = null @@ -380,12 +398,29 @@ class Client @JvmOverloads constructor( } while (offset < size) { - input.seek(offset) - input.read(buffer) + when(input.sourceType) { + "file", "path" -> { + file!!.seek(offset) + file!!.read(buffer) + } + "bytes" -> { + val end = if (offset + CHUNK_SIZE < size) { + offset + CHUNK_SIZE + } else { + size - 1 + } + (input.data as ByteArray).copyInto( + buffer, + startIndex = offset.toInt(), + endIndex = end.toInt() + ) + } + else -> throw UnsupportedOperationException() + } params[paramName] = MultipartBody.Part.createFormData( paramName, - file.name, + input.filename, buffer.toRequestBody() ) diff --git a/library/src/main/java/io/appwrite/ID.kt b/library/src/main/java/io/appwrite/ID.kt new file mode 100644 index 0000000..fe8e656 --- /dev/null +++ b/library/src/main/java/io/appwrite/ID.kt @@ -0,0 +1,10 @@ +package io.appwrite + +class ID { + companion object { + fun custom(id: String): String + = id + fun unique(): String + = "unique()" + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/Permission.kt b/library/src/main/java/io/appwrite/Permission.kt new file mode 100644 index 0000000..a540dcf --- /dev/null +++ b/library/src/main/java/io/appwrite/Permission.kt @@ -0,0 +1,21 @@ +package io.appwrite + +class Permission { + companion object { + fun read(role: String): String { + return "read(\"${role}\")" + } + fun write(role: String): String { + return "write(\"${role}\")" + } + fun create(role: String): String { + return "create(\"${role}\")" + } + fun update(role: String): String { + return "update(\"${role}\")" + } + fun delete(role: String): String { + return "delete(\"${role}\")" + } + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/Query.kt b/library/src/main/java/io/appwrite/Query.kt index b86507b..2d33a02 100644 --- a/library/src/main/java/io/appwrite/Query.kt +++ b/library/src/main/java/io/appwrite/Query.kt @@ -6,20 +6,32 @@ class Query { fun notEqual(attribute: String, value: Any) = Query.addQuery(attribute, "notEqual", value) - fun lesser(attribute: String, value: Any) = Query.addQuery(attribute, "lesser", value) + fun lessThan(attribute: String, value: Any) = Query.addQuery(attribute, "lessThan", value) - fun lesserEqual(attribute: String, value: Any) = Query.addQuery(attribute, "lesserEqual", value) + fun lessThanEqual(attribute: String, value: Any) = Query.addQuery(attribute, "lessThanEqual", value) - fun greater(attribute: String, value: Any) = Query.addQuery(attribute, "greater", value) + fun greaterThan(attribute: String, value: Any) = Query.addQuery(attribute, "greaterThan", value) - fun greaterEqual(attribute: String, value: Any) = Query.addQuery(attribute, "greaterEqual", value) + fun greaterThanEqual(attribute: String, value: Any) = Query.addQuery(attribute, "greaterThanEqual", value) fun search(attribute: String, value: String) = Query.addQuery(attribute, "search", value) - private fun addQuery(attribute: String, oper: String, value: Any): String { + fun orderAsc(attribute: String) = "orderAsc(\"${attribute}\")" + + fun orderDesc(attribute: String) = "orderDesc(\"${attribute}\")" + + fun cursorBefore(documentId: String) = "cursorBefore(\"${documentId}\")" + + fun cursorAfter(documentId: String) = "cursorAfter(\"${documentId}\")" + + fun limit(limit: Int) = "limit(${limit})" + + fun offset(offset: Int) = "offset(${offset})" + + private fun addQuery(attribute: String, method: String, value: Any): String { return when (value) { - is List<*> -> "${attribute}.${oper}(${value.map{it -> parseValues(it!!)}.joinToString(",")})" - else -> "${attribute}.${oper}(${Query.parseValues(value)})" + is List<*> -> "${method}(\"${attribute}\", [${value.map{it -> parseValues(it!!)}.joinToString(",")}])" + else -> "${method}(\"${attribute}\", [${Query.parseValues(value)}])" } } private fun parseValues(value: Any): String { diff --git a/library/src/main/java/io/appwrite/Role.kt b/library/src/main/java/io/appwrite/Role.kt new file mode 100644 index 0000000..1764cc6 --- /dev/null +++ b/library/src/main/java/io/appwrite/Role.kt @@ -0,0 +1,22 @@ +package io.appwrite + +class Role { + companion object { + fun any(): String + = "any" + fun user(id: String): String + = "user:$id" + fun users(): String + = "users" + fun guests(): String + = "guests" + fun team(id: String, role: String = ""): String + = if(role.isEmpty()) { + "team:$id" + } else { + "team:$id/$role" + } + fun status(status: String): String + = "status:$status" + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/User.kt b/library/src/main/java/io/appwrite/models/Account.kt similarity index 57% rename from library/src/main/java/io/appwrite/models/User.kt rename to library/src/main/java/io/appwrite/models/Account.kt index 032391e..5bc87e7 100644 --- a/library/src/main/java/io/appwrite/models/User.kt +++ b/library/src/main/java/io/appwrite/models/Account.kt @@ -3,9 +3,9 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName /** - * User + * Account */ -data class User( +data class Account( /** * User ID. * @@ -13,6 +13,20 @@ data class User( @SerializedName("\$id") val id: String, + /** + * User creation date in Datetime. + * + */ + @SerializedName("\$createdAt") + val createdAt: String, + + /** + * User update date in Datetime. + * + */ + @SerializedName("\$updatedAt") + val updatedAt: String, + /** * User name. * @@ -21,11 +35,11 @@ data class User( val name: String, /** - * User registration date in Unix timestamp. + * User registration date in Datetime. * */ @SerializedName("registration") - val registration: Long, + val registration: String, /** * User status. Pass `true` for enabled and `false` for disabled. @@ -35,11 +49,11 @@ data class User( val status: Boolean, /** - * Unix timestamp of the most recent password update + * Datetime of the most recent password update * */ @SerializedName("passwordUpdate") - val passwordUpdate: Long, + val passwordUpdate: String, /** * User email address. @@ -48,6 +62,13 @@ data class User( @SerializedName("email") val email: String, + /** + * User phone number in E.164 format. + * + */ + @SerializedName("phone") + val phone: String, + /** * Email verification status. * @@ -55,6 +76,13 @@ data class User( @SerializedName("emailVerification") val emailVerification: Boolean, + /** + * Phone verification status. + * + */ + @SerializedName("phoneVerification") + val phoneVerification: Boolean, + /** * User preferences as a key-value object * @@ -64,26 +92,34 @@ data class User( ) { companion object { @Suppress("UNCHECKED_CAST") - fun from(map: Map) = User( + fun from(map: Map) = Account( id = map["\$id"] as String, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, name = map["name"] as String, - registration = (map["registration"] as Number).toLong(), + registration = map["registration"] as String, status = map["status"] as Boolean, - passwordUpdate = (map["passwordUpdate"] as Number).toLong(), + passwordUpdate = map["passwordUpdate"] as String, email = map["email"] as String, + phone = map["phone"] as String, emailVerification = map["emailVerification"] as Boolean, + phoneVerification = map["phoneVerification"] as Boolean, prefs = Preferences.from(map = map["prefs"] as Map) ) } 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/Document.kt b/library/src/main/java/io/appwrite/models/Document.kt index a83a844..3ffbd5f 100644 --- a/library/src/main/java/io/appwrite/models/Document.kt +++ b/library/src/main/java/io/appwrite/models/Document.kt @@ -21,18 +21,25 @@ data class Document( val collection: String, /** - * Document read permissions. + * Document creation date in Datetime * */ - @SerializedName("\$read") - val read: List, + @SerializedName("\$createdAt") + val createdAt: String, /** - * Document write permissions. + * Document update date in Datetime * */ - @SerializedName("\$write") - val write: List, + @SerializedName("\$updatedAt") + val updatedAt: String, + + /** + * Document permissions. [Learn more about permissions](/docs/permissions). + * + */ + @SerializedName("\$permissions") + val permissions: List, val data: Map ) { @@ -41,8 +48,9 @@ data class Document( fun from(map: Map) = Document( id = map["\$id"] as String, collection = map["\$collection"] as String, - read = map["\$read"] as List, - write = map["\$write"] as List, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, + permissions = map["\$permissions"] as List, data = map ) } @@ -50,8 +58,9 @@ data class Document( fun toMap(): Map = mapOf( "\$id" to id as Any, "\$collection" to collection as Any, - "\$read" to read as Any, - "\$write" to write as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "\$permissions" to permissions as Any, "data" to data ) diff --git a/library/src/main/java/io/appwrite/models/Execution.kt b/library/src/main/java/io/appwrite/models/Execution.kt index 06c2811..52b4d03 100644 --- a/library/src/main/java/io/appwrite/models/Execution.kt +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -14,25 +14,32 @@ data class Execution( val id: String, /** - * Execution read permissions. + * Execution creation date in Datetime * */ - @SerializedName("\$read") - val read: List, + @SerializedName("\$createdAt") + val createdAt: String, /** - * Function ID. + * Execution upate date in Datetime * */ - @SerializedName("functionId") - val functionId: String, + @SerializedName("\$updatedAt") + val updatedAt: String, + + /** + * Execution roles. + * + */ + @SerializedName("\$permissions") + val permissions: List, /** - * The execution creation date in Unix timestamp. + * Function ID. * */ - @SerializedName("dateCreated") - val dateCreated: Long, + @SerializedName("functionId") + val functionId: String, /** * The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. @@ -63,7 +70,14 @@ data class Execution( val response: String, /** - * The script stderr output string. Logs the last 4,000 characters of the execution stderr output + * 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") @@ -80,13 +94,15 @@ data class Execution( @Suppress("UNCHECKED_CAST") fun from(map: Map) = Execution( id = map["\$id"] as String, - read = map["\$read"] as List, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, + permissions = map["\$permissions"] as List, functionId = map["functionId"] as String, - dateCreated = (map["dateCreated"] as Number).toLong(), trigger = map["trigger"] as String, status = map["status"] as String, statusCode = (map["statusCode"] as Number).toLong(), response = map["response"] as String, + stdout = map["stdout"] as String, stderr = map["stderr"] as String, time = (map["time"] as Number).toDouble() ) @@ -94,13 +110,15 @@ data class Execution( fun toMap(): Map = mapOf( "\$id" to id as Any, - "\$read" to read as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "\$permissions" to permissions as Any, "functionId" to functionId as Any, - "dateCreated" to dateCreated 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, "time" to time as Any ) diff --git a/library/src/main/java/io/appwrite/models/File.kt b/library/src/main/java/io/appwrite/models/File.kt index 2faa1e4..576751e 100644 --- a/library/src/main/java/io/appwrite/models/File.kt +++ b/library/src/main/java/io/appwrite/models/File.kt @@ -21,32 +21,32 @@ data class File( val bucketId: String, /** - * File read permissions. + * File creation date in Datetime * */ - @SerializedName("\$read") - val read: List, + @SerializedName("\$createdAt") + val createdAt: String, /** - * File write permissions. + * File update date in Datetime * */ - @SerializedName("\$write") - val write: List, + @SerializedName("\$updatedAt") + val updatedAt: String, /** - * File name. + * File permissions. [Learn more about permissions](/docs/permissions). * */ - @SerializedName("name") - val name: String, + @SerializedName("\$permissions") + val permissions: List, /** - * File creation date in Unix timestamp. + * File name. * */ - @SerializedName("dateCreated") - val dateCreated: Long, + @SerializedName("name") + val name: String, /** * File MD5 signature. @@ -88,10 +88,10 @@ data class File( fun from(map: Map) = File( id = map["\$id"] as String, bucketId = map["bucketId"] as String, - read = map["\$read"] as List, - write = map["\$write"] as List, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, + permissions = map["\$permissions"] as List, name = map["name"] as String, - dateCreated = (map["dateCreated"] as Number).toLong(), signature = map["signature"] as String, mimeType = map["mimeType"] as String, sizeOriginal = (map["sizeOriginal"] as Number).toLong(), @@ -103,10 +103,10 @@ data class File( fun toMap(): Map = mapOf( "\$id" to id as Any, "bucketId" to bucketId as Any, - "\$read" to read as Any, - "\$write" to write as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "\$permissions" to permissions as Any, "name" to name as Any, - "dateCreated" to dateCreated as Any, "signature" to signature as Any, "mimeType" to mimeType as Any, "sizeOriginal" to sizeOriginal as Any, diff --git a/library/src/main/java/io/appwrite/models/InputFile.kt b/library/src/main/java/io/appwrite/models/InputFile.kt new file mode 100644 index 0000000..afbb2e9 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/InputFile.kt @@ -0,0 +1,37 @@ +package io.appwrite.models + +import java.io.File +import java.net.URLConnection +import java.nio.file.Files +import java.nio.file.Paths + +class InputFile private constructor() { + + lateinit var path: String + lateinit var filename: String + lateinit var mimeType: String + lateinit var sourceType: String + lateinit var data: Any + + companion object { + fun fromFile(file: File) = InputFile().apply { + path = file.canonicalPath + filename = file.name + mimeType = Files.probeContentType(Paths.get(file.canonicalPath)) + ?: URLConnection.guessContentTypeFromName(filename) + ?: "" + sourceType = "file" + } + + fun fromPath(path: String): InputFile = fromFile(File(path)).apply { + sourceType = "path" + } + + fun fromBytes(bytes: ByteArray, filename: String = "", mimeType: String = "") = InputFile().apply { + this.filename = filename + this.mimeType = mimeType + data = bytes + sourceType = "bytes" + } + } +} \ 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 fb4de88..7d7dcdf 100644 --- a/library/src/main/java/io/appwrite/models/Log.kt +++ b/library/src/main/java/io/appwrite/models/Log.kt @@ -49,11 +49,11 @@ data class Log( val ip: String, /** - * Log creation time in Unix timestamp. + * Log creation date in Datetime. * */ @SerializedName("time") - val time: Long, + val time: String, /** * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). @@ -162,7 +162,7 @@ data class Log( userName = map["userName"] as String, mode = map["mode"] as String, ip = map["ip"] as String, - time = (map["time"] as Number).toLong(), + time = map["time"] as String, osCode = map["osCode"] as String, osName = map["osName"] as String, osVersion = map["osVersion"] as String, diff --git a/library/src/main/java/io/appwrite/models/Membership.kt b/library/src/main/java/io/appwrite/models/Membership.kt index 3df7b69..f86d6bf 100644 --- a/library/src/main/java/io/appwrite/models/Membership.kt +++ b/library/src/main/java/io/appwrite/models/Membership.kt @@ -13,6 +13,20 @@ data class Membership( @SerializedName("\$id") val id: String, + /** + * Membership creation date in Datetime + * + */ + @SerializedName("\$createdAt") + val createdAt: String, + + /** + * Membership update date in Datetime + * + */ + @SerializedName("\$updatedAt") + val updatedAt: String, + /** * User ID. * @@ -49,18 +63,18 @@ data class Membership( val teamName: String, /** - * Date, the user has been invited to join the team in Unix timestamp. + * Date, the user has been invited to join the team in Datetime * */ @SerializedName("invited") - val invited: Long, + val invited: String, /** - * Date, the user has accepted the invitation to join the team in Unix timestamp. + * Date, the user has accepted the invitation to join the team in Datetime * */ @SerializedName("joined") - val joined: Long, + val joined: String, /** * User confirmation status, true if the user has joined the team or false otherwise. @@ -80,13 +94,15 @@ data class Membership( @Suppress("UNCHECKED_CAST") fun from(map: Map) = Membership( id = map["\$id"] as String, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, userId = map["userId"] as String, userName = map["userName"] as String, userEmail = map["userEmail"] as String, teamId = map["teamId"] as String, teamName = map["teamName"] as String, - invited = (map["invited"] as Number).toLong(), - joined = (map["joined"] as Number).toLong(), + invited = map["invited"] as String, + joined = map["joined"] as String, confirm = map["confirm"] as Boolean, roles = map["roles"] as List ) @@ -94,6 +110,8 @@ data class Membership( 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, diff --git a/library/src/main/java/io/appwrite/models/Session.kt b/library/src/main/java/io/appwrite/models/Session.kt index 1abd909..c0a49fb 100644 --- a/library/src/main/java/io/appwrite/models/Session.kt +++ b/library/src/main/java/io/appwrite/models/Session.kt @@ -13,6 +13,13 @@ data class Session( @SerializedName("\$id") val id: String, + /** + * Session creation date in Datetime + * + */ + @SerializedName("\$createdAt") + val createdAt: String, + /** * User ID. * @@ -21,11 +28,11 @@ data class Session( val userId: String, /** - * Session expiration date in Unix timestamp. + * Session expiration date in Datetime * */ @SerializedName("expire") - val expire: Long, + val expire: String, /** * Session Provider. @@ -49,11 +56,11 @@ data class Session( val providerAccessToken: String, /** - * Date, the Unix timestamp of when the access token expires. + * The date of when the access token expires in Datetime format. * */ @SerializedName("providerAccessTokenExpiry") - val providerAccessTokenExpiry: Long, + val providerAccessTokenExpiry: String, /** * Session Provider Refresh Token. @@ -178,12 +185,13 @@ data class Session( @Suppress("UNCHECKED_CAST") fun from(map: Map) = Session( id = map["\$id"] as String, + createdAt = map["\$createdAt"] as String, userId = map["userId"] as String, - expire = (map["expire"] as Number).toLong(), + expire = map["expire"] as String, provider = map["provider"] as String, providerUid = map["providerUid"] as String, providerAccessToken = map["providerAccessToken"] as String, - providerAccessTokenExpiry = (map["providerAccessTokenExpiry"] as Number).toLong(), + providerAccessTokenExpiry = map["providerAccessTokenExpiry"] as String, providerRefreshToken = map["providerRefreshToken"] as String, ip = map["ip"] as String, osCode = map["osCode"] as String, @@ -206,6 +214,7 @@ data class Session( 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, diff --git a/library/src/main/java/io/appwrite/models/Team.kt b/library/src/main/java/io/appwrite/models/Team.kt index f502375..0419e4b 100644 --- a/library/src/main/java/io/appwrite/models/Team.kt +++ b/library/src/main/java/io/appwrite/models/Team.kt @@ -14,18 +14,25 @@ data class Team( val id: String, /** - * Team name. + * Team creation date in Datetime * */ - @SerializedName("name") - val name: String, + @SerializedName("\$createdAt") + val createdAt: String, + + /** + * Team update date in Datetime + * + */ + @SerializedName("\$updatedAt") + val updatedAt: String, /** - * Team creation date in Unix timestamp. + * Team name. * */ - @SerializedName("dateCreated") - val dateCreated: Long, + @SerializedName("name") + val name: String, /** * Total number of team members. @@ -38,16 +45,18 @@ data class Team( @Suppress("UNCHECKED_CAST") 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, - dateCreated = (map["dateCreated"] 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, - "dateCreated" to dateCreated as Any, "total" to total 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 d555f45..d5a5c4f 100644 --- a/library/src/main/java/io/appwrite/models/Token.kt +++ b/library/src/main/java/io/appwrite/models/Token.kt @@ -13,6 +13,13 @@ data class Token( @SerializedName("\$id") val id: String, + /** + * Token creation date in Datetime + * + */ + @SerializedName("\$createdAt") + val createdAt: String, + /** * User ID. * @@ -28,24 +35,26 @@ data class Token( val secret: String, /** - * Token expiration date in Unix timestamp. + * Token expiration date in Datetime. * */ @SerializedName("expire") - val expire: Long + val expire: String ) { companion object { @Suppress("UNCHECKED_CAST") 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 Number).toLong() + 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 diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 8f144de..02fd660 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -12,33 +12,35 @@ import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import java.io.File -class Account(client: Client) : Service(client) { +class Account : Service { + + public constructor (client: Client) : super(client) { } /** * Get Account * * Get currently logged in user data as JSON object. * - * @return [io.appwrite.models.User] + * @return [io.appwrite.models.Account] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun get(): io.appwrite.models.User { + suspend fun get(): io.appwrite.models.Account { val path = "/account" val params = mutableMapOf( ) val headers = mutableMapOf( "content-type" to "application/json" ) - val converter: (Map) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it) + val converter: (Map) -> io.appwrite.models.Account = { + io.appwrite.models.Account.from(map = it) } return client.call( "GET", path, headers, params, - responseType = io.appwrite.models.User::class.java, + responseType = io.appwrite.models.Account::class.java, converter, ) } @@ -57,7 +59,7 @@ class Account(client: Client) : Service(client) { * @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.User] + * @return [io.appwrite.models.Account] */ @JvmOverloads @Throws(AppwriteException::class) @@ -66,7 +68,7 @@ class Account(client: Client) : Service(client) { email: String, password: String, name: String? = null - ): io.appwrite.models.User { + ): io.appwrite.models.Account { val path = "/account" val params = mutableMapOf( "userId" to userId, @@ -77,15 +79,15 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val converter: (Map) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it) + val converter: (Map) -> io.appwrite.models.Account = { + io.appwrite.models.Account.from(map = it) } return client.call( "POST", path, headers, params, - responseType = io.appwrite.models.User::class.java, + responseType = io.appwrite.models.Account::class.java, converter, ) } @@ -104,14 +106,14 @@ class Account(client: Client) : Service(client) { * * @param email User email. * @param password User password. Must be at least 8 chars. - * @return [io.appwrite.models.User] + * @return [io.appwrite.models.Account] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun updateEmail( email: String, password: String - ): io.appwrite.models.User { + ): io.appwrite.models.Account { val path = "/account/email" val params = mutableMapOf( "email" to email, @@ -120,15 +122,15 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val converter: (Map) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it) + val converter: (Map) -> io.appwrite.models.Account = { + io.appwrite.models.Account.from(map = it) } return client.call( "PATCH", path, headers, params, - responseType = io.appwrite.models.User::class.java, + responseType = io.appwrite.models.Account::class.java, converter, ) } @@ -172,20 +174,17 @@ class Account(client: Client) : Service(client) { * 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 limit Maximum number of logs to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) + * @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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getLogs( - limit: Long? = null, - offset: Long? = null + queries: List? = null ): io.appwrite.models.LogList { val path = "/account/logs" val params = mutableMapOf( - "limit" to limit, - "offset" to offset + "queries" to queries ) val headers = mutableMapOf( "content-type" to "application/json" @@ -209,13 +208,13 @@ class Account(client: Client) : Service(client) { * Update currently logged in user account name. * * @param name User name. Max length: 128 chars. - * @return [io.appwrite.models.User] + * @return [io.appwrite.models.Account] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun updateName( name: String - ): io.appwrite.models.User { + ): io.appwrite.models.Account { val path = "/account/name" val params = mutableMapOf( "name" to name @@ -223,15 +222,15 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val converter: (Map) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it) + val converter: (Map) -> io.appwrite.models.Account = { + io.appwrite.models.Account.from(map = it) } return client.call( "PATCH", path, headers, params, - responseType = io.appwrite.models.User::class.java, + responseType = io.appwrite.models.Account::class.java, converter, ) } @@ -245,14 +244,14 @@ class Account(client: Client) : Service(client) { * * @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.User] + * @return [io.appwrite.models.Account] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun updatePassword( password: String, oldPassword: String? = null - ): io.appwrite.models.User { + ): io.appwrite.models.Account { val path = "/account/password" val params = mutableMapOf( "password" to password, @@ -261,15 +260,55 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val converter: (Map) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it) + val converter: (Map) -> io.appwrite.models.Account = { + io.appwrite.models.Account.from(map = it) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.Account::class.java, + converter, + ) + } + + /** + * Update Account 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] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updatePhone( + phone: String, + password: String + ): io.appwrite.models.Account { + val path = "/account/phone" + val params = mutableMapOf( + "phone" to phone, + "password" to password + ) + val headers = mutableMapOf( + "content-type" to "application/json" + ) + val converter: (Map) -> io.appwrite.models.Account = { + io.appwrite.models.Account.from(map = it) } return client.call( "PATCH", path, headers, params, - responseType = io.appwrite.models.User::class.java, + responseType = io.appwrite.models.Account::class.java, converter, ) } @@ -311,13 +350,13 @@ class Account(client: Client) : Service(client) { * size is 64kB and throws error if exceeded. * * @param prefs Prefs key-value JSON object. - * @return [io.appwrite.models.User] + * @return [io.appwrite.models.Account] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun updatePrefs( prefs: Any - ): io.appwrite.models.User { + ): io.appwrite.models.Account { val path = "/account/prefs" val params = mutableMapOf( "prefs" to prefs @@ -325,15 +364,15 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val converter: (Map) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it) + val converter: (Map) -> io.appwrite.models.Account = { + io.appwrite.models.Account.from(map = it) } return client.call( "PATCH", path, headers, params, - responseType = io.appwrite.models.User::class.java, + responseType = io.appwrite.models.Account::class.java, converter, ) } @@ -462,85 +501,85 @@ class Account(client: Client) : Service(client) { } /** - * Create Account Session + * Delete All Account Sessions * - * 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. + * Delete all sessions from the user account and remove any sessions cookies + * from the end client. * - * @param email User email. - * @param password User password. Must be at least 8 chars. - * @return [io.appwrite.models.Session] + * @return [Any] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun createSession( - email: String, - password: String - ): io.appwrite.models.Session { + suspend fun deleteSessions(): Any { val path = "/account/sessions" val params = mutableMapOf( - "email" to email, - "password" to password ) val headers = mutableMapOf( "content-type" to "application/json" ) - val converter: (Map) -> io.appwrite.models.Session = { - io.appwrite.models.Session.from(map = it) - } return client.call( - "POST", + "DELETE", path, headers, params, - responseType = io.appwrite.models.Session::class.java, - converter, + responseType = Any::class.java, ) } /** - * Delete All Account Sessions + * Create Anonymous Session * - * Delete all sessions from the user account and remove any sessions cookies - * from the end client. + * 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 [Any] + * @return [io.appwrite.models.Session] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun deleteSessions(): Any { - val path = "/account/sessions" + suspend fun createAnonymousSession(): io.appwrite.models.Session { + val path = "/account/sessions/anonymous" val params = mutableMapOf( ) val headers = mutableMapOf( "content-type" to "application/json" ) + val converter: (Map) -> io.appwrite.models.Session = { + io.appwrite.models.Session.from(map = it) + } return client.call( - "DELETE", + "POST", path, headers, params, - responseType = Any::class.java, + responseType = io.appwrite.models.Session::class.java, + converter, ) } /** - * Create Anonymous Session + * Create Account Session with Email * - * 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). + * 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. * + * @param email User email. + * @param password User password. Must be at least 8 chars. * @return [io.appwrite.models.Session] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun createAnonymousSession(): io.appwrite.models.Session { - val path = "/account/sessions/anonymous" + suspend fun createEmailSession( + email: String, + password: String + ): io.appwrite.models.Session { + val path = "/account/sessions/email" val params = mutableMapOf( + "email" to email, + "password" to password ) val headers = mutableMapOf( "content-type" to "application/json" @@ -561,9 +600,10 @@ class Account(client: Client) : Service(client) { /** * Create Magic URL session * - * Sends the user an email with a secret key for creating a session. 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 + * 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) @@ -668,10 +708,10 @@ class Account(client: Client) : Service(client) { * user.. * * - * @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, bitbucket, bitly, box, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, notion, okta, paypal, paypalSandbox, salesforce, slack, spotify, tradeshift, tradeshiftBox, twitch, zoom, yahoo, yammer, yandex, wordpress, stripe. + * @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 128 characters long. + * @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 @@ -681,7 +721,7 @@ class Account(client: Client) : Service(client) { provider: String, success: String? = null, failure: String? = null, - scopes: List? = null + scopes: List? = null ) { val path = "/account/sessions/oauth2/{provider}".replace("{provider}", provider) val params = mutableMapOf( @@ -734,6 +774,87 @@ class Account(client: Client) : Service(client) { } } + /** + * 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. + * + * @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 phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @return [io.appwrite.models.Token] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createPhoneSession( + userId: String, + phone: String + ): io.appwrite.models.Token { + val path = "/account/sessions/phone" + val params = mutableMapOf( + "userId" to userId, + "phone" to phone + ) + val headers = mutableMapOf( + "content-type" to "application/json" + ) + val converter: (Map) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Token::class.java, + 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. + * + * @param userId User ID. + * @param secret Valid verification token. + * @return [io.appwrite.models.Session] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updatePhoneSession( + userId: String, + secret: String + ): io.appwrite.models.Session { + val path = "/account/sessions/phone" + val params = mutableMapOf( + "userId" to userId, + "secret" to secret + ) + val headers = mutableMapOf( + "content-type" to "application/json" + ) + val converter: (Map) -> io.appwrite.models.Session = { + io.appwrite.models.Session.from(map = it) + } + return client.call( + "PUT", + path, + headers, + params, + responseType = io.appwrite.models.Session::class.java, + converter, + ) + } + /** * Get Session By ID * @@ -839,26 +960,26 @@ class Account(client: Client) : Service(client) { * record is not deleted but permanently blocked from any access. To * completely delete a user, use the Users API instead. * - * @return [io.appwrite.models.User] + * @return [io.appwrite.models.Account] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun updateStatus(): io.appwrite.models.User { + suspend fun updateStatus(): io.appwrite.models.Account { val path = "/account/status" val params = mutableMapOf( ) val headers = mutableMapOf( "content-type" to "application/json" ) - val converter: (Map) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it) + val converter: (Map) -> io.appwrite.models.Account = { + io.appwrite.models.Account.from(map = it) } return client.call( "PATCH", path, headers, params, - responseType = io.appwrite.models.User::class.java, + responseType = io.appwrite.models.Account::class.java, converter, ) } @@ -873,8 +994,8 @@ class Account(client: Client) : Service(client) { * 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#accountUpdateVerification). The verification - * link sent to the user's email address is valid for 7 days. + * 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), @@ -949,4 +1070,77 @@ class Account(client: Client) : Service(client) { ) } + /** + * 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. + * + * @return [io.appwrite.models.Token] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createPhoneVerification(): io.appwrite.models.Token { + val path = "/account/verification/phone" + val params = mutableMapOf( + ) + val headers = mutableMapOf( + "content-type" to "application/json" + ) + val converter: (Map) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Token::class.java, + 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. + * + * @param userId User ID. + * @param secret Valid verification token. + * @return [io.appwrite.models.Token] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updatePhoneVerification( + userId: String, + secret: String + ): io.appwrite.models.Token { + val path = "/account/verification/phone" + val params = mutableMapOf( + "userId" to userId, + "secret" to secret + ) + val headers = mutableMapOf( + "content-type" to "application/json" + ) + val converter: (Map) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it) + } + return client.call( + "PUT", + path, + headers, + params, + responseType = io.appwrite.models.Token::class.java, + 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 20e1f54..bb75581 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -10,7 +10,9 @@ import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import java.io.File -class Avatars(client: Client) : Service(client) { +class Avatars : Service { + + public constructor (client: Client) : super(client) { } /** * Get Browser Icon @@ -129,7 +131,8 @@ class Avatars(client: Client) : Service(client) { * * 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. + * 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 diff --git a/library/src/main/java/io/appwrite/services/Database.kt b/library/src/main/java/io/appwrite/services/Databases.kt similarity index 58% rename from library/src/main/java/io/appwrite/services/Database.kt rename to library/src/main/java/io/appwrite/services/Databases.kt index 74bced3..65f1ead 100644 --- a/library/src/main/java/io/appwrite/services/Database.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -8,47 +8,33 @@ import okhttp3.Cookie import okhttp3.Response import java.io.File -class Database(client: Client) : Service(client) { +class Databases : Service { + + public constructor (client: Client) : super(client) { } /** * List Documents * - * Get a list of all the user documents. 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 documents. [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. 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). * - * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/database#querying-documents). Maximum of 100 queries are allowed, each 128 characters long. - * @param limit Maximum number of documents to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursor ID of the document used as the starting point for the query, excluding the document itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursorDirection Direction of the cursor. - * @param orderAttributes Array of attributes used to sort results. Maximum of 100 order attributes are allowed, each 128 characters long. - * @param orderTypes Array of order directions for sorting attribtues. Possible values are DESC for descending order, or ASC for ascending order. Maximum of 100 order types are allowed. + * @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, - limit: Long? = null, - offset: Long? = null, - cursor: String? = null, - cursorDirection: String? = null, - orderAttributes: List? = null, - orderTypes: List? = null + queries: List? = null ): io.appwrite.models.DocumentList { - val path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId) + val path = "/databases/{databaseId}/collections/{collectionId}/documents".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId) val params = mutableMapOf( - "queries" to queries, - "limit" to limit, - "offset" to offset, - "cursor" to cursor, - "cursorDirection" to cursorDirection, - "orderAttributes" to orderAttributes, - "orderTypes" to orderTypes + "queries" to queries ) val headers = mutableMapOf( "content-type" to "application/json" @@ -71,31 +57,30 @@ class Database(client: Client) : Service(client) { * * Create a new Document. Before using this route, you should create a new * collection resource using either a [server - * integration](/docs/server/database#databaseCreateCollection) API or + * integration](/docs/server/databases#databasesCreateCollection) API or * directly from your database console. * - * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). Make sure to define attributes before creating documents. + * @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 data Document data as JSON object. - * @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. - * @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. + * @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, - read: List? = null, - write: List? = null + permissions: List? = null ): io.appwrite.models.Document { - val path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId) + val path = "/databases/{databaseId}/collections/{collectionId}/documents".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId) val params = mutableMapOf( "documentId" to documentId, "data" to data, - "read" to read, - "write" to write + "permissions" to permissions ) val headers = mutableMapOf( "content-type" to "application/json" @@ -119,17 +104,19 @@ class Database(client: Client) : Service(client) { * Get a document by its unique ID. This endpoint response returns a JSON * object with the document data. * - * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). + * @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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getDocument( + databaseId: String, collectionId: String, documentId: String ): io.appwrite.models.Document { - val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId) + val path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId).replace("{documentId}", documentId) val params = mutableMapOf( ) val headers = mutableMapOf( @@ -154,27 +141,26 @@ class Database(client: Client) : Service(client) { * 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 read An array of strings with read permissions. By default inherits the existing read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. - * @param write An array of strings with write permissions. By default inherits the existing write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. + * @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, - read: List? = null, - write: List? = null + data: Any? = null, + permissions: List? = null ): io.appwrite.models.Document { - val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId) + val path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId).replace("{documentId}", documentId) val params = mutableMapOf( "data" to data, - "read" to read, - "write" to write + "permissions" to permissions ) val headers = mutableMapOf( "content-type" to "application/json" @@ -197,17 +183,19 @@ class Database(client: Client) : Service(client) { * * Delete a document by its unique ID. * - * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). + * @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] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun deleteDocument( + databaseId: String, collectionId: String, documentId: String ): Any { - val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId) + val path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId).replace("{documentId}", documentId) val params = mutableMapOf( ) val headers = mutableMapOf( diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index 85a1f2c..1c50538 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -8,7 +8,9 @@ import okhttp3.Cookie import okhttp3.Response import java.io.File -class Functions(client: Client) : Service(client) { +class Functions : Service { + + public constructor (client: Client) : super(client) { } /** * Retry Build @@ -49,30 +51,21 @@ class Functions(client: Client) : Service(client) { * different API modes](/docs/admin). * * @param functionId Function ID. - * @param limit Maximum number of executions to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) + * @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, time * @param search Search term to filter your list results. Max length: 256 chars. - * @param cursor ID of the execution used as the starting point for the query, excluding the execution itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursorDirection Direction of the cursor. * @return [io.appwrite.models.ExecutionList] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun listExecutions( functionId: String, - limit: Long? = null, - offset: Long? = null, - search: String? = null, - cursor: String? = null, - cursorDirection: String? = null + queries: List? = null, + search: String? = null ): io.appwrite.models.ExecutionList { val path = "/functions/{functionId}/executions".replace("{functionId}", functionId) val params = mutableMapOf( - "limit" to limit, - "offset" to offset, - "search" to search, - "cursor" to cursor, - "cursorDirection" to cursorDirection + "queries" to queries, + "search" to search ) val headers = mutableMapOf( "content-type" to "application/json" diff --git a/library/src/main/java/io/appwrite/services/Locale.kt b/library/src/main/java/io/appwrite/services/Locale.kt index 21b297c..b4ff685 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -8,7 +8,9 @@ import okhttp3.Cookie import okhttp3.Response import java.io.File -class Locale(client: Client) : Service(client) { +class Locale : Service { + + public constructor (client: Client) : super(client) { } /** * Get User Locale diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index c1e0abc..053e0e6 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -10,7 +10,9 @@ import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import java.io.File -class Storage(client: Client) : Service(client) { +class Storage : Service { + + public constructor (client: Client) : super(client) { } /** * List Files @@ -20,33 +22,21 @@ class Storage(client: Client) : Service(client) { * project's files. [Learn more about different API modes](/docs/admin). * * @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. - * @param limit Maximum number of files to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursor ID of the file used as the starting point for the query, excluding the file itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursorDirection Direction of the cursor. - * @param orderType Order result by ASC or DESC order. * @return [io.appwrite.models.FileList] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun listFiles( bucketId: String, - search: String? = null, - limit: Long? = null, - offset: Long? = null, - cursor: String? = null, - cursorDirection: String? = null, - orderType: String? = null + queries: List? = null, + search: String? = null ): io.appwrite.models.FileList { val path = "/storage/buckets/{bucketId}/files".replace("{bucketId}", bucketId) val params = mutableMapOf( - "search" to search, - "limit" to limit, - "offset" to offset, - "cursor" to cursor, - "cursorDirection" to cursorDirection, - "orderType" to orderType + "queries" to queries, + "search" to search ) val headers = mutableMapOf( "content-type" to "application/json" @@ -69,8 +59,8 @@ class Storage(client: Client) : Service(client) { * * Create a new file. Before using this route, you should create a new bucket * resource using either a [server - * integration](/docs/server/database#storageCreateBucket) API or directly - * from your Appwrite console. + * 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) @@ -89,8 +79,7 @@ class Storage(client: Client) : Service(client) { * @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 file Binary file. - * @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. - * @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. + * @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] */ @JvmOverloads @@ -98,16 +87,14 @@ class Storage(client: Client) : Service(client) { suspend fun createFile( bucketId: String, fileId: String, - file: File, - read: List? = null, - write: List? = null, onProgress: ((UploadProgress) -> Unit)? = null + 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, - "read" to read, - "write" to write + "permissions" to permissions ) val headers = mutableMapOf( "content-type" to "multipart/form-data" @@ -172,8 +159,7 @@ class Storage(client: Client) : Service(client) { * * @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 read An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. - * @param write An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. + * @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] */ @JvmOverloads @@ -181,13 +167,11 @@ class Storage(client: Client) : Service(client) { suspend fun updateFile( bucketId: String, fileId: String, - read: List? = null, - write: List? = null + permissions: List? = null ): io.appwrite.models.File { val path = "/storage/buckets/{bucketId}/files/{fileId}".replace("{bucketId}", bucketId).replace("{fileId}", fileId) val params = mutableMapOf( - "read" to read, - "write" to write + "permissions" to permissions ) val headers = mutableMapOf( "content-type" to "application/json" diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 5b74d1d..46fe9d0 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -8,7 +8,9 @@ import okhttp3.Cookie import okhttp3.Response import java.io.File -class Teams(client: Client) : Service(client) { +class Teams : Service { + + public constructor (client: Client) : super(client) { } /** * List Teams @@ -19,32 +21,20 @@ class Teams(client: Client) : Service(client) { * In admin mode, this endpoint returns a list of all the teams in the current * project. [Learn more about different API modes](/docs/admin). * + * @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. - * @param limit Maximum number of teams to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursor ID of the team used as the starting point for the query, excluding the team itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursorDirection Direction of the cursor. - * @param orderType Order result by ASC or DESC order. * @return [io.appwrite.models.TeamList] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun list( - search: String? = null, - limit: Long? = null, - offset: Long? = null, - cursor: String? = null, - cursorDirection: String? = null, - orderType: String? = null + queries: List? = null, + search: String? = null ): io.appwrite.models.TeamList { val path = "/teams" val params = mutableMapOf( - "search" to search, - "limit" to limit, - "offset" to offset, - "cursor" to cursor, - "cursorDirection" to cursorDirection, - "orderType" to orderType + "queries" to queries, + "search" to search ) val headers = mutableMapOf( "content-type" to "application/json" @@ -79,7 +69,7 @@ class Teams(client: Client) : Service(client) { suspend fun create( teamId: String, name: String, - roles: List? = null + roles: List? = null ): io.appwrite.models.Team { val path = "/teams" val params = mutableMapOf( @@ -207,33 +197,21 @@ class Teams(client: Client) : Service(client) { * 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. - * @param limit Maximum number of memberships to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursor ID of the membership used as the starting point for the query, excluding the membership itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursorDirection Direction of the cursor. - * @param orderType Order result by ASC or DESC order. * @return [io.appwrite.models.MembershipList] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getMemberships( teamId: String, - search: String? = null, - limit: Long? = null, - offset: Long? = null, - cursor: String? = null, - cursorDirection: String? = null, - orderType: String? = null + queries: List? = null, + search: String? = null ): io.appwrite.models.MembershipList { val path = "/teams/{teamId}/memberships".replace("{teamId}", teamId) val params = mutableMapOf( - "search" to search, - "limit" to limit, - "offset" to offset, - "cursor" to cursor, - "cursorDirection" to cursorDirection, - "orderType" to orderType + "queries" to queries, + "search" to search ) val headers = mutableMapOf( "content-type" to "application/json" @@ -282,7 +260,7 @@ class Teams(client: Client) : Service(client) { suspend fun createMembership( teamId: String, email: String, - roles: List, + roles: List, url: String, name: String? = null ): io.appwrite.models.Membership { @@ -361,7 +339,7 @@ class Teams(client: Client) : Service(client) { suspend fun updateMembershipRoles( teamId: String, membershipId: String, - roles: List + roles: List ): io.appwrite.models.Membership { val path = "/teams/{teamId}/memberships/{membershipId}".replace("{teamId}", teamId).replace("{membershipId}", membershipId) val params = mutableMapOf( From 6ec27cb2a8bea07788c5c64874de0bec659f6d59 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Mon, 5 Sep 2022 01:34:32 +0400 Subject: [PATCH 039/118] feat: update descriptions --- README.md | 8 +- .../java/databases/create-document.md | 3 +- .../java/databases/delete-document.md | 3 +- docs/examples/java/databases/get-document.md | 3 +- .../examples/java/databases/list-documents.md | 3 +- .../java/databases/update-document.md | 3 +- .../kotlin/account/create-phone-session.md | 2 +- docs/examples/kotlin/account/update-phone.md | 2 +- .../kotlin/databases/create-document.md | 3 +- .../kotlin/databases/delete-document.md | 3 +- .../examples/kotlin/databases/get-document.md | 3 +- .../kotlin/databases/list-documents.md | 3 +- .../kotlin/databases/update-document.md | 3 +- library/src/main/java/io/appwrite/Client.kt | 7 +- .../main/java/io/appwrite/models/Account.kt | 16 ++-- .../main/java/io/appwrite/models/Document.kt | 28 ++----- .../main/java/io/appwrite/models/Execution.kt | 33 +++----- .../src/main/java/io/appwrite/models/File.kt | 35 +++----- .../src/main/java/io/appwrite/models/Log.kt | 2 +- .../java/io/appwrite/models/Membership.kt | 16 ++-- .../main/java/io/appwrite/models/Session.kt | 10 +-- .../src/main/java/io/appwrite/models/Team.kt | 12 +-- .../src/main/java/io/appwrite/models/Token.kt | 8 +- .../main/java/io/appwrite/services/Account.kt | 81 +++++-------------- .../java/io/appwrite/services/Databases.kt | 48 ++++++----- .../java/io/appwrite/services/Functions.kt | 2 - .../main/java/io/appwrite/services/Storage.kt | 8 +- .../main/java/io/appwrite/services/Teams.kt | 14 +--- 28 files changed, 146 insertions(+), 216 deletions(-) diff --git a/README.md b/README.md index 859d5ca..2aa502b 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-0.15.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.0.0-RC1-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 0.15.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.0.0-RC1. 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:0.7.0") +implementation("io.appwrite:sdk-for-android:0.8.0-SNAPSHOT") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 0.7.0 + 0.8.0-SNAPSHOT ``` diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index 96aea79..7fc322b 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -16,9 +16,10 @@ public class MainActivity extends AppCompatActivity { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID - Databases databases = new Databases(client, "[DATABASE_ID]"); + Databases databases = new Databases(client); databases.createDocument( + "[DATABASE_ID]", "[COLLECTION_ID]", "[DOCUMENT_ID]", mapOf( "a" to "b" ), diff --git a/docs/examples/java/databases/delete-document.md b/docs/examples/java/databases/delete-document.md index e749a0a..f42a09b 100644 --- a/docs/examples/java/databases/delete-document.md +++ b/docs/examples/java/databases/delete-document.md @@ -16,9 +16,10 @@ public class MainActivity extends AppCompatActivity { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID - Databases databases = new Databases(client, "[DATABASE_ID]"); + Databases databases = new Databases(client); databases.deleteDocument( + "[DATABASE_ID]", "[COLLECTION_ID]", "[DOCUMENT_ID]" new Continuation() { diff --git a/docs/examples/java/databases/get-document.md b/docs/examples/java/databases/get-document.md index 2a7f227..f1a4d44 100644 --- a/docs/examples/java/databases/get-document.md +++ b/docs/examples/java/databases/get-document.md @@ -16,9 +16,10 @@ public class MainActivity extends AppCompatActivity { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID - Databases databases = new Databases(client, "[DATABASE_ID]"); + Databases databases = new Databases(client); databases.getDocument( + "[DATABASE_ID]", "[COLLECTION_ID]", "[DOCUMENT_ID]" new Continuation() { diff --git a/docs/examples/java/databases/list-documents.md b/docs/examples/java/databases/list-documents.md index 5f49d26..93d7333 100644 --- a/docs/examples/java/databases/list-documents.md +++ b/docs/examples/java/databases/list-documents.md @@ -16,9 +16,10 @@ public class MainActivity extends AppCompatActivity { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID - Databases databases = new Databases(client, "[DATABASE_ID]"); + Databases databases = new Databases(client); databases.listDocuments( + "[DATABASE_ID]", "[COLLECTION_ID]", new Continuation() { @NotNull diff --git a/docs/examples/java/databases/update-document.md b/docs/examples/java/databases/update-document.md index a9d361d..81e55d4 100644 --- a/docs/examples/java/databases/update-document.md +++ b/docs/examples/java/databases/update-document.md @@ -16,9 +16,10 @@ public class MainActivity extends AppCompatActivity { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID - Databases databases = new Databases(client, "[DATABASE_ID]"); + Databases databases = new Databases(client); databases.updateDocument( + "[DATABASE_ID]", "[COLLECTION_ID]", "[DOCUMENT_ID]", new Continuation() { diff --git a/docs/examples/kotlin/account/create-phone-session.md b/docs/examples/kotlin/account/create-phone-session.md index 899e3a3..2df83ad 100644 --- a/docs/examples/kotlin/account/create-phone-session.md +++ b/docs/examples/kotlin/account/create-phone-session.md @@ -19,7 +19,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = account.createPhoneSession( userId = "[USER_ID]", - number = "" + phone = "" ) val json = response.body?.string() } diff --git a/docs/examples/kotlin/account/update-phone.md b/docs/examples/kotlin/account/update-phone.md index b200b5b..8ffef51 100644 --- a/docs/examples/kotlin/account/update-phone.md +++ b/docs/examples/kotlin/account/update-phone.md @@ -18,7 +18,7 @@ class MainActivity : AppCompatActivity() { GlobalScope.launch { val response = account.updatePhone( - number = "", + phone = "", password = "password" ) val json = response.body?.string() diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index 37e20de..8a755a2 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -14,10 +14,11 @@ class MainActivity : AppCompatActivity() { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID - val databases = Databases(client, "[DATABASE_ID]") + val databases = Databases(client) GlobalScope.launch { 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 aa5e3ef..f56293b 100644 --- a/docs/examples/kotlin/databases/delete-document.md +++ b/docs/examples/kotlin/databases/delete-document.md @@ -14,10 +14,11 @@ class MainActivity : AppCompatActivity() { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID - val databases = Databases(client, "[DATABASE_ID]") + val databases = Databases(client) GlobalScope.launch { 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 9acc860..1f5bf29 100644 --- a/docs/examples/kotlin/databases/get-document.md +++ b/docs/examples/kotlin/databases/get-document.md @@ -14,10 +14,11 @@ class MainActivity : AppCompatActivity() { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID - val databases = Databases(client, "[DATABASE_ID]") + val databases = Databases(client) GlobalScope.launch { 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 48295f4..5277b46 100644 --- a/docs/examples/kotlin/databases/list-documents.md +++ b/docs/examples/kotlin/databases/list-documents.md @@ -14,10 +14,11 @@ class MainActivity : AppCompatActivity() { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID - val databases = Databases(client, "[DATABASE_ID]") + val databases = Databases(client) GlobalScope.launch { val response = databases.listDocuments( + databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", ) val json = response.body?.string() diff --git a/docs/examples/kotlin/databases/update-document.md b/docs/examples/kotlin/databases/update-document.md index 6e73fa1..7807f52 100644 --- a/docs/examples/kotlin/databases/update-document.md +++ b/docs/examples/kotlin/databases/update-document.md @@ -14,10 +14,11 @@ class MainActivity : AppCompatActivity() { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID - val databases = Databases(client, "[DATABASE_ID]") + val databases = Databases(client) GlobalScope.launch { val response = databases.updateDocument( + databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", documentId = "[DOCUMENT_ID]", ) diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index be46747..761fbaa 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -85,8 +85,11 @@ class Client @JvmOverloads constructor( "content-type" to "application/json", "origin" to "appwrite-android://${context.packageName}", "user-agent" to "${context.packageName}/${appVersion}, ${System.getProperty("http.agent")}", - "x-sdk-version" to "appwrite:android:${BuildConfig.SDK_VERSION}", - "x-appwrite-response-format" to "0.15.0" + "x-sdk-name" to "Android", + "x-sdk-platform" to "client", + "x-sdk-language" to "android", + "x-sdk-version" to "0.8.0-SNAPSHOT", + "x-appwrite-response-format" to "1.0.0-RC1" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/models/Account.kt b/library/src/main/java/io/appwrite/models/Account.kt index 754c94a..1450b82 100644 --- a/library/src/main/java/io/appwrite/models/Account.kt +++ b/library/src/main/java/io/appwrite/models/Account.kt @@ -14,18 +14,18 @@ data class Account( val id: String, /** - * User creation date in Unix timestamp. + * User creation date in ISO 8601 format. * */ @SerializedName("\$createdAt") - val createdAt: Long, + val createdAt: String, /** - * User update date in Unix timestamp. + * User update date in ISO 8601 format. * */ @SerializedName("\$updatedAt") - val updatedAt: Long, + val updatedAt: String, /** * User name. @@ -35,7 +35,7 @@ data class Account( val name: String, /** - * User registration date in Datetime. + * User registration date in ISO 8601 format. * */ @SerializedName("registration") @@ -49,7 +49,7 @@ data class Account( val status: Boolean, /** - * Datetime of the most recent password update + * Password update time in ISO 8601 format. * */ @SerializedName("passwordUpdate") @@ -94,8 +94,8 @@ data class Account( @Suppress("UNCHECKED_CAST") fun from(map: Map) = Account( id = map["\$id"] as String, - createdAt = (map["\$createdAt"] as Number).toLong(), - updatedAt = (map["\$updatedAt"] as Number).toLong(), + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, name = map["name"] as String, registration = map["registration"] as String, status = map["status"] as Boolean, diff --git a/library/src/main/java/io/appwrite/models/Document.kt b/library/src/main/java/io/appwrite/models/Document.kt index b8f0a82..d527f7c 100644 --- a/library/src/main/java/io/appwrite/models/Document.kt +++ b/library/src/main/java/io/appwrite/models/Document.kt @@ -21,28 +21,14 @@ data class Document( val collection: String, /** - * Document creation date in Unix timestamp. - * - */ - @SerializedName("\$createdAt") - val createdAt: Long, - - /** - * Document update date in Unix timestamp. - * - */ - @SerializedName("\$updatedAt") - val updatedAt: Long, - - /** - * Document read permissions. + * Document creation date in ISO 8601 format. * */ @SerializedName("\$createdAt") val createdAt: String, /** - * Document update date in Datetime + * Document update date in ISO 8601 format. * */ @SerializedName("\$updatedAt") @@ -62,10 +48,9 @@ data class Document( fun from(map: Map) = Document( id = map["\$id"] as String, collection = map["\$collection"] as String, - createdAt = (map["\$createdAt"] as Number).toLong(), - updatedAt = (map["\$updatedAt"] as Number).toLong(), - read = map["\$read"] as List, - write = map["\$write"] as List, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, + permissions = map["\$permissions"] as List, data = map ) } @@ -75,8 +60,7 @@ data class Document( "\$collection" to collection as Any, "\$createdAt" to createdAt as Any, "\$updatedAt" to updatedAt as Any, - "\$read" to read as Any, - "\$write" to write as Any, + "\$permissions" to permissions as Any, "data" to data ) diff --git a/library/src/main/java/io/appwrite/models/Execution.kt b/library/src/main/java/io/appwrite/models/Execution.kt index 7fb8467..46495bf 100644 --- a/library/src/main/java/io/appwrite/models/Execution.kt +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -14,28 +14,14 @@ data class Execution( val id: String, /** - * Execution creation date in Unix timestamp. - * - */ - @SerializedName("\$createdAt") - val createdAt: Long, - - /** - * Execution update date in Unix timestamp. - * - */ - @SerializedName("\$updatedAt") - val updatedAt: Long, - - /** - * Execution read permissions. + * Execution creation date in ISO 8601 format. * */ @SerializedName("\$createdAt") val createdAt: String, /** - * Execution upate date in Datetime + * Execution upate date in ISO 8601 format. * */ @SerializedName("\$updatedAt") @@ -48,6 +34,13 @@ data class Execution( @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`. * @@ -101,9 +94,9 @@ data class Execution( @Suppress("UNCHECKED_CAST") fun from(map: Map) = Execution( id = map["\$id"] as String, - createdAt = (map["\$createdAt"] as Number).toLong(), - updatedAt = (map["\$updatedAt"] as Number).toLong(), - read = map["\$read"] as List, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, + permissions = map["\$permissions"] as List, functionId = map["functionId"] as String, trigger = map["trigger"] as String, status = map["status"] as String, @@ -119,7 +112,7 @@ data class Execution( "\$id" to id as Any, "\$createdAt" to createdAt as Any, "\$updatedAt" to updatedAt as Any, - "\$read" to read as Any, + "\$permissions" to permissions as Any, "functionId" to functionId as Any, "trigger" to trigger as Any, "status" to status as Any, diff --git a/library/src/main/java/io/appwrite/models/File.kt b/library/src/main/java/io/appwrite/models/File.kt index f726121..3f1a296 100644 --- a/library/src/main/java/io/appwrite/models/File.kt +++ b/library/src/main/java/io/appwrite/models/File.kt @@ -21,28 +21,14 @@ data class File( val bucketId: String, /** - * File creation date in Unix timestamp. - * - */ - @SerializedName("\$createdAt") - val createdAt: Long, - - /** - * File update date in Unix timestamp. - * - */ - @SerializedName("\$updatedAt") - val updatedAt: Long, - - /** - * File read permissions. + * File creation date in ISO 8601 format. * */ @SerializedName("\$createdAt") val createdAt: String, /** - * File update date in Datetime + * File update date in ISO 8601 format. * */ @SerializedName("\$updatedAt") @@ -55,6 +41,13 @@ data class File( @SerializedName("\$permissions") val permissions: List, + /** + * File name. + * + */ + @SerializedName("name") + val name: String, + /** * File MD5 signature. * @@ -95,10 +88,9 @@ data class File( fun from(map: Map) = File( id = map["\$id"] as String, bucketId = map["bucketId"] as String, - createdAt = (map["\$createdAt"] as Number).toLong(), - updatedAt = (map["\$updatedAt"] as Number).toLong(), - read = map["\$read"] as List, - write = map["\$write"] as List, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, + permissions = map["\$permissions"] as List, name = map["name"] as String, signature = map["signature"] as String, mimeType = map["mimeType"] as String, @@ -113,8 +105,7 @@ data class File( "bucketId" to bucketId as Any, "\$createdAt" to createdAt as Any, "\$updatedAt" to updatedAt as Any, - "\$read" to read as Any, - "\$write" to write as Any, + "\$permissions" to permissions as Any, "name" to name as Any, "signature" to signature as Any, "mimeType" to mimeType as Any, diff --git a/library/src/main/java/io/appwrite/models/Log.kt b/library/src/main/java/io/appwrite/models/Log.kt index 7d7dcdf..2343352 100644 --- a/library/src/main/java/io/appwrite/models/Log.kt +++ b/library/src/main/java/io/appwrite/models/Log.kt @@ -49,7 +49,7 @@ data class Log( val ip: String, /** - * Log creation date in Datetime. + * Log creation date in ISO 8601 format. * */ @SerializedName("time") diff --git a/library/src/main/java/io/appwrite/models/Membership.kt b/library/src/main/java/io/appwrite/models/Membership.kt index b9e3a60..a923fea 100644 --- a/library/src/main/java/io/appwrite/models/Membership.kt +++ b/library/src/main/java/io/appwrite/models/Membership.kt @@ -14,18 +14,18 @@ data class Membership( val id: String, /** - * Membership creation date in Unix timestamp. + * Membership creation date in ISO 8601 format. * */ @SerializedName("\$createdAt") - val createdAt: Long, + val createdAt: String, /** - * Membership update date in Unix timestamp. + * Membership update date in ISO 8601 format. * */ @SerializedName("\$updatedAt") - val updatedAt: Long, + val updatedAt: String, /** * User ID. @@ -63,14 +63,14 @@ data class Membership( val teamName: String, /** - * Date, the user has been invited to join the team in Datetime + * 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 Datetime + * Date, the user has accepted the invitation to join the team in ISO 8601 format. * */ @SerializedName("joined") @@ -94,8 +94,8 @@ data class Membership( @Suppress("UNCHECKED_CAST") fun from(map: Map) = Membership( id = map["\$id"] as String, - createdAt = (map["\$createdAt"] as Number).toLong(), - updatedAt = (map["\$updatedAt"] as Number).toLong(), + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, userId = map["userId"] as String, userName = map["userName"] as String, userEmail = map["userEmail"] as String, diff --git a/library/src/main/java/io/appwrite/models/Session.kt b/library/src/main/java/io/appwrite/models/Session.kt index 54ca106..3510640 100644 --- a/library/src/main/java/io/appwrite/models/Session.kt +++ b/library/src/main/java/io/appwrite/models/Session.kt @@ -14,11 +14,11 @@ data class Session( val id: String, /** - * Session creation date in Unix timestamp. + * Session creation date in ISO 8601 format. * */ @SerializedName("\$createdAt") - val createdAt: Long, + val createdAt: String, /** * User ID. @@ -28,7 +28,7 @@ data class Session( val userId: String, /** - * Session expiration date in Datetime + * Session expiration date in ISO 8601 format. * */ @SerializedName("expire") @@ -56,7 +56,7 @@ data class Session( val providerAccessToken: String, /** - * The date of when the access token expires in Datetime format. + * The date of when the access token expires in ISO 8601 format. * */ @SerializedName("providerAccessTokenExpiry") @@ -185,7 +185,7 @@ data class Session( @Suppress("UNCHECKED_CAST") fun from(map: Map) = Session( id = map["\$id"] as String, - createdAt = (map["\$createdAt"] as Number).toLong(), + createdAt = map["\$createdAt"] as String, userId = map["userId"] as String, expire = map["expire"] as String, provider = map["provider"] as String, diff --git a/library/src/main/java/io/appwrite/models/Team.kt b/library/src/main/java/io/appwrite/models/Team.kt index 4a5dbcd..c3b038f 100644 --- a/library/src/main/java/io/appwrite/models/Team.kt +++ b/library/src/main/java/io/appwrite/models/Team.kt @@ -14,18 +14,18 @@ data class Team( val id: String, /** - * Team creation date in Unix timestamp. + * Team creation date in ISO 8601 format. * */ @SerializedName("\$createdAt") - val createdAt: Long, + val createdAt: String, /** - * Team update date in Unix timestamp. + * Team update date in ISO 8601 format. * */ @SerializedName("\$updatedAt") - val updatedAt: Long, + val updatedAt: String, /** * Team name. @@ -45,8 +45,8 @@ data class Team( @Suppress("UNCHECKED_CAST") fun from(map: Map) = Team( id = map["\$id"] as String, - createdAt = (map["\$createdAt"] as Number).toLong(), - updatedAt = (map["\$updatedAt"] as Number).toLong(), + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, name = map["name"] as String, total = (map["total"] as Number).toLong() ) diff --git a/library/src/main/java/io/appwrite/models/Token.kt b/library/src/main/java/io/appwrite/models/Token.kt index 485cdeb..2587776 100644 --- a/library/src/main/java/io/appwrite/models/Token.kt +++ b/library/src/main/java/io/appwrite/models/Token.kt @@ -14,11 +14,11 @@ data class Token( val id: String, /** - * Token creation date in Unix timestamp. + * Token creation date in ISO 8601 format. * */ @SerializedName("\$createdAt") - val createdAt: Long, + val createdAt: String, /** * User ID. @@ -35,7 +35,7 @@ data class Token( val secret: String, /** - * Token expiration date in Datetime. + * Token expiration date in ISO 8601 format. * */ @SerializedName("expire") @@ -45,7 +45,7 @@ data class Token( @Suppress("UNCHECKED_CAST") fun from(map: Map) = Token( id = map["\$id"] as String, - createdAt = (map["\$createdAt"] as Number).toLong(), + createdAt = map["\$createdAt"] as String, userId = map["userId"] as String, secret = map["secret"] as String, expire = map["expire"] as String diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 0156896..02fd660 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -313,45 +313,6 @@ class Account : Service { ) } - /** - * Update Account Phone - * - * Update currently logged in user account phone number. After changing phone - * number, the user confirmation status will get reset. A new confirmation SMS - * is not sent automatically however you can use the phone confirmation - * endpoint again to send the confirmation SMS. - * - * @param number 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.User] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun updatePhone( - number: String, - password: String - ): io.appwrite.models.User { - val path = "/account/phone" - val params = mutableMapOf( - "number" to number, - "password" to password - ) - val headers = mutableMapOf( - "content-type" to "application/json" - ) - val converter: (Map) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it) - } - return client.call( - "PATCH", - path, - headers, - params, - responseType = io.appwrite.models.User::class.java, - converter, - ) - } - /** * Get Account Preferences * @@ -747,7 +708,7 @@ class Account : Service { * user.. * * - * @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, bitbucket, bitly, box, dailymotion, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, notion, okta, paypal, paypalSandbox, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoom. + * @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. @@ -816,26 +777,27 @@ class Account : Service { /** * Create Phone session * - * Sends the user a SMS with a secret key for creating a session. Use the - * returned user ID and the secret to submit a request to the [PUT + * 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. * * @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 number Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @return [io.appwrite.models.Token] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun createPhoneSession( userId: String, - number: String + phone: String ): io.appwrite.models.Token { val path = "/account/sessions/phone" val params = mutableMapOf( "userId" to userId, - "number" to number + "phone" to phone ) val headers = mutableMapOf( "content-type" to "application/json" @@ -854,19 +816,13 @@ class Account : Service { } /** - * Create Phone session (confirmation) + * Create Phone 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 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. @@ -1117,13 +1073,12 @@ class Account : Service { /** * Create Phone Verification * - * Use this endpoint to send a verification message to your user's phone - * number to confirm they are the valid owners of that address. The provided - * secret should allow you to complete the verification process by verifying - * both the **userId** and **secret** parameters. Learn more about how to - * [complete the 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 link sent to the user's phone number is valid for 15 minutes. + * verification code sent to the user's phone number is valid for 15 minutes. * * @return [io.appwrite.models.Token] */ diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index 2a63485..65f1ead 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -10,23 +10,19 @@ import java.io.File class Databases : Service { - val databaseId: String - - public constructor(client: Client, databaseId: String) : super(client) { - this.databaseId = databaseId - } + public constructor (client: Client) : super(client) { } /** * List Documents * - * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/database#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. - * @param limit Maximum number of documents to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursor ID of the document used as the starting point for the query, excluding the document itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursorDirection Direction of the cursor, can be either 'before' or 'after'. - * @param orderAttributes Array of attributes used to sort results. Maximum of 100 order attributes are allowed, each 4096 characters long. - * @param orderTypes Array of order directions for sorting attribtues. Possible values are DESC for descending order, or ASC for ascending order. Maximum of 100 order types are allowed. + * 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). + * + * @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 @@ -59,7 +55,13 @@ class Databases : Service { /** * Create Document * - * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). Make sure to define attributes before creating documents. + * 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 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). @@ -99,7 +101,11 @@ class Databases : Service { /** * Get Document * - * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). + * 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] */ @@ -132,6 +138,10 @@ class Databases : Service { /** * 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. @@ -145,8 +155,7 @@ class Databases : Service { collectionId: String, documentId: String, data: Any? = null, - read: List? = null, - write: List? = 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) val params = mutableMapOf( @@ -172,7 +181,10 @@ class Databases : Service { /** * Delete Document * - * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). + * Delete a document by its unique ID. + * + * @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] */ diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index f49f7bd..1c50538 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -53,8 +53,6 @@ class Functions : Service { * @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, time * @param search Search term to filter your list results. Max length: 256 chars. - * @param cursor ID of the execution used as the starting point for the query, excluding the execution itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursorDirection Direction of the cursor, can be either 'before' or 'after'. * @return [io.appwrite.models.ExecutionList] */ @JvmOverloads diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index 6c6e02b..053e0e6 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -24,11 +24,6 @@ class Storage : Service { * @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. - * @param limit Maximum number of files to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursor ID of the file used as the starting point for the query, excluding the file itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursorDirection Direction of the cursor, can be either 'before' or 'after'. - * @param orderType Order result by ASC or DESC order. * @return [io.appwrite.models.FileList] */ @JvmOverloads @@ -93,8 +88,7 @@ class Storage : Service { bucketId: String, fileId: String, file: InputFile, - read: List? = null, - write: List? = null, onProgress: ((UploadProgress) -> Unit)? = null + permissions: List? = null, onProgress: ((UploadProgress) -> Unit)? = null ): io.appwrite.models.File { val path = "/storage/buckets/{bucketId}/files".replace("{bucketId}", bucketId) val params = mutableMapOf( diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 4092e96..46fe9d0 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -16,18 +16,13 @@ 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. - * + * 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). * * @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. - * @param limit Maximum number of teams to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursor ID of the team used as the starting point for the query, excluding the team itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursorDirection Direction of the cursor, can be either 'before' or 'after'. - * @param orderType Order result by ASC or DESC order. * @return [io.appwrite.models.TeamList] */ @JvmOverloads @@ -204,11 +199,6 @@ class Teams : Service { * @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. - * @param limit Maximum number of memberships to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursor ID of the membership used as the starting point for the query, excluding the membership itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursorDirection Direction of the cursor, can be either 'before' or 'after'. - * @param orderType Order result by ASC or DESC order. * @return [io.appwrite.models.MembershipList] */ @JvmOverloads From 962b8dabe79e961d20821c269ff295ad37717c8a Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Mon, 5 Sep 2022 20:35:25 +0400 Subject: [PATCH 040/118] feat: update for 1.0.0-RC1 --- README.md | 4 ++-- library/src/main/java/io/appwrite/Client.kt | 2 +- library/src/main/java/io/appwrite/services/Avatars.kt | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2aa502b..1f8968c 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:0.8.0-SNAPSHOT") +implementation("io.appwrite:sdk-for-android:1.0.0-SNAPSHOT") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 0.8.0-SNAPSHOT + 1.0.0-SNAPSHOT ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 761fbaa..4be5e78 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 "0.8.0-SNAPSHOT", + "x-sdk-version" to "1.0.0-SNAPSHOT", "x-appwrite-response-format" to "1.0.0-RC1" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt index bb75581..843f0ba 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -233,7 +233,6 @@ class Avatars : Service { * @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 color Changes text color. By default a random color will be picked and stay will persistent to the given name. * @param background Changes background color. By default a random color will be picked and stay will persistent to the given name. * @return [ByteArray] */ @@ -243,7 +242,6 @@ class Avatars : Service { name: String? = null, width: Long? = null, height: Long? = null, - color: String? = null, background: String? = null ): ByteArray { val path = "/avatars/initials" @@ -251,7 +249,6 @@ class Avatars : Service { "name" to name, "width" to width, "height" to height, - "color" to color, "background" to background, "project" to client.config["project"] ) From 84cd2a938e407afd2389c61764d526a55efa6c1d Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Tue, 6 Sep 2022 20:44:37 +0400 Subject: [PATCH 041/118] feat: update for 1.0.0-RC1 --- .../java/io/appwrite/models/RealtimeModels.kt | 2 +- .../main/java/io/appwrite/services/Account.kt | 16 ++++++++-------- .../main/java/io/appwrite/services/Avatars.kt | 2 +- .../main/java/io/appwrite/services/Databases.kt | 2 +- .../main/java/io/appwrite/services/Storage.kt | 2 +- .../src/main/java/io/appwrite/services/Teams.kt | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/library/src/main/java/io/appwrite/models/RealtimeModels.kt b/library/src/main/java/io/appwrite/models/RealtimeModels.kt index 9041554..bdd8752 100644 --- a/library/src/main/java/io/appwrite/models/RealtimeModels.kt +++ b/library/src/main/java/io/appwrite/models/RealtimeModels.kt @@ -23,7 +23,7 @@ open class RealtimeResponse( data class RealtimeResponseEvent( val events: Collection, val channels: Collection, - val timestamp: Long, + val timestamp: String, var payload: T ) diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 02fd660..97bcf42 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -55,7 +55,7 @@ class Account : Service { * 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 "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. @@ -282,7 +282,7 @@ class Account : Service { * /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 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] */ @@ -612,7 +612,7 @@ class Account : Service { * 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. + * @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 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] @@ -784,8 +784,8 @@ class Account : Service { * endpoint to complete the login process. The secret sent to the user's phone * is valid for 15 minutes. * - * @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 phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @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 phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @return [io.appwrite.models.Token] */ @JvmOverloads @@ -861,7 +861,7 @@ class Account : Service { * 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. + * @param sessionId Session ID. Use the string 'current' to get the current device session. * @return [io.appwrite.models.Session] */ @JvmOverloads @@ -895,7 +895,7 @@ class Account : Service { * 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. + * @param sessionId Session ID. Use the string 'current' to update the current device session. * @return [io.appwrite.models.Session] */ @JvmOverloads @@ -930,7 +930,7 @@ class Account : Service { * 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. + * @param sessionId Session ID. Use the string 'current' to delete the current device session. * @return [Any] */ @JvmOverloads diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt index 843f0ba..2853e59 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -270,7 +270,7 @@ class Avatars : Service { * @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. + * @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] */ @JvmOverloads diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index 65f1ead..350ec05 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -62,7 +62,7 @@ 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). 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 "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] diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index 053e0e6..0d22f47 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -77,7 +77,7 @@ class Storage : Service { * * * @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 "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] diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 46fe9d0..fe32c8f 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -59,7 +59,7 @@ class Teams : Service { * 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 "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] @@ -331,7 +331,7 @@ class Teams : Service { * * @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. + * @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] */ @JvmOverloads From 37a3256d0dd111f524d9d5f0ef28fb05eea77514 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 14 Sep 2022 22:45:57 +1200 Subject: [PATCH 042/118] Update for 1.0.0 --- README.md | 21 ++++---- docs/examples/java/account/list-logs.md | 47 ++++++++++++++++++ docs/examples/java/account/list-sessions.md | 46 ++++++++++++++++++ docs/examples/java/locale/list-continents.md | 46 ++++++++++++++++++ .../java/locale/list-countries-e-u.md | 46 ++++++++++++++++++ .../java/locale/list-countries-phones.md | 46 ++++++++++++++++++ docs/examples/java/locale/list-countries.md | 46 ++++++++++++++++++ docs/examples/java/locale/list-currencies.md | 46 ++++++++++++++++++ docs/examples/java/locale/list-languages.md | 46 ++++++++++++++++++ docs/examples/java/teams/list-memberships.md | 48 +++++++++++++++++++ docs/examples/kotlin/account/list-logs.md | 25 ++++++++++ docs/examples/kotlin/account/list-sessions.md | 24 ++++++++++ .../examples/kotlin/locale/list-continents.md | 24 ++++++++++ .../kotlin/locale/list-countries-e-u.md | 24 ++++++++++ .../kotlin/locale/list-countries-phones.md | 24 ++++++++++ docs/examples/kotlin/locale/list-countries.md | 24 ++++++++++ .../examples/kotlin/locale/list-currencies.md | 24 ++++++++++ docs/examples/kotlin/locale/list-languages.md | 24 ++++++++++ .../examples/kotlin/teams/list-memberships.md | 26 ++++++++++ library/src/main/java/io/appwrite/Client.kt | 4 +- library/src/main/java/io/appwrite/Role.kt | 41 +++++++++------- .../main/java/io/appwrite/models/Document.kt | 17 +++++-- .../main/java/io/appwrite/models/Execution.kt | 10 ++-- .../main/java/io/appwrite/services/Account.kt | 8 ++-- .../java/io/appwrite/services/Functions.kt | 4 +- .../main/java/io/appwrite/services/Locale.kt | 12 ++--- .../main/java/io/appwrite/services/Teams.kt | 4 +- 27 files changed, 706 insertions(+), 51 deletions(-) create mode 100644 docs/examples/java/account/list-logs.md create mode 100644 docs/examples/java/account/list-sessions.md create mode 100644 docs/examples/java/locale/list-continents.md create mode 100644 docs/examples/java/locale/list-countries-e-u.md create mode 100644 docs/examples/java/locale/list-countries-phones.md create mode 100644 docs/examples/java/locale/list-countries.md create mode 100644 docs/examples/java/locale/list-currencies.md create mode 100644 docs/examples/java/locale/list-languages.md create mode 100644 docs/examples/java/teams/list-memberships.md create mode 100644 docs/examples/kotlin/account/list-logs.md create mode 100644 docs/examples/kotlin/account/list-sessions.md create mode 100644 docs/examples/kotlin/locale/list-continents.md create mode 100644 docs/examples/kotlin/locale/list-countries-e-u.md create mode 100644 docs/examples/kotlin/locale/list-countries-phones.md create mode 100644 docs/examples/kotlin/locale/list-countries.md create mode 100644 docs/examples/kotlin/locale/list-currencies.md create mode 100644 docs/examples/kotlin/locale/list-languages.md create mode 100644 docs/examples/kotlin/teams/list-memberships.md diff --git a/README.md b/README.md index 1f8968c..f3ed730 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-RC1-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.0.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.0-RC1. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).** +**This SDK is compatible with Appwrite server version 1.0.0. 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.0.0-SNAPSHOT") +implementation("io.appwrite:sdk-for-android:1.0.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 1.0.0-SNAPSHOT + 1.0.0 ``` @@ -108,7 +108,7 @@ When trying to connect to Appwrite from an emulator or a mobile device, localhos // Register User val account = Account(client) val response = account.create( - "[USER_ID]", + ID.unique(), "email@example.com", "password" ) @@ -119,6 +119,7 @@ val response = account.create( ```kotlin import io.appwrite.Client import io.appwrite.services.Account +import io.appwrite.ID val client = Client(context) .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint @@ -126,8 +127,8 @@ val client = Client(context) .setSelfSigned(true) // Remove in production val account = Account(client) -val response = account.create( - "[USER_ID]", +val user = account.create( + ID.unique(), "email@example.com", "password" ) @@ -138,10 +139,10 @@ The Appwrite Android SDK raises an `AppwriteException` object with `message`, `c ```kotlin try { - var response = account.create("[USER_ID]", "email@example.com", "password") - Log.d("Appwrite response", response.body?.string()) + var user = account.create(ID.unique(), "email@example.com", "password") + Log.d("Appwrite user", user.toMap()) } catch(e : AppwriteException) { - Log.e("AppwriteException",e.message.toString()) + e.printStackTrace() } ``` diff --git a/docs/examples/java/account/list-logs.md b/docs/examples/java/account/list-logs.md new file mode 100644 index 0000000..f33c413 --- /dev/null +++ b/docs/examples/java/account/list-logs.md @@ -0,0 +1,47 @@ +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.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 diff --git a/docs/examples/java/account/list-sessions.md b/docs/examples/java/account/list-sessions.md new file mode 100644 index 0000000..5933f03 --- /dev/null +++ b/docs/examples/java/account/list-sessions.md @@ -0,0 +1,46 @@ +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.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()); + } + } + }); + } +} \ No newline at end of file diff --git a/docs/examples/java/locale/list-continents.md b/docs/examples/java/locale/list-continents.md new file mode 100644 index 0000000..970f066 --- /dev/null +++ b/docs/examples/java/locale/list-continents.md @@ -0,0 +1,46 @@ +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.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()); + } + } + }); + } +} \ No newline at end of file diff --git a/docs/examples/java/locale/list-countries-e-u.md b/docs/examples/java/locale/list-countries-e-u.md new file mode 100644 index 0000000..b2d0b29 --- /dev/null +++ b/docs/examples/java/locale/list-countries-e-u.md @@ -0,0 +1,46 @@ +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.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()); + } + } + }); + } +} \ No newline at end of file diff --git a/docs/examples/java/locale/list-countries-phones.md b/docs/examples/java/locale/list-countries-phones.md new file mode 100644 index 0000000..ed4d1f4 --- /dev/null +++ b/docs/examples/java/locale/list-countries-phones.md @@ -0,0 +1,46 @@ +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.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()); + } + } + }); + } +} \ No newline at end of file diff --git a/docs/examples/java/locale/list-countries.md b/docs/examples/java/locale/list-countries.md new file mode 100644 index 0000000..cb4000f --- /dev/null +++ b/docs/examples/java/locale/list-countries.md @@ -0,0 +1,46 @@ +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.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()); + } + } + }); + } +} \ No newline at end of file diff --git a/docs/examples/java/locale/list-currencies.md b/docs/examples/java/locale/list-currencies.md new file mode 100644 index 0000000..5423698 --- /dev/null +++ b/docs/examples/java/locale/list-currencies.md @@ -0,0 +1,46 @@ +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.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()); + } + } + }); + } +} \ No newline at end of file diff --git a/docs/examples/java/locale/list-languages.md b/docs/examples/java/locale/list-languages.md new file mode 100644 index 0000000..158c0e5 --- /dev/null +++ b/docs/examples/java/locale/list-languages.md @@ -0,0 +1,46 @@ +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.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()); + } + } + }); + } +} \ No newline at end of file diff --git a/docs/examples/java/teams/list-memberships.md b/docs/examples/java/teams/list-memberships.md new file mode 100644 index 0000000..c53493d --- /dev/null +++ b/docs/examples/java/teams/list-memberships.md @@ -0,0 +1,48 @@ +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.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 diff --git a/docs/examples/kotlin/account/list-logs.md b/docs/examples/kotlin/account/list-logs.md new file mode 100644 index 0000000..397906b --- /dev/null +++ b/docs/examples/kotlin/account/list-logs.md @@ -0,0 +1,25 @@ +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.listLogs( + ) + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/account/list-sessions.md b/docs/examples/kotlin/account/list-sessions.md new file mode 100644 index 0000000..0a0bc73 --- /dev/null +++ b/docs/examples/kotlin/account/list-sessions.md @@ -0,0 +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 + +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.listSessions() + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/locale/list-continents.md b/docs/examples/kotlin/locale/list-continents.md new file mode 100644 index 0000000..b582b40 --- /dev/null +++ b/docs/examples/kotlin/locale/list-continents.md @@ -0,0 +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.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.listContinents() + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/locale/list-countries-e-u.md b/docs/examples/kotlin/locale/list-countries-e-u.md new file mode 100644 index 0000000..133da97 --- /dev/null +++ b/docs/examples/kotlin/locale/list-countries-e-u.md @@ -0,0 +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.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.listCountriesEU() + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/locale/list-countries-phones.md b/docs/examples/kotlin/locale/list-countries-phones.md new file mode 100644 index 0000000..7f17f47 --- /dev/null +++ b/docs/examples/kotlin/locale/list-countries-phones.md @@ -0,0 +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.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.listCountriesPhones() + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/locale/list-countries.md b/docs/examples/kotlin/locale/list-countries.md new file mode 100644 index 0000000..1d83452 --- /dev/null +++ b/docs/examples/kotlin/locale/list-countries.md @@ -0,0 +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.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.listCountries() + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/locale/list-currencies.md b/docs/examples/kotlin/locale/list-currencies.md new file mode 100644 index 0000000..657652f --- /dev/null +++ b/docs/examples/kotlin/locale/list-currencies.md @@ -0,0 +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.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.listCurrencies() + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/locale/list-languages.md b/docs/examples/kotlin/locale/list-languages.md new file mode 100644 index 0000000..bdf023e --- /dev/null +++ b/docs/examples/kotlin/locale/list-languages.md @@ -0,0 +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.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.listLanguages() + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/teams/list-memberships.md b/docs/examples/kotlin/teams/list-memberships.md new file mode 100644 index 0000000..32ef3bd --- /dev/null +++ b/docs/examples/kotlin/teams/list-memberships.md @@ -0,0 +1,26 @@ +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.listMemberships( + teamId = "[TEAM_ID]", + ) + val json = response.body?.string() + } + } +} \ 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 4be5e78..2622bf7 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -88,8 +88,8 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "1.0.0-SNAPSHOT", - "x-appwrite-response-format" to "1.0.0-RC1" + "x-sdk-version" to "1.0.0", + "x-appwrite-response-format" to "1.0.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/Role.kt b/library/src/main/java/io/appwrite/Role.kt index 1764cc6..4ac6175 100644 --- a/library/src/main/java/io/appwrite/Role.kt +++ b/library/src/main/java/io/appwrite/Role.kt @@ -2,21 +2,30 @@ package io.appwrite class Role { companion object { - fun any(): String - = "any" - fun user(id: String): String - = "user:$id" - fun users(): String - = "users" - fun guests(): String - = "guests" - fun team(id: String, role: String = ""): String - = if(role.isEmpty()) { - "team:$id" - } else { - "team:$id/$role" - } - fun status(status: String): String - = "status:$status" + fun any(): String = "any" + + fun user(id: String, status: String = ""): String = if(status.isEmpty()) { + "user:$id" + } else { + "user:$id/$status" + } + + fun users(status: String = ""): String = if(status.isEmpty()) { + "users" + } else { + "users/$status" + } + + fun guests(): String = "guests" + + fun team(id: String, role: String = ""): String = if(role.isEmpty()) { + "team:$id" + } else { + "team:$id/$role" + } + + fun member(id: String): String = "member:$id" + + fun status(status: String): String = "status:$status" } } \ 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 d527f7c..a57214e 100644 --- a/library/src/main/java/io/appwrite/models/Document.kt +++ b/library/src/main/java/io/appwrite/models/Document.kt @@ -17,8 +17,15 @@ data class Document( * Collection ID. * */ - @SerializedName("\$collection") - val collection: String, + @SerializedName("\$collectionId") + val collectionId: String, + + /** + * Database ID. + * + */ + @SerializedName("\$databaseId") + val databaseId: String, /** * Document creation date in ISO 8601 format. @@ -47,7 +54,8 @@ data class Document( @Suppress("UNCHECKED_CAST") fun from(map: Map) = Document( id = map["\$id"] as String, - collection = map["\$collection"] 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, @@ -57,7 +65,8 @@ data class Document( fun toMap(): Map = mapOf( "\$id" to id as Any, - "\$collection" to collection as Any, + "\$collectionId" to collectionId as Any, + "\$databaseId" to databaseId as Any, "\$createdAt" to createdAt as Any, "\$updatedAt" to updatedAt as Any, "\$permissions" to permissions as Any, diff --git a/library/src/main/java/io/appwrite/models/Execution.kt b/library/src/main/java/io/appwrite/models/Execution.kt index 46495bf..b1179f5 100644 --- a/library/src/main/java/io/appwrite/models/Execution.kt +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -84,11 +84,11 @@ data class Execution( val stderr: String, /** - * The script execution time in seconds. + * The script execution duration in seconds. * */ - @SerializedName("time") - val time: Double + @SerializedName("duration") + val duration: Double ) { companion object { @Suppress("UNCHECKED_CAST") @@ -104,7 +104,7 @@ data class Execution( response = map["response"] as String, stdout = map["stdout"] as String, stderr = map["stderr"] as String, - time = (map["time"] as Number).toDouble() + duration = (map["duration"] as Number).toDouble() ) } @@ -120,6 +120,6 @@ data class Execution( "response" to response as Any, "stdout" to stdout as Any, "stderr" to stderr as Any, - "time" to time as Any + "duration" to duration 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 97bcf42..8241afa 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -169,7 +169,7 @@ class Account : Service { } /** - * Get Account Logs + * List Account 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. @@ -179,7 +179,7 @@ class Account : Service { */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getLogs( + suspend fun listLogs( queries: List? = null ): io.appwrite.models.LogList { val path = "/account/logs" @@ -471,7 +471,7 @@ class Account : Service { } /** - * Get Account Sessions + * List Account Sessions * * Get currently logged in user list of active sessions across different * devices. @@ -480,7 +480,7 @@ class Account : Service { */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getSessions(): io.appwrite.models.SessionList { + suspend fun listSessions(): io.appwrite.models.SessionList { val path = "/account/sessions" val params = mutableMapOf( ) diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index 1c50538..adb5c7a 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -51,7 +51,7 @@ class Functions : Service { * different API modes](/docs/admin). * * @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, time + * @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] */ @@ -93,7 +93,7 @@ class Functions : Service { * * @param functionId Function ID. * @param data String of custom data to send to function. - * @param async Execute code asynchronously. Default value is true. + * @param async Execute code in the background. Default value is false. * @return [io.appwrite.models.Execution] */ @JvmOverloads diff --git a/library/src/main/java/io/appwrite/services/Locale.kt b/library/src/main/java/io/appwrite/services/Locale.kt index b4ff685..feb3dec 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -56,7 +56,7 @@ class Locale : Service { */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getContinents(): io.appwrite.models.ContinentList { + suspend fun listContinents(): io.appwrite.models.ContinentList { val path = "/locale/continents" val params = mutableMapOf( ) @@ -86,7 +86,7 @@ class Locale : Service { */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getCountries(): io.appwrite.models.CountryList { + suspend fun listCountries(): io.appwrite.models.CountryList { val path = "/locale/countries" val params = mutableMapOf( ) @@ -116,7 +116,7 @@ class Locale : Service { */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getCountriesEU(): io.appwrite.models.CountryList { + suspend fun listCountriesEU(): io.appwrite.models.CountryList { val path = "/locale/countries/eu" val params = mutableMapOf( ) @@ -146,7 +146,7 @@ class Locale : Service { */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getCountriesPhones(): io.appwrite.models.PhoneList { + suspend fun listCountriesPhones(): io.appwrite.models.PhoneList { val path = "/locale/countries/phones" val params = mutableMapOf( ) @@ -177,7 +177,7 @@ class Locale : Service { */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getCurrencies(): io.appwrite.models.CurrencyList { + suspend fun listCurrencies(): io.appwrite.models.CurrencyList { val path = "/locale/currencies" val params = mutableMapOf( ) @@ -207,7 +207,7 @@ class Locale : Service { */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getLanguages(): io.appwrite.models.LanguageList { + suspend fun listLanguages(): io.appwrite.models.LanguageList { val path = "/locale/languages" val params = mutableMapOf( ) diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index fe32c8f..de74fb7 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -191,7 +191,7 @@ class Teams : Service { } /** - * Get Team Memberships + * 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. @@ -203,7 +203,7 @@ class Teams : Service { */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getMemberships( + suspend fun listMemberships( teamId: String, queries: List? = null, search: String? = null From 1fb7c57fe6585116d787668ebc3df382675709a1 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 22 Sep 2022 08:55:36 +0530 Subject: [PATCH 043/118] chore: update role helper class --- README.md | 21 ++++---- docs/examples/java/account/list-logs.md | 47 ++++++++++++++++++ docs/examples/java/account/list-sessions.md | 46 ++++++++++++++++++ docs/examples/java/locale/list-continents.md | 46 ++++++++++++++++++ .../java/locale/list-countries-e-u.md | 46 ++++++++++++++++++ .../java/locale/list-countries-phones.md | 46 ++++++++++++++++++ docs/examples/java/locale/list-countries.md | 46 ++++++++++++++++++ docs/examples/java/locale/list-currencies.md | 46 ++++++++++++++++++ docs/examples/java/locale/list-languages.md | 46 ++++++++++++++++++ docs/examples/java/teams/list-memberships.md | 48 +++++++++++++++++++ docs/examples/kotlin/account/list-logs.md | 25 ++++++++++ docs/examples/kotlin/account/list-sessions.md | 24 ++++++++++ .../examples/kotlin/locale/list-continents.md | 24 ++++++++++ .../kotlin/locale/list-countries-e-u.md | 24 ++++++++++ .../kotlin/locale/list-countries-phones.md | 24 ++++++++++ docs/examples/kotlin/locale/list-countries.md | 24 ++++++++++ .../examples/kotlin/locale/list-currencies.md | 24 ++++++++++ docs/examples/kotlin/locale/list-languages.md | 24 ++++++++++ .../examples/kotlin/teams/list-memberships.md | 26 ++++++++++ library/src/main/java/io/appwrite/Client.kt | 4 +- library/src/main/java/io/appwrite/Role.kt | 39 ++++++++------- .../main/java/io/appwrite/models/Document.kt | 17 +++++-- .../main/java/io/appwrite/models/Execution.kt | 10 ++-- .../main/java/io/appwrite/services/Account.kt | 8 ++-- .../java/io/appwrite/services/Functions.kt | 4 +- .../main/java/io/appwrite/services/Locale.kt | 12 ++--- .../main/java/io/appwrite/services/Teams.kt | 4 +- 27 files changed, 704 insertions(+), 51 deletions(-) create mode 100644 docs/examples/java/account/list-logs.md create mode 100644 docs/examples/java/account/list-sessions.md create mode 100644 docs/examples/java/locale/list-continents.md create mode 100644 docs/examples/java/locale/list-countries-e-u.md create mode 100644 docs/examples/java/locale/list-countries-phones.md create mode 100644 docs/examples/java/locale/list-countries.md create mode 100644 docs/examples/java/locale/list-currencies.md create mode 100644 docs/examples/java/locale/list-languages.md create mode 100644 docs/examples/java/teams/list-memberships.md create mode 100644 docs/examples/kotlin/account/list-logs.md create mode 100644 docs/examples/kotlin/account/list-sessions.md create mode 100644 docs/examples/kotlin/locale/list-continents.md create mode 100644 docs/examples/kotlin/locale/list-countries-e-u.md create mode 100644 docs/examples/kotlin/locale/list-countries-phones.md create mode 100644 docs/examples/kotlin/locale/list-countries.md create mode 100644 docs/examples/kotlin/locale/list-currencies.md create mode 100644 docs/examples/kotlin/locale/list-languages.md create mode 100644 docs/examples/kotlin/teams/list-memberships.md diff --git a/README.md b/README.md index 1f8968c..cfff7f9 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-RC1-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.0.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.0-RC1. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).** +**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).** 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.0.0-SNAPSHOT") +implementation("io.appwrite:sdk-for-android:1.0.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 1.0.0-SNAPSHOT + 1.0.0 ``` @@ -108,7 +108,7 @@ When trying to connect to Appwrite from an emulator or a mobile device, localhos // Register User val account = Account(client) val response = account.create( - "[USER_ID]", + ID.unique(), "email@example.com", "password" ) @@ -119,6 +119,7 @@ val response = account.create( ```kotlin import io.appwrite.Client import io.appwrite.services.Account +import io.appwrite.ID val client = Client(context) .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint @@ -126,8 +127,8 @@ val client = Client(context) .setSelfSigned(true) // Remove in production val account = Account(client) -val response = account.create( - "[USER_ID]", +val user = account.create( + ID.unique(), "email@example.com", "password" ) @@ -138,10 +139,10 @@ The Appwrite Android SDK raises an `AppwriteException` object with `message`, `c ```kotlin try { - var response = account.create("[USER_ID]", "email@example.com", "password") - Log.d("Appwrite response", response.body?.string()) + var user = account.create(ID.unique(), "email@example.com", "password") + Log.d("Appwrite user", user.toMap()) } catch(e : AppwriteException) { - Log.e("AppwriteException",e.message.toString()) + e.printStackTrace() } ``` diff --git a/docs/examples/java/account/list-logs.md b/docs/examples/java/account/list-logs.md new file mode 100644 index 0000000..f33c413 --- /dev/null +++ b/docs/examples/java/account/list-logs.md @@ -0,0 +1,47 @@ +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.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 diff --git a/docs/examples/java/account/list-sessions.md b/docs/examples/java/account/list-sessions.md new file mode 100644 index 0000000..5933f03 --- /dev/null +++ b/docs/examples/java/account/list-sessions.md @@ -0,0 +1,46 @@ +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.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()); + } + } + }); + } +} \ No newline at end of file diff --git a/docs/examples/java/locale/list-continents.md b/docs/examples/java/locale/list-continents.md new file mode 100644 index 0000000..970f066 --- /dev/null +++ b/docs/examples/java/locale/list-continents.md @@ -0,0 +1,46 @@ +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.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()); + } + } + }); + } +} \ No newline at end of file diff --git a/docs/examples/java/locale/list-countries-e-u.md b/docs/examples/java/locale/list-countries-e-u.md new file mode 100644 index 0000000..b2d0b29 --- /dev/null +++ b/docs/examples/java/locale/list-countries-e-u.md @@ -0,0 +1,46 @@ +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.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()); + } + } + }); + } +} \ No newline at end of file diff --git a/docs/examples/java/locale/list-countries-phones.md b/docs/examples/java/locale/list-countries-phones.md new file mode 100644 index 0000000..ed4d1f4 --- /dev/null +++ b/docs/examples/java/locale/list-countries-phones.md @@ -0,0 +1,46 @@ +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.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()); + } + } + }); + } +} \ No newline at end of file diff --git a/docs/examples/java/locale/list-countries.md b/docs/examples/java/locale/list-countries.md new file mode 100644 index 0000000..cb4000f --- /dev/null +++ b/docs/examples/java/locale/list-countries.md @@ -0,0 +1,46 @@ +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.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()); + } + } + }); + } +} \ No newline at end of file diff --git a/docs/examples/java/locale/list-currencies.md b/docs/examples/java/locale/list-currencies.md new file mode 100644 index 0000000..5423698 --- /dev/null +++ b/docs/examples/java/locale/list-currencies.md @@ -0,0 +1,46 @@ +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.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()); + } + } + }); + } +} \ No newline at end of file diff --git a/docs/examples/java/locale/list-languages.md b/docs/examples/java/locale/list-languages.md new file mode 100644 index 0000000..158c0e5 --- /dev/null +++ b/docs/examples/java/locale/list-languages.md @@ -0,0 +1,46 @@ +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.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()); + } + } + }); + } +} \ No newline at end of file diff --git a/docs/examples/java/teams/list-memberships.md b/docs/examples/java/teams/list-memberships.md new file mode 100644 index 0000000..c53493d --- /dev/null +++ b/docs/examples/java/teams/list-memberships.md @@ -0,0 +1,48 @@ +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.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 diff --git a/docs/examples/kotlin/account/list-logs.md b/docs/examples/kotlin/account/list-logs.md new file mode 100644 index 0000000..397906b --- /dev/null +++ b/docs/examples/kotlin/account/list-logs.md @@ -0,0 +1,25 @@ +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.listLogs( + ) + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/account/list-sessions.md b/docs/examples/kotlin/account/list-sessions.md new file mode 100644 index 0000000..0a0bc73 --- /dev/null +++ b/docs/examples/kotlin/account/list-sessions.md @@ -0,0 +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 + +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.listSessions() + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/locale/list-continents.md b/docs/examples/kotlin/locale/list-continents.md new file mode 100644 index 0000000..b582b40 --- /dev/null +++ b/docs/examples/kotlin/locale/list-continents.md @@ -0,0 +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.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.listContinents() + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/locale/list-countries-e-u.md b/docs/examples/kotlin/locale/list-countries-e-u.md new file mode 100644 index 0000000..133da97 --- /dev/null +++ b/docs/examples/kotlin/locale/list-countries-e-u.md @@ -0,0 +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.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.listCountriesEU() + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/locale/list-countries-phones.md b/docs/examples/kotlin/locale/list-countries-phones.md new file mode 100644 index 0000000..7f17f47 --- /dev/null +++ b/docs/examples/kotlin/locale/list-countries-phones.md @@ -0,0 +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.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.listCountriesPhones() + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/locale/list-countries.md b/docs/examples/kotlin/locale/list-countries.md new file mode 100644 index 0000000..1d83452 --- /dev/null +++ b/docs/examples/kotlin/locale/list-countries.md @@ -0,0 +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.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.listCountries() + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/locale/list-currencies.md b/docs/examples/kotlin/locale/list-currencies.md new file mode 100644 index 0000000..657652f --- /dev/null +++ b/docs/examples/kotlin/locale/list-currencies.md @@ -0,0 +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.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.listCurrencies() + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/locale/list-languages.md b/docs/examples/kotlin/locale/list-languages.md new file mode 100644 index 0000000..bdf023e --- /dev/null +++ b/docs/examples/kotlin/locale/list-languages.md @@ -0,0 +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.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.listLanguages() + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/teams/list-memberships.md b/docs/examples/kotlin/teams/list-memberships.md new file mode 100644 index 0000000..32ef3bd --- /dev/null +++ b/docs/examples/kotlin/teams/list-memberships.md @@ -0,0 +1,26 @@ +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.listMemberships( + teamId = "[TEAM_ID]", + ) + val json = response.body?.string() + } + } +} \ 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 4be5e78..2622bf7 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -88,8 +88,8 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "1.0.0-SNAPSHOT", - "x-appwrite-response-format" to "1.0.0-RC1" + "x-sdk-version" to "1.0.0", + "x-appwrite-response-format" to "1.0.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/Role.kt b/library/src/main/java/io/appwrite/Role.kt index 1764cc6..d9ccbd2 100644 --- a/library/src/main/java/io/appwrite/Role.kt +++ b/library/src/main/java/io/appwrite/Role.kt @@ -2,21 +2,28 @@ package io.appwrite class Role { companion object { - fun any(): String - = "any" - fun user(id: String): String - = "user:$id" - fun users(): String - = "users" - fun guests(): String - = "guests" - fun team(id: String, role: String = ""): String - = if(role.isEmpty()) { - "team:$id" - } else { - "team:$id/$role" - } - fun status(status: String): String - = "status:$status" + fun any(): String = "any" + + fun user(id: String, status: String = ""): String = if(status.isEmpty()) { + "user:$id" + } else { + "user:$id/$status" + } + + fun users(status: String = ""): String = if(status.isEmpty()) { + "users" + } else { + "users/$status" + } + + fun guests(): String = "guests" + + fun team(id: String, role: String = ""): String = if(role.isEmpty()) { + "team:$id" + } else { + "team:$id/$role" + } + + fun member(id: String): String = "member:$id" } } \ 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 d527f7c..a57214e 100644 --- a/library/src/main/java/io/appwrite/models/Document.kt +++ b/library/src/main/java/io/appwrite/models/Document.kt @@ -17,8 +17,15 @@ data class Document( * Collection ID. * */ - @SerializedName("\$collection") - val collection: String, + @SerializedName("\$collectionId") + val collectionId: String, + + /** + * Database ID. + * + */ + @SerializedName("\$databaseId") + val databaseId: String, /** * Document creation date in ISO 8601 format. @@ -47,7 +54,8 @@ data class Document( @Suppress("UNCHECKED_CAST") fun from(map: Map) = Document( id = map["\$id"] as String, - collection = map["\$collection"] 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, @@ -57,7 +65,8 @@ data class Document( fun toMap(): Map = mapOf( "\$id" to id as Any, - "\$collection" to collection as Any, + "\$collectionId" to collectionId as Any, + "\$databaseId" to databaseId as Any, "\$createdAt" to createdAt as Any, "\$updatedAt" to updatedAt as Any, "\$permissions" to permissions as Any, diff --git a/library/src/main/java/io/appwrite/models/Execution.kt b/library/src/main/java/io/appwrite/models/Execution.kt index 46495bf..b1179f5 100644 --- a/library/src/main/java/io/appwrite/models/Execution.kt +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -84,11 +84,11 @@ data class Execution( val stderr: String, /** - * The script execution time in seconds. + * The script execution duration in seconds. * */ - @SerializedName("time") - val time: Double + @SerializedName("duration") + val duration: Double ) { companion object { @Suppress("UNCHECKED_CAST") @@ -104,7 +104,7 @@ data class Execution( response = map["response"] as String, stdout = map["stdout"] as String, stderr = map["stderr"] as String, - time = (map["time"] as Number).toDouble() + duration = (map["duration"] as Number).toDouble() ) } @@ -120,6 +120,6 @@ data class Execution( "response" to response as Any, "stdout" to stdout as Any, "stderr" to stderr as Any, - "time" to time as Any + "duration" to duration 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 97bcf42..8241afa 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -169,7 +169,7 @@ class Account : Service { } /** - * Get Account Logs + * List Account 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. @@ -179,7 +179,7 @@ class Account : Service { */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getLogs( + suspend fun listLogs( queries: List? = null ): io.appwrite.models.LogList { val path = "/account/logs" @@ -471,7 +471,7 @@ class Account : Service { } /** - * Get Account Sessions + * List Account Sessions * * Get currently logged in user list of active sessions across different * devices. @@ -480,7 +480,7 @@ class Account : Service { */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getSessions(): io.appwrite.models.SessionList { + suspend fun listSessions(): io.appwrite.models.SessionList { val path = "/account/sessions" val params = mutableMapOf( ) diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index 1c50538..adb5c7a 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -51,7 +51,7 @@ class Functions : Service { * different API modes](/docs/admin). * * @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, time + * @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] */ @@ -93,7 +93,7 @@ class Functions : Service { * * @param functionId Function ID. * @param data String of custom data to send to function. - * @param async Execute code asynchronously. Default value is true. + * @param async Execute code in the background. Default value is false. * @return [io.appwrite.models.Execution] */ @JvmOverloads diff --git a/library/src/main/java/io/appwrite/services/Locale.kt b/library/src/main/java/io/appwrite/services/Locale.kt index b4ff685..feb3dec 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -56,7 +56,7 @@ class Locale : Service { */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getContinents(): io.appwrite.models.ContinentList { + suspend fun listContinents(): io.appwrite.models.ContinentList { val path = "/locale/continents" val params = mutableMapOf( ) @@ -86,7 +86,7 @@ class Locale : Service { */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getCountries(): io.appwrite.models.CountryList { + suspend fun listCountries(): io.appwrite.models.CountryList { val path = "/locale/countries" val params = mutableMapOf( ) @@ -116,7 +116,7 @@ class Locale : Service { */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getCountriesEU(): io.appwrite.models.CountryList { + suspend fun listCountriesEU(): io.appwrite.models.CountryList { val path = "/locale/countries/eu" val params = mutableMapOf( ) @@ -146,7 +146,7 @@ class Locale : Service { */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getCountriesPhones(): io.appwrite.models.PhoneList { + suspend fun listCountriesPhones(): io.appwrite.models.PhoneList { val path = "/locale/countries/phones" val params = mutableMapOf( ) @@ -177,7 +177,7 @@ class Locale : Service { */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getCurrencies(): io.appwrite.models.CurrencyList { + suspend fun listCurrencies(): io.appwrite.models.CurrencyList { val path = "/locale/currencies" val params = mutableMapOf( ) @@ -207,7 +207,7 @@ class Locale : Service { */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getLanguages(): io.appwrite.models.LanguageList { + suspend fun listLanguages(): io.appwrite.models.LanguageList { val path = "/locale/languages" val params = mutableMapOf( ) diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index fe32c8f..de74fb7 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -191,7 +191,7 @@ class Teams : Service { } /** - * Get Team Memberships + * 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. @@ -203,7 +203,7 @@ class Teams : Service { */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getMemberships( + suspend fun listMemberships( teamId: String, queries: List? = null, search: String? = null From 0c87b2eb6e6533229052bfd54a540e0d4eb8f4a9 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 22 Sep 2022 09:45:22 +0530 Subject: [PATCH 044/118] chore: update sdk versions --- README.md | 4 ++-- library/src/main/java/io/appwrite/Client.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cfff7f9..83edb8a 100644 --- a/README.md +++ b/README.md @@ -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.0.0") +implementation("io.appwrite:sdk-for-android:1.1.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 1.0.0 + 1.1.0 ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 2622bf7..7faa46d 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.0.0", + "x-sdk-version" to "1.1.0", "x-appwrite-response-format" to "1.0.0" ) config = mutableMapOf() From 5dbe73c9f663b895b151390cab2b4da3f4feb5db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 27 Dec 2022 21:01:59 +0100 Subject: [PATCH 045/118] Appwrite 1.2.0 support --- LICENSE.md | 2 +- README.md | 8 +- build.gradle | 4 +- .../java/account/create-anonymous-session.md | 56 +- .../java/account/create-email-session.md | 63 +- docs/examples/java/account/create-j-w-t.md | 56 +- .../account/create-magic-u-r-l-session.md | 63 +- .../java/account/create-o-auth2session.md | 59 +- .../java/account/create-phone-session.md | 63 +- .../java/account/create-phone-verification.md | 56 +- docs/examples/java/account/create-recovery.md | 63 +- .../java/account/create-verification.md | 61 +- docs/examples/java/account/create.md | 65 +- docs/examples/java/account/delete-session.md | 61 +- docs/examples/java/account/delete-sessions.md | 56 +- docs/examples/java/account/get-logs.md | 47 - docs/examples/java/account/get-prefs.md | 56 +- docs/examples/java/account/get-session.md | 61 +- docs/examples/java/account/get-sessions.md | 46 - docs/examples/java/account/get.md | 56 +- docs/examples/java/account/list-logs.md | 59 +- docs/examples/java/account/list-sessions.md | 56 +- docs/examples/java/account/update-email.md | 63 +- .../account/update-magic-u-r-l-session.md | 63 +- docs/examples/java/account/update-name.md | 61 +- docs/examples/java/account/update-password.md | 61 +- .../java/account/update-phone-session.md | 63 +- .../java/account/update-phone-verification.md | 63 +- docs/examples/java/account/update-phone.md | 63 +- docs/examples/java/account/update-prefs.md | 61 +- docs/examples/java/account/update-recovery.md | 67 +- docs/examples/java/account/update-session.md | 61 +- docs/examples/java/account/update-status.md | 56 +- .../java/account/update-verification.md | 63 +- docs/examples/java/avatars/get-browser.md | 61 +- docs/examples/java/avatars/get-credit-card.md | 61 +- docs/examples/java/avatars/get-favicon.md | 61 +- docs/examples/java/avatars/get-flag.md | 61 +- docs/examples/java/avatars/get-image.md | 61 +- docs/examples/java/avatars/get-initials.md | 59 +- docs/examples/java/avatars/get-q-r.md | 61 +- .../java/databases/create-document.md | 67 +- .../java/databases/delete-document.md | 65 +- docs/examples/java/databases/get-document.md | 65 +- .../examples/java/databases/list-documents.md | 63 +- .../java/databases/update-document.md | 65 +- .../java/functions/create-execution.md | 61 +- docs/examples/java/functions/get-execution.md | 63 +- .../java/functions/list-executions.md | 61 +- docs/examples/java/functions/retry-build.md | 50 - docs/examples/java/graphql/mutation.md | 21 + docs/examples/java/graphql/query.md | 21 + docs/examples/java/locale/get-continents.md | 46 - .../examples/java/locale/get-countries-e-u.md | 46 - .../java/locale/get-countries-phones.md | 46 - docs/examples/java/locale/get-countries.md | 46 - docs/examples/java/locale/get-currencies.md | 46 - docs/examples/java/locale/get-languages.md | 46 - docs/examples/java/locale/get.md | 56 +- docs/examples/java/locale/list-continents.md | 56 +- .../java/locale/list-countries-e-u.md | 56 +- .../java/locale/list-countries-phones.md | 56 +- docs/examples/java/locale/list-countries.md | 56 +- docs/examples/java/locale/list-currencies.md | 56 +- docs/examples/java/locale/list-languages.md | 56 +- docs/examples/java/storage/create-file.md | 67 +- docs/examples/java/storage/delete-file.md | 63 +- .../java/storage/get-file-download.md | 63 +- .../examples/java/storage/get-file-preview.md | 63 +- docs/examples/java/storage/get-file-view.md | 63 +- docs/examples/java/storage/get-file.md | 63 +- docs/examples/java/storage/list-files.md | 61 +- docs/examples/java/storage/update-file.md | 63 +- docs/examples/java/teams/create-membership.md | 67 +- docs/examples/java/teams/create.md | 63 +- docs/examples/java/teams/delete-membership.md | 63 +- docs/examples/java/teams/delete.md | 61 +- docs/examples/java/teams/get-membership.md | 63 +- docs/examples/java/teams/get-memberships.md | 48 - docs/examples/java/teams/get.md | 61 +- docs/examples/java/teams/list-memberships.md | 61 +- docs/examples/java/teams/list.md | 59 +- .../java/teams/update-membership-roles.md | 65 +- .../java/teams/update-membership-status.md | 67 +- docs/examples/java/teams/update.md | 63 +- .../account/create-anonymous-session.md | 24 +- .../kotlin/account/create-email-session.md | 30 +- docs/examples/kotlin/account/create-j-w-t.md | 24 +- .../account/create-magic-u-r-l-session.md | 30 +- .../kotlin/account/create-o-auth2session.md | 29 +- .../kotlin/account/create-phone-session.md | 30 +- .../account/create-phone-verification.md | 24 +- .../kotlin/account/create-recovery.md | 30 +- .../kotlin/account/create-verification.md | 28 +- docs/examples/kotlin/account/create.md | 32 +- .../examples/kotlin/account/delete-session.md | 28 +- .../kotlin/account/delete-sessions.md | 24 +- docs/examples/kotlin/account/get-logs.md | 25 - docs/examples/kotlin/account/get-prefs.md | 24 +- docs/examples/kotlin/account/get-session.md | 28 +- docs/examples/kotlin/account/get-sessions.md | 24 - docs/examples/kotlin/account/get.md | 24 +- docs/examples/kotlin/account/list-logs.md | 26 +- docs/examples/kotlin/account/list-sessions.md | 24 +- docs/examples/kotlin/account/update-email.md | 30 +- .../account/update-magic-u-r-l-session.md | 30 +- docs/examples/kotlin/account/update-name.md | 28 +- .../kotlin/account/update-password.md | 28 +- .../kotlin/account/update-phone-session.md | 30 +- .../account/update-phone-verification.md | 30 +- docs/examples/kotlin/account/update-phone.md | 30 +- docs/examples/kotlin/account/update-prefs.md | 28 +- .../kotlin/account/update-recovery.md | 34 +- .../examples/kotlin/account/update-session.md | 28 +- docs/examples/kotlin/account/update-status.md | 24 +- .../kotlin/account/update-verification.md | 30 +- docs/examples/kotlin/avatars/get-browser.md | 28 +- .../kotlin/avatars/get-credit-card.md | 28 +- docs/examples/kotlin/avatars/get-favicon.md | 28 +- docs/examples/kotlin/avatars/get-flag.md | 28 +- docs/examples/kotlin/avatars/get-image.md | 28 +- docs/examples/kotlin/avatars/get-initials.md | 26 +- docs/examples/kotlin/avatars/get-q-r.md | 28 +- .../kotlin/databases/create-document.md | 34 +- .../kotlin/databases/delete-document.md | 32 +- .../examples/kotlin/databases/get-document.md | 32 +- .../kotlin/databases/list-documents.md | 30 +- .../kotlin/databases/update-document.md | 32 +- .../kotlin/functions/create-execution.md | 28 +- .../kotlin/functions/get-execution.md | 30 +- .../kotlin/functions/list-executions.md | 28 +- docs/examples/kotlin/functions/retry-build.md | 28 - docs/examples/kotlin/graphql/mutation.md | 12 + docs/examples/kotlin/graphql/query.md | 12 + docs/examples/kotlin/locale/get-continents.md | 24 - .../kotlin/locale/get-countries-e-u.md | 24 - .../kotlin/locale/get-countries-phones.md | 24 - docs/examples/kotlin/locale/get-countries.md | 24 - docs/examples/kotlin/locale/get-currencies.md | 24 - docs/examples/kotlin/locale/get-languages.md | 24 - docs/examples/kotlin/locale/get.md | 24 +- .../examples/kotlin/locale/list-continents.md | 24 +- .../kotlin/locale/list-countries-e-u.md | 24 +- .../kotlin/locale/list-countries-phones.md | 24 +- docs/examples/kotlin/locale/list-countries.md | 24 +- .../examples/kotlin/locale/list-currencies.md | 24 +- docs/examples/kotlin/locale/list-languages.md | 24 +- docs/examples/kotlin/storage/create-file.md | 32 +- docs/examples/kotlin/storage/delete-file.md | 30 +- .../kotlin/storage/get-file-download.md | 30 +- .../kotlin/storage/get-file-preview.md | 30 +- docs/examples/kotlin/storage/get-file-view.md | 30 +- docs/examples/kotlin/storage/get-file.md | 30 +- docs/examples/kotlin/storage/list-files.md | 28 +- docs/examples/kotlin/storage/update-file.md | 30 +- .../kotlin/teams/create-membership.md | 34 +- docs/examples/kotlin/teams/create.md | 30 +- .../kotlin/teams/delete-membership.md | 30 +- docs/examples/kotlin/teams/delete.md | 28 +- docs/examples/kotlin/teams/get-membership.md | 30 +- docs/examples/kotlin/teams/get-memberships.md | 26 - docs/examples/kotlin/teams/get.md | 28 +- .../examples/kotlin/teams/list-memberships.md | 28 +- docs/examples/kotlin/teams/list.md | 26 +- .../kotlin/teams/update-membership-roles.md | 32 +- .../kotlin/teams/update-membership-status.md | 34 +- docs/examples/kotlin/teams/update.md | 30 +- .../appwrite/example_java/MainActivity.java | 47 +- .../android/ui/accounts/AccountsViewModel.kt | 2 +- library/build.gradle | 26 +- library/src/main/java/io/appwrite/Client.kt | 12 +- .../java/io/appwrite/coroutines/Callback.kt | 18 + .../io/appwrite/extensions/TypeExtensions.kt | 8 + .../main/java/io/appwrite/models/Account.kt | 83 +- .../main/java/io/appwrite/models/Continent.kt | 23 +- .../java/io/appwrite/models/ContinentList.kt | 23 +- .../main/java/io/appwrite/models/Country.kt | 23 +- .../java/io/appwrite/models/CountryList.kt | 23 +- .../main/java/io/appwrite/models/Currency.kt | 38 +- .../java/io/appwrite/models/CurrencyList.kt | 23 +- .../main/java/io/appwrite/models/Document.kt | 64 +- .../java/io/appwrite/models/DocumentList.kt | 36 +- .../main/java/io/appwrite/models/Execution.kt | 53 +- .../java/io/appwrite/models/ExecutionList.kt | 23 +- .../src/main/java/io/appwrite/models/File.kt | 50 +- .../main/java/io/appwrite/models/FileList.kt | 23 +- .../src/main/java/io/appwrite/models/Jwt.kt | 20 +- .../main/java/io/appwrite/models/Language.kt | 26 +- .../java/io/appwrite/models/LanguageList.kt | 23 +- .../main/java/io/appwrite/models/Locale.kt | 38 +- .../src/main/java/io/appwrite/models/Log.kt | 80 +- .../main/java/io/appwrite/models/LogList.kt | 23 +- .../java/io/appwrite/models/Membership.kt | 53 +- .../java/io/appwrite/models/MembershipList.kt | 23 +- .../src/main/java/io/appwrite/models/Phone.kt | 26 +- .../main/java/io/appwrite/models/PhoneList.kt | 23 +- .../java/io/appwrite/models/Preferences.kt | 34 +- .../main/java/io/appwrite/models/Session.kt | 92 +- .../java/io/appwrite/models/SessionList.kt | 23 +- .../src/main/java/io/appwrite/models/Team.kt | 32 +- .../main/java/io/appwrite/models/TeamList.kt | 23 +- .../src/main/java/io/appwrite/models/Token.kt | 32 +- .../main/java/io/appwrite/services/Account.kt | 1036 +++++++++-------- .../main/java/io/appwrite/services/Avatars.kt | 200 ++-- .../java/io/appwrite/services/Databases.kt | 290 +++-- .../java/io/appwrite/services/Functions.kt | 127 +- .../main/java/io/appwrite/services/Graphql.kt | 86 ++ .../main/java/io/appwrite/services/Locale.kt | 164 ++- .../main/java/io/appwrite/services/Storage.kt | 265 ++--- .../main/java/io/appwrite/services/Teams.kt | 346 +++--- 210 files changed, 3704 insertions(+), 7041 deletions(-) delete mode 100644 docs/examples/java/account/get-logs.md delete mode 100644 docs/examples/java/account/get-sessions.md delete mode 100644 docs/examples/java/functions/retry-build.md create mode 100644 docs/examples/java/graphql/mutation.md create mode 100644 docs/examples/java/graphql/query.md delete mode 100644 docs/examples/java/locale/get-continents.md delete mode 100644 docs/examples/java/locale/get-countries-e-u.md delete mode 100644 docs/examples/java/locale/get-countries-phones.md delete mode 100644 docs/examples/java/locale/get-countries.md delete mode 100644 docs/examples/java/locale/get-currencies.md delete mode 100644 docs/examples/java/locale/get-languages.md delete mode 100644 docs/examples/java/teams/get-memberships.md delete mode 100644 docs/examples/kotlin/account/get-logs.md delete mode 100644 docs/examples/kotlin/account/get-sessions.md delete mode 100644 docs/examples/kotlin/functions/retry-build.md create mode 100644 docs/examples/kotlin/graphql/mutation.md create mode 100644 docs/examples/kotlin/graphql/query.md delete mode 100644 docs/examples/kotlin/locale/get-continents.md delete mode 100644 docs/examples/kotlin/locale/get-countries-e-u.md delete mode 100644 docs/examples/kotlin/locale/get-countries-phones.md delete mode 100644 docs/examples/kotlin/locale/get-countries.md delete mode 100644 docs/examples/kotlin/locale/get-currencies.md delete mode 100644 docs/examples/kotlin/locale/get-languages.md delete mode 100644 docs/examples/kotlin/teams/get-memberships.md create mode 100644 library/src/main/java/io/appwrite/coroutines/Callback.kt create mode 100644 library/src/main/java/io/appwrite/extensions/TypeExtensions.kt create mode 100644 library/src/main/java/io/appwrite/services/Graphql.kt 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 From 57c57b48492a221795cca1ce5fd20f70e4a4a7e3 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 16 Feb 2023 08:10:07 +0000 Subject: [PATCH 046/118] Fix oauth2 issues --- LICENSE.md | 2 +- README.md | 6 +- library/src/main/java/io/appwrite/Client.kt | 2 +- .../main/java/io/appwrite/models/Locale.kt | 2 +- .../main/java/io/appwrite/services/Account.kt | 113 +++++++++--------- .../main/java/io/appwrite/services/Avatars.kt | 7 ++ .../java/io/appwrite/services/Databases.kt | 28 ++--- .../java/io/appwrite/services/Functions.kt | 12 +- .../main/java/io/appwrite/services/Graphql.kt | 8 +- .../main/java/io/appwrite/services/Locale.kt | 28 ++--- .../main/java/io/appwrite/services/Storage.kt | 25 ++-- .../main/java/io/appwrite/services/Teams.kt | 38 +++--- 12 files changed, 141 insertions(+), 130 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index 90528c4..47cfdfb 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2022 Appwrite (https://appwrite.io) and individual contributors. +Copyright (c) 2023 Appwrite (https://appwrite.io) and individual contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/README.md b/README.md index 35f4e57..20edee9 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![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.2.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.2.1-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) @@ -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.2.0") +implementation("io.appwrite:sdk-for-android:1.2.1") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 1.2.0 + 1.2.1 ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 0d87b5b..2f8623f 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.2.0", + "x-sdk-version" to "1.2.1", "x-appwrite-response-format" to "1.0.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/models/Locale.kt b/library/src/main/java/io/appwrite/models/Locale.kt index 4327545..abe4a0e 100644 --- a/library/src/main/java/io/appwrite/models/Locale.kt +++ b/library/src/main/java/io/appwrite/models/Locale.kt @@ -38,7 +38,7 @@ data class Locale( val continent: String, /** - * True if country is part of the Europian Union. + * True if country is part of the European Union. */ @SerializedName("eu") val eu: Boolean, diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 83d41fd..fec82f4 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -37,8 +37,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it as Map, nestedType) - } + io.appwrite.models.Account.from(map = it as Map, nestedType) + } return client.call( "GET", path, @@ -67,7 +67,7 @@ class Account : Service { * * 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 userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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. @@ -93,8 +93,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it as Map, nestedType) - } + io.appwrite.models.Account.from(map = it as Map, nestedType) + } return client.call( "POST", path, @@ -110,7 +110,7 @@ class Account : Service { * * 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 userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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. @@ -155,8 +155,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it as Map, nestedType) - } + io.appwrite.models.Account.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, @@ -203,8 +203,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Jwt = { - io.appwrite.models.Jwt.from(map = it as Map) - } + io.appwrite.models.Jwt.from(map = it as Map) + } return client.call( "POST", path, @@ -237,8 +237,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LogList = { - io.appwrite.models.LogList.from(map = it as Map) - } + io.appwrite.models.LogList.from(map = it as Map) + } return client.call( "GET", path, @@ -271,8 +271,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it as Map, nestedType) - } + io.appwrite.models.Account.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, @@ -324,8 +324,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it as Map, nestedType) - } + io.appwrite.models.Account.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, @@ -380,8 +380,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it as Map, nestedType) - } + io.appwrite.models.Account.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, @@ -429,8 +429,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { - io.appwrite.models.Preferences.from(map = it as Map, nestedType) - } + io.appwrite.models.Preferences.from(map = it as Map, nestedType) + } return client.call( "GET", path, @@ -475,8 +475,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it as Map, nestedType) - } + io.appwrite.models.Account.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, @@ -526,8 +526,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it as Map) - } + io.appwrite.models.Token.from(map = it as Map) + } return client.call( "POST", path, @@ -568,8 +568,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it as Map) - } + io.appwrite.models.Token.from(map = it as Map) + } return client.call( "PUT", path, @@ -598,8 +598,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.SessionList = { - io.appwrite.models.SessionList.from(map = it as Map) - } + io.appwrite.models.SessionList.from(map = it as Map) + } return client.call( "GET", path, @@ -654,8 +654,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { - io.appwrite.models.Session.from(map = it as Map) - } + io.appwrite.models.Session.from(map = it as Map) + } return client.call( "POST", path, @@ -690,8 +690,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { - io.appwrite.models.Session.from(map = it as Map) - } + io.appwrite.models.Session.from(map = it as Map) + } return client.call( "POST", path, @@ -708,7 +708,7 @@ class Account : Service { * * 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 userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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] @@ -730,8 +730,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it as Map) - } + io.appwrite.models.Token.from(map = it as Map) + } return client.call( "POST", path, @@ -766,8 +766,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { - io.appwrite.models.Session.from(map = it as Map) - } + io.appwrite.models.Session.from(map = it as Map) + } return client.call( "PUT", path, @@ -804,6 +804,7 @@ class Account : Service { "success" to success, "failure" to failure, "scopes" to scopes, + "project" to client.config["project"], ) val query = mutableListOf() params.forEach { @@ -855,7 +856,7 @@ class Account : Service { * * 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 `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 userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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] */ @@ -873,8 +874,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it as Map) - } + io.appwrite.models.Token.from(map = it as Map) + } return client.call( "POST", path, @@ -909,8 +910,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { - io.appwrite.models.Session.from(map = it as Map) - } + io.appwrite.models.Session.from(map = it as Map) + } return client.call( "PUT", path, @@ -942,8 +943,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { - io.appwrite.models.Session.from(map = it as Map) - } + io.appwrite.models.Session.from(map = it as Map) + } return client.call( "GET", path, @@ -975,8 +976,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { - io.appwrite.models.Session.from(map = it as Map) - } + io.appwrite.models.Session.from(map = it as Map) + } return client.call( "PATCH", path, @@ -1035,8 +1036,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it as Map, nestedType) - } + io.appwrite.models.Account.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, @@ -1080,8 +1081,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it as Map) - } + io.appwrite.models.Token.from(map = it as Map) + } return client.call( "POST", path, @@ -1116,8 +1117,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it as Map) - } + io.appwrite.models.Token.from(map = it as Map) + } return client.call( "PUT", path, @@ -1146,8 +1147,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it as Map) - } + io.appwrite.models.Token.from(map = it as Map) + } return client.call( "POST", path, @@ -1182,8 +1183,8 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it as Map) - } + io.appwrite.models.Token.from(map = it as Map) + } return client.call( "PUT", path, diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt index 74980b9..69f158b 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -42,6 +42,7 @@ class Avatars : Service { "width" to width, "height" to height, "quality" to quality, + "project" to client.config["project"], ) return client.call( "GET", @@ -77,6 +78,7 @@ class Avatars : Service { "width" to width, "height" to height, "quality" to quality, + "project" to client.config["project"], ) return client.call( "GET", @@ -102,6 +104,7 @@ class Avatars : Service { val params = mutableMapOf( "url" to url, + "project" to client.config["project"], ) return client.call( "GET", @@ -137,6 +140,7 @@ class Avatars : Service { "width" to width, "height" to height, "quality" to quality, + "project" to client.config["project"], ) return client.call( "GET", @@ -169,6 +173,7 @@ class Avatars : Service { "url" to url, "width" to width, "height" to height, + "project" to client.config["project"], ) return client.call( "GET", @@ -204,6 +209,7 @@ class Avatars : Service { "width" to width, "height" to height, "background" to background, + "project" to client.config["project"], ) return client.call( "GET", @@ -239,6 +245,7 @@ class Avatars : Service { "size" to size, "margin" to margin, "download" to download, + "project" to client.config["project"], ) return client.call( "GET", diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index 45d6864..26094eb 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -43,8 +43,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.DocumentList = { - io.appwrite.models.DocumentList.from(map = it as Map, nestedType) - } + io.appwrite.models.DocumentList.from(map = it as Map, nestedType) + } return client.call( "GET", path, @@ -85,9 +85,9 @@ 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). 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 documentId Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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). + * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](/docs/permissions). * @return [io.appwrite.models.Document] */ @JvmOverloads @@ -112,8 +112,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { - io.appwrite.models.Document.from(map = it as Map, nestedType) - } + io.appwrite.models.Document.from(map = it as Map, nestedType) + } return client.call( "POST", path, @@ -131,9 +131,9 @@ 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). 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 documentId Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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). + * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](/docs/permissions). * @return [io.appwrite.models.Document] */ @JvmOverloads @@ -180,8 +180,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { - io.appwrite.models.Document.from(map = it as Map, nestedType) - } + io.appwrite.models.Document.from(map = it as Map, nestedType) + } return client.call( "GET", path, @@ -223,7 +223,7 @@ class Databases : Service { * @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). + * @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 @@ -248,8 +248,8 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { - io.appwrite.models.Document.from(map = it as Map, nestedType) - } + io.appwrite.models.Document.from(map = it as Map, nestedType) + } return client.call( "PATCH", path, @@ -269,7 +269,7 @@ class Databases : Service { * @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). + * @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 diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index 90b4867..a9d33ca 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -42,8 +42,8 @@ class Functions : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.ExecutionList = { - io.appwrite.models.ExecutionList.from(map = it as Map) - } + io.appwrite.models.ExecutionList.from(map = it as Map) + } return client.call( "GET", path, @@ -82,8 +82,8 @@ class Functions : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Execution = { - io.appwrite.models.Execution.from(map = it as Map) - } + io.appwrite.models.Execution.from(map = it as Map) + } return client.call( "POST", path, @@ -118,8 +118,8 @@ class Functions : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Execution = { - io.appwrite.models.Execution.from(map = it as Map) - } + io.appwrite.models.Execution.from(map = it as Map) + } return client.call( "GET", path, diff --git a/library/src/main/java/io/appwrite/services/Graphql.kt b/library/src/main/java/io/appwrite/services/Graphql.kt index 7ac28b5..d661ccf 100644 --- a/library/src/main/java/io/appwrite/services/Graphql.kt +++ b/library/src/main/java/io/appwrite/services/Graphql.kt @@ -36,8 +36,8 @@ class Graphql : Service { "content-type" to "application/json", ) val converter: (Any) -> Any = { - it - } + it + } return client.call( "POST", path, @@ -70,8 +70,8 @@ class Graphql : Service { "content-type" to "application/json", ) val converter: (Any) -> Any = { - it - } + it + } return client.call( "POST", path, diff --git a/library/src/main/java/io/appwrite/services/Locale.kt b/library/src/main/java/io/appwrite/services/Locale.kt index ff6d988..5c9cc95 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -32,8 +32,8 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Locale = { - io.appwrite.models.Locale.from(map = it as Map) - } + io.appwrite.models.Locale.from(map = it as Map) + } return client.call( "GET", path, @@ -62,8 +62,8 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.ContinentList = { - io.appwrite.models.ContinentList.from(map = it as Map) - } + io.appwrite.models.ContinentList.from(map = it as Map) + } return client.call( "GET", path, @@ -92,8 +92,8 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CountryList = { - io.appwrite.models.CountryList.from(map = it as Map) - } + io.appwrite.models.CountryList.from(map = it as Map) + } return client.call( "GET", path, @@ -122,8 +122,8 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CountryList = { - io.appwrite.models.CountryList.from(map = it as Map) - } + io.appwrite.models.CountryList.from(map = it as Map) + } return client.call( "GET", path, @@ -152,8 +152,8 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.PhoneList = { - io.appwrite.models.PhoneList.from(map = it as Map) - } + io.appwrite.models.PhoneList.from(map = it as Map) + } return client.call( "GET", path, @@ -182,8 +182,8 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CurrencyList = { - io.appwrite.models.CurrencyList.from(map = it as Map) - } + io.appwrite.models.CurrencyList.from(map = it as Map) + } return client.call( "GET", path, @@ -212,8 +212,8 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LanguageList = { - io.appwrite.models.LanguageList.from(map = it as Map) - } + io.appwrite.models.LanguageList.from(map = it as Map) + } return client.call( "GET", path, diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index 6aec906..fd7dc1b 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -44,8 +44,8 @@ class Storage : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.FileList = { - io.appwrite.models.FileList.from(map = it as Map) - } + io.appwrite.models.FileList.from(map = it as Map) + } return client.call( "GET", path, @@ -63,9 +63,9 @@ class Storage : Service { * 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 `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 fileId File ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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). + * @param permissions An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](/docs/permissions). * @return [io.appwrite.models.File] */ @JvmOverloads @@ -88,8 +88,8 @@ class Storage : Service { "content-type" to "multipart/form-data", ) val converter: (Any) -> io.appwrite.models.File = { - io.appwrite.models.File.from(map = it as Map) - } + io.appwrite.models.File.from(map = it as Map) + } val idParamName: String? = "fileId" val paramName = "file" return client.chunkedUpload( @@ -128,8 +128,8 @@ class Storage : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.File = { - io.appwrite.models.File.from(map = it as Map) - } + io.appwrite.models.File.from(map = it as Map) + } return client.call( "GET", path, @@ -148,7 +148,7 @@ class Storage : Service { * * @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). + * @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] */ @JvmOverloads @@ -168,8 +168,8 @@ class Storage : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.File = { - io.appwrite.models.File.from(map = it as Map) - } + io.appwrite.models.File.from(map = it as Map) + } return client.call( "PUT", path, @@ -231,6 +231,7 @@ class Storage : Service { .replace("{fileId}", fileId) val params = mutableMapOf( + "project" to client.config["project"], ) return client.call( "GET", @@ -293,6 +294,7 @@ class Storage : Service { "rotation" to rotation, "background" to background, "output" to output, + "project" to client.config["project"], ) return client.call( "GET", @@ -321,6 +323,7 @@ class Storage : Service { .replace("{fileId}", fileId) val params = mutableMapOf( + "project" to client.config["project"], ) return client.call( "GET", diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 68f0b0a..e188330 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -39,8 +39,8 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.TeamList = { - io.appwrite.models.TeamList.from(map = it as Map) - } + io.appwrite.models.TeamList.from(map = it as Map) + } return client.call( "GET", path, @@ -57,7 +57,7 @@ class Teams : Service { * * 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 `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 teamId Team ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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] @@ -79,8 +79,8 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Team = { - io.appwrite.models.Team.from(map = it as Map) - } + io.appwrite.models.Team.from(map = it as Map) + } return client.call( "POST", path, @@ -112,8 +112,8 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Team = { - io.appwrite.models.Team.from(map = it as Map) - } + io.appwrite.models.Team.from(map = it as Map) + } return client.call( "GET", path, @@ -148,8 +148,8 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Team = { - io.appwrite.models.Team.from(map = it as Map) - } + io.appwrite.models.Team.from(map = it as Map) + } return client.call( "PUT", path, @@ -217,8 +217,8 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MembershipList = { - io.appwrite.models.MembershipList.from(map = it as Map) - } + io.appwrite.models.MembershipList.from(map = it as Map) + } return client.call( "GET", path, @@ -263,8 +263,8 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { - io.appwrite.models.Membership.from(map = it as Map) - } + io.appwrite.models.Membership.from(map = it as Map) + } return client.call( "POST", path, @@ -299,8 +299,8 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { - io.appwrite.models.Membership.from(map = it as Map) - } + io.appwrite.models.Membership.from(map = it as Map) + } return client.call( "GET", path, @@ -338,8 +338,8 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { - io.appwrite.models.Membership.from(map = it as Map) - } + io.appwrite.models.Membership.from(map = it as Map) + } return client.call( "PATCH", path, @@ -412,8 +412,8 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { - io.appwrite.models.Membership.from(map = it as Map) - } + io.appwrite.models.Membership.from(map = it as Map) + } return client.call( "PATCH", path, From 27e0b16c636db9ae9f24756064dcc54729dcd320 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Tue, 11 Apr 2023 23:57:49 +0000 Subject: [PATCH 047/118] update to appwrite 1.3.0 --- README.md | 6 +- build.gradle | 2 +- docs/examples/java/account/create.md | 2 +- docs/examples/java/account/update-password.md | 2 +- docs/examples/java/databases/get-document.md | 2 +- docs/examples/java/teams/create-membership.md | 1 - docs/examples/java/teams/get-prefs.md | 21 ++ .../java/teams/{update.md => update-name.md} | 2 +- docs/examples/java/teams/update-prefs.md | 22 ++ docs/examples/kotlin/account/create.md | 2 +- .../kotlin/account/update-password.md | 2 +- .../examples/kotlin/databases/get-document.md | 2 +- .../kotlin/teams/create-membership.md | 1 - docs/examples/kotlin/teams/get-prefs.md | 12 + .../teams/{update.md => update-name.md} | 2 +- docs/examples/kotlin/teams/update-prefs.md | 13 + example-java/build.gradle | 16 +- example/build.gradle | 34 +-- gradle/wrapper/gradle-wrapper.properties | 2 +- library/build.gradle | 14 +- library/src/main/java/io/appwrite/Client.kt | 2 +- library/src/main/java/io/appwrite/Query.kt | 16 ++ .../java/io/appwrite/models/AlgoArgon2.kt | 54 ++++ .../java/io/appwrite/models/AlgoBcrypt.kt | 30 +++ .../main/java/io/appwrite/models/AlgoMd5.kt | 30 +++ .../java/io/appwrite/models/AlgoPhpass.kt | 30 +++ .../java/io/appwrite/models/AlgoScrypt.kt | 62 +++++ .../io/appwrite/models/AlgoScryptModified.kt | 54 ++++ .../main/java/io/appwrite/models/AlgoSha.kt | 30 +++ .../src/main/java/io/appwrite/models/Team.kt | 30 ++- .../main/java/io/appwrite/models/TeamList.kt | 18 +- .../appwrite/models/{Account.kt => User.kt} | 38 ++- .../main/java/io/appwrite/services/Account.kt | 112 ++++---- .../java/io/appwrite/services/Databases.kt | 20 +- .../java/io/appwrite/services/Functions.kt | 2 +- .../main/java/io/appwrite/services/Storage.kt | 2 +- .../main/java/io/appwrite/services/Teams.kt | 250 +++++++++++++++--- 37 files changed, 785 insertions(+), 155 deletions(-) create mode 100644 docs/examples/java/teams/get-prefs.md rename docs/examples/java/teams/{update.md => update-name.md} (96%) create mode 100644 docs/examples/java/teams/update-prefs.md create mode 100644 docs/examples/kotlin/teams/get-prefs.md rename docs/examples/kotlin/teams/{update.md => update-name.md} (89%) create mode 100644 docs/examples/kotlin/teams/update-prefs.md create mode 100644 library/src/main/java/io/appwrite/models/AlgoArgon2.kt create mode 100644 library/src/main/java/io/appwrite/models/AlgoBcrypt.kt create mode 100644 library/src/main/java/io/appwrite/models/AlgoMd5.kt create mode 100644 library/src/main/java/io/appwrite/models/AlgoPhpass.kt create mode 100644 library/src/main/java/io/appwrite/models/AlgoScrypt.kt create mode 100644 library/src/main/java/io/appwrite/models/AlgoScryptModified.kt create mode 100644 library/src/main/java/io/appwrite/models/AlgoSha.kt rename library/src/main/java/io/appwrite/models/{Account.kt => User.kt} (81%) diff --git a/README.md b/README.md index 20edee9..97b1780 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![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.2.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.3.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.2.1") +implementation("io.appwrite:sdk-for-android:1.3.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 1.2.1 + 1.3.0 ``` diff --git a/build.gradle b/build.gradle index d475d54..f2080e6 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.7.10" + ext.kotlin_version = "1.8.0" version System.getenv("SDK_VERSION") repositories { maven { url "https://plugins.gradle.org/m2/" } diff --git a/docs/examples/java/account/create.md b/docs/examples/java/account/create.md index af0965e..68bb47e 100644 --- a/docs/examples/java/account/create.md +++ b/docs/examples/java/account/create.md @@ -11,7 +11,7 @@ Account account = new Account(client); account.create( "[USER_ID]", "email@example.com", - "password", + "", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-password.md b/docs/examples/java/account/update-password.md index e16aac5..aaaee66 100644 --- a/docs/examples/java/account/update-password.md +++ b/docs/examples/java/account/update-password.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.updatePassword( - "password", + "", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/get-document.md b/docs/examples/java/databases/get-document.md index f4e7dc6..7e3b33b 100644 --- a/docs/examples/java/databases/get-document.md +++ b/docs/examples/java/databases/get-document.md @@ -11,7 +11,7 @@ Databases databases = new Databases(client); databases.getDocument( "[DATABASE_ID]", "[COLLECTION_ID]", - "[DOCUMENT_ID]" + "[DOCUMENT_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/create-membership.md b/docs/examples/java/teams/create-membership.md index 9d567d6..0e5590d 100644 --- a/docs/examples/java/teams/create-membership.md +++ b/docs/examples/java/teams/create-membership.md @@ -10,7 +10,6 @@ Teams teams = new Teams(client); teams.createMembership( "[TEAM_ID]", - "email@example.com", listOf(), "https://example.com", new CoroutineCallback<>((result, error) -> { diff --git a/docs/examples/java/teams/get-prefs.md b/docs/examples/java/teams/get-prefs.md new file mode 100644 index 0000000..bbf1256 --- /dev/null +++ b/docs/examples/java/teams/get-prefs.md @@ -0,0 +1,21 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Teams; + +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Teams teams = new Teams(client); + +teams.getPrefs( + "[TEAM_ID]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/teams/update.md b/docs/examples/java/teams/update-name.md similarity index 96% rename from docs/examples/java/teams/update.md rename to docs/examples/java/teams/update-name.md index 86d6a3f..22a2ee0 100644 --- a/docs/examples/java/teams/update.md +++ b/docs/examples/java/teams/update-name.md @@ -8,7 +8,7 @@ Client client = new Client(context) Teams teams = new Teams(client); -teams.update( +teams.updateName( "[TEAM_ID]", "[NAME]" new CoroutineCallback<>((result, error) -> { diff --git a/docs/examples/java/teams/update-prefs.md b/docs/examples/java/teams/update-prefs.md new file mode 100644 index 0000000..a4cf82d --- /dev/null +++ b/docs/examples/java/teams/update-prefs.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Teams; + +Client client = new Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Teams teams = new Teams(client); + +teams.updatePrefs( + "[TEAM_ID]", + mapOf( "a" to "b" ) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/kotlin/account/create.md b/docs/examples/kotlin/account/create.md index 2a55fb1..eda87d3 100644 --- a/docs/examples/kotlin/account/create.md +++ b/docs/examples/kotlin/account/create.md @@ -10,5 +10,5 @@ val account = Account(client) val response = account.create( userId = "[USER_ID]", email = "email@example.com", - password = "password", + password = "", ) diff --git a/docs/examples/kotlin/account/update-password.md b/docs/examples/kotlin/account/update-password.md index cdf8178..14e746f 100644 --- a/docs/examples/kotlin/account/update-password.md +++ b/docs/examples/kotlin/account/update-password.md @@ -8,5 +8,5 @@ val client = Client(context) val account = Account(client) val response = account.updatePassword( - password = "password", + password = "", ) diff --git a/docs/examples/kotlin/databases/get-document.md b/docs/examples/kotlin/databases/get-document.md index b81f340..17c6047 100644 --- a/docs/examples/kotlin/databases/get-document.md +++ b/docs/examples/kotlin/databases/get-document.md @@ -10,5 +10,5 @@ val databases = Databases(client) val response = databases.getDocument( databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", - documentId = "[DOCUMENT_ID]" + documentId = "[DOCUMENT_ID]", ) diff --git a/docs/examples/kotlin/teams/create-membership.md b/docs/examples/kotlin/teams/create-membership.md index 60d39c0..33bbe56 100644 --- a/docs/examples/kotlin/teams/create-membership.md +++ b/docs/examples/kotlin/teams/create-membership.md @@ -9,7 +9,6 @@ val teams = Teams(client) val response = teams.createMembership( teamId = "[TEAM_ID]", - email = "email@example.com", roles = listOf(), url = "https://example.com", ) diff --git a/docs/examples/kotlin/teams/get-prefs.md b/docs/examples/kotlin/teams/get-prefs.md new file mode 100644 index 0000000..b8c2382 --- /dev/null +++ b/docs/examples/kotlin/teams/get-prefs.md @@ -0,0 +1,12 @@ +import io.appwrite.Client +import io.appwrite.services.Teams + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val teams = Teams(client) + +val response = teams.getPrefs( + teamId = "[TEAM_ID]" +) diff --git a/docs/examples/kotlin/teams/update.md b/docs/examples/kotlin/teams/update-name.md similarity index 89% rename from docs/examples/kotlin/teams/update.md rename to docs/examples/kotlin/teams/update-name.md index 1a54434..9a2dc4a 100644 --- a/docs/examples/kotlin/teams/update.md +++ b/docs/examples/kotlin/teams/update-name.md @@ -7,7 +7,7 @@ val client = Client(context) val teams = Teams(client) -val response = teams.update( +val response = teams.updateName( teamId = "[TEAM_ID]", name = "[NAME]" ) diff --git a/docs/examples/kotlin/teams/update-prefs.md b/docs/examples/kotlin/teams/update-prefs.md new file mode 100644 index 0000000..f7f8f50 --- /dev/null +++ b/docs/examples/kotlin/teams/update-prefs.md @@ -0,0 +1,13 @@ +import io.appwrite.Client +import io.appwrite.services.Teams + +val client = Client(context) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val teams = Teams(client) + +val response = teams.updatePrefs( + teamId = "[TEAM_ID]", + prefs = mapOf( "a" to "b" ) +) diff --git a/example-java/build.gradle b/example-java/build.gradle index fb916fa..774d3ba 100644 --- a/example-java/build.gradle +++ b/example-java/build.gradle @@ -3,12 +3,12 @@ plugins { } android { - compileSdkVersion 31 + compileSdkVersion 33 defaultConfig { applicationId "io.appwrite.example_java" minSdkVersion 23 - targetSdkVersion 31 + targetSdkVersion 33 versionCode 1 versionName "1.0" @@ -30,10 +30,10 @@ android { dependencies { implementation project(path: ':library') - implementation 'androidx.appcompat:appcompat:1.3.0' - implementation 'com.google.android.material:material:1.3.0' - implementation 'androidx.constraintlayout:constraintlayout:2.0.4' - testImplementation 'junit:junit:4.+' - androidTestImplementation 'androidx.test.ext:junit:1.1.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + implementation 'androidx.appcompat:appcompat:1.6.0' + implementation 'com.google.android.material:material:1.8.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' } \ No newline at end of file diff --git a/example/build.gradle b/example/build.gradle index 6c5e1f5..62a34ed 100644 --- a/example/build.gradle +++ b/example/build.gradle @@ -4,12 +4,12 @@ plugins { } android { - compileSdkVersion 31 + compileSdkVersion 33 defaultConfig { applicationId "io.appwrite.android" minSdkVersion 21 - targetSdkVersion 31 + targetSdkVersion 33 versionCode 1 versionName "1.0" @@ -39,20 +39,20 @@ dependencies { implementation project(path: ':library') implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.core:core-ktx:1.6.0' - implementation 'androidx.appcompat:appcompat:1.3.1' - implementation 'com.google.android.material:material:1.4.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.1' - implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5' - implementation "androidx.fragment:fragment-ktx:1.3.6" - implementation 'androidx.navigation:navigation-ui-ktx:2.3.5' - implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1' - implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1' - implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5' - implementation 'androidx.navigation:navigation-ui-ktx:2.3.5' + implementation 'androidx.core:core-ktx:1.9.0' + implementation 'androidx.appcompat:appcompat:1.6.0' + implementation 'com.google.android.material:material:1.8.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3' + implementation "androidx.fragment:fragment-ktx:1.5.5" + implementation 'androidx.navigation:navigation-ui-ktx:2.5.3' + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1' + implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3' + implementation 'androidx.navigation:navigation-ui-ktx:2.5.3' implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2" - testImplementation 'junit:junit:4.+' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1" + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2dadb9d..85e684f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Tue Jun 01 15:55:54 IST 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/library/build.gradle b/library/build.gradle index 6be6a48..baa5b1e 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -53,7 +53,7 @@ android { } dependencies { - implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION}") + implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version") api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1") api("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1") @@ -65,14 +65,14 @@ dependencies { 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.appcompat:appcompat:1.6.0") + implementation("androidx.fragment:fragment-ktx:1.5.5") + implementation("androidx.activity:activity-ktx:1.6.1") 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 'junit:junit:4.13.2' + testImplementation "androidx.test.ext:junit-ktx:1.1.5" + testImplementation "androidx.test:core-ktx:1.5.0" testImplementation "org.robolectric:robolectric:4.5.1" testApi("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.1") } diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 2f8623f..4460d4d 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.2.1", + "x-sdk-version" to "1.3.0", "x-appwrite-response-format" to "1.0.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/Query.kt b/library/src/main/java/io/appwrite/Query.kt index 2d33a02..ad1f3ed 100644 --- a/library/src/main/java/io/appwrite/Query.kt +++ b/library/src/main/java/io/appwrite/Query.kt @@ -16,6 +16,22 @@ class Query { fun search(attribute: String, value: String) = Query.addQuery(attribute, "search", value) + fun isNull(attribute: String) = "isNull(\"${attribute}\")" + + fun isNotNull(attribute: String) = "isNotNull(\"${attribute}\")" + + fun between(attribute: String, start: Int, end: Int) = Query.addQuery(attribute, "between", listOf(start, end)) + + fun between(attribute: String, start: Double, end: Double) = Query.addQuery(attribute, "between", listOf(start, end)) + + fun between(attribute: String, start: String, end: String) = Query.addQuery(attribute, "between", listOf(start, end)) + + fun startsWith(attribute: String, value: String) = Query.addQuery(attribute, "startsWith", value) + + fun endsWith(attribute: String, value: String) = Query.addQuery(attribute, "endsWith", value) + + fun select(attributes: List) = "select([${attributes.joinToString(",") { "\"$it\"" }}])" + fun orderAsc(attribute: String) = "orderAsc(\"${attribute}\")" fun orderDesc(attribute: String) = "orderDesc(\"${attribute}\")" diff --git a/library/src/main/java/io/appwrite/models/AlgoArgon2.kt b/library/src/main/java/io/appwrite/models/AlgoArgon2.kt new file mode 100644 index 0000000..6230248 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AlgoArgon2.kt @@ -0,0 +1,54 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * AlgoArgon2 + */ +data class AlgoArgon2( + /** + * Algo type. + */ + @SerializedName("type") + val type: String, + + /** + * Memory used to compute hash. + */ + @SerializedName("memoryCost") + val memoryCost: Long, + + /** + * Amount of time consumed to compute hash + */ + @SerializedName("timeCost") + val timeCost: Long, + + /** + * Number of threads used to compute hash. + */ + @SerializedName("threads") + val threads: Long, + +) { + fun toMap(): Map = mapOf( + "type" to type as Any, + "memoryCost" to memoryCost as Any, + "timeCost" to timeCost as Any, + "threads" to threads as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = AlgoArgon2( + type = map["type"] as String, + memoryCost = (map["memoryCost"] as Number).toLong(), + timeCost = (map["timeCost"] as Number).toLong(), + threads = (map["threads"] as Number).toLong(), + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AlgoBcrypt.kt b/library/src/main/java/io/appwrite/models/AlgoBcrypt.kt new file mode 100644 index 0000000..24e74b8 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AlgoBcrypt.kt @@ -0,0 +1,30 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * AlgoBcrypt + */ +data class AlgoBcrypt( + /** + * Algo type. + */ + @SerializedName("type") + val type: String, + +) { + fun toMap(): Map = mapOf( + "type" to type as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = AlgoBcrypt( + type = map["type"] as String, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AlgoMd5.kt b/library/src/main/java/io/appwrite/models/AlgoMd5.kt new file mode 100644 index 0000000..71baf51 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AlgoMd5.kt @@ -0,0 +1,30 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * AlgoMD5 + */ +data class AlgoMd5( + /** + * Algo type. + */ + @SerializedName("type") + val type: String, + +) { + fun toMap(): Map = mapOf( + "type" to type as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = AlgoMd5( + type = map["type"] as String, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AlgoPhpass.kt b/library/src/main/java/io/appwrite/models/AlgoPhpass.kt new file mode 100644 index 0000000..d89b8cf --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AlgoPhpass.kt @@ -0,0 +1,30 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * AlgoPHPass + */ +data class AlgoPhpass( + /** + * Algo type. + */ + @SerializedName("type") + val type: String, + +) { + fun toMap(): Map = mapOf( + "type" to type as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = AlgoPhpass( + type = map["type"] as String, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AlgoScrypt.kt b/library/src/main/java/io/appwrite/models/AlgoScrypt.kt new file mode 100644 index 0000000..2e4ae1e --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AlgoScrypt.kt @@ -0,0 +1,62 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * AlgoScrypt + */ +data class AlgoScrypt( + /** + * Algo type. + */ + @SerializedName("type") + val type: String, + + /** + * CPU complexity of computed hash. + */ + @SerializedName("costCpu") + val costCpu: Long, + + /** + * Memory complexity of computed hash. + */ + @SerializedName("costMemory") + val costMemory: Long, + + /** + * Parallelization of computed hash. + */ + @SerializedName("costParallel") + val costParallel: Long, + + /** + * Length used to compute hash. + */ + @SerializedName("length") + val length: Long, + +) { + fun toMap(): Map = mapOf( + "type" to type as Any, + "costCpu" to costCpu as Any, + "costMemory" to costMemory as Any, + "costParallel" to costParallel as Any, + "length" to length as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = AlgoScrypt( + type = map["type"] as String, + costCpu = (map["costCpu"] as Number).toLong(), + costMemory = (map["costMemory"] as Number).toLong(), + costParallel = (map["costParallel"] as Number).toLong(), + length = (map["length"] as Number).toLong(), + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AlgoScryptModified.kt b/library/src/main/java/io/appwrite/models/AlgoScryptModified.kt new file mode 100644 index 0000000..3807d6d --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AlgoScryptModified.kt @@ -0,0 +1,54 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * AlgoScryptModified + */ +data class AlgoScryptModified( + /** + * Algo type. + */ + @SerializedName("type") + val type: String, + + /** + * Salt used to compute hash. + */ + @SerializedName("salt") + val salt: String, + + /** + * Separator used to compute hash. + */ + @SerializedName("saltSeparator") + val saltSeparator: String, + + /** + * Key used to compute hash. + */ + @SerializedName("signerKey") + val signerKey: String, + +) { + fun toMap(): Map = mapOf( + "type" to type as Any, + "salt" to salt as Any, + "saltSeparator" to saltSeparator as Any, + "signerKey" to signerKey as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = AlgoScryptModified( + type = map["type"] as String, + salt = map["salt"] as String, + saltSeparator = map["saltSeparator"] as String, + signerKey = map["signerKey"] as String, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/AlgoSha.kt b/library/src/main/java/io/appwrite/models/AlgoSha.kt new file mode 100644 index 0000000..4209a0e --- /dev/null +++ b/library/src/main/java/io/appwrite/models/AlgoSha.kt @@ -0,0 +1,30 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * AlgoSHA + */ +data class AlgoSha( + /** + * Algo type. + */ + @SerializedName("type") + val type: String, + +) { + fun toMap(): Map = mapOf( + "type" to type as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = AlgoSha( + type = map["type"] as String, + ) + } +} \ 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 76f7cb2..0723b90 100644 --- a/library/src/main/java/io/appwrite/models/Team.kt +++ b/library/src/main/java/io/appwrite/models/Team.kt @@ -6,7 +6,7 @@ import io.appwrite.extensions.jsonCast /** * Team */ -data class Team( +data class Team( /** * Team ID. */ @@ -37,6 +37,12 @@ data class Team( @SerializedName("total") val total: Long, + /** + * Team preferences as a key-value object + */ + @SerializedName("prefs") + val prefs: Preferences, + ) { fun toMap(): Map = mapOf( "\$id" to id as Any, @@ -44,19 +50,37 @@ data class Team( "\$updatedAt" to updatedAt as Any, "name" to name as Any, "total" to total as Any, + "prefs" to prefs.toMap() as Any, ) companion object { + operator fun invoke( + id: String, + createdAt: String, + updatedAt: String, + name: String, + total: Long, + prefs: Preferences>, + ) = Team>( + id, + createdAt, + updatedAt, + name, + total, + prefs, + ) @Suppress("UNCHECKED_CAST") - fun from( + fun from( map: Map, - ) = Team( + nestedType: Class + ) = 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(), + prefs = Preferences.from(map = map["prefs"] as Map, nestedType), ) } } \ 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 ab76ed6..17ccd6b 100644 --- a/library/src/main/java/io/appwrite/models/TeamList.kt +++ b/library/src/main/java/io/appwrite/models/TeamList.kt @@ -6,7 +6,7 @@ import io.appwrite.extensions.jsonCast /** * Teams List */ -data class TeamList( +data class TeamList( /** * Total number of teams documents that matched your query. */ @@ -17,7 +17,7 @@ data class TeamList( * List of teams. */ @SerializedName("teams") - val teams: List, + val teams: List>, ) { fun toMap(): Map = mapOf( @@ -26,13 +26,21 @@ data class TeamList( ) companion object { + operator fun invoke( + total: Long, + teams: List>>, + ) = TeamList>( + total, + teams, + ) @Suppress("UNCHECKED_CAST") - fun from( + fun from( map: Map, - ) = TeamList( + nestedType: Class + ) = 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, nestedType) }, ) } } \ 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/User.kt similarity index 81% rename from library/src/main/java/io/appwrite/models/Account.kt rename to library/src/main/java/io/appwrite/models/User.kt index 1b87beb..81551e6 100644 --- a/library/src/main/java/io/appwrite/models/Account.kt +++ b/library/src/main/java/io/appwrite/models/User.kt @@ -4,9 +4,9 @@ import com.google.gson.annotations.SerializedName import io.appwrite.extensions.jsonCast /** - * Account + * User */ -data class Account( +data class User( /** * User ID. */ @@ -31,6 +31,24 @@ data class Account( @SerializedName("name") val name: String, + /** + * Hashed user password. + */ + @SerializedName("password") + var password: String?, + + /** + * Password hashing algorithm. + */ + @SerializedName("hash") + var hash: String?, + + /** + * Password hashing algorithm configuration. + */ + @SerializedName("hashOptions") + var hashOptions: Any?, + /** * User registration date in ISO 8601 format. */ @@ -85,6 +103,9 @@ data class Account( "\$createdAt" to createdAt as Any, "\$updatedAt" to updatedAt as Any, "name" to name as Any, + "password" to password as Any, + "hash" to hash as Any, + "hashOptions" to hashOptions as Any, "registration" to registration as Any, "status" to status as Any, "passwordUpdate" to passwordUpdate as Any, @@ -101,6 +122,9 @@ data class Account( createdAt: String, updatedAt: String, name: String, + password: String?, + hash: String?, + hashOptions: Any?, registration: String, status: Boolean, passwordUpdate: String, @@ -109,11 +133,14 @@ data class Account( emailVerification: Boolean, phoneVerification: Boolean, prefs: Preferences>, - ) = Account>( + ) = User>( id, createdAt, updatedAt, name, + password, + hash, + hashOptions, registration, status, passwordUpdate, @@ -128,11 +155,14 @@ data class Account( fun from( map: Map, nestedType: Class - ) = Account( + ) = User( id = map["\$id"] as String, createdAt = map["\$createdAt"] as String, updatedAt = map["\$updatedAt"] as String, name = map["name"] as String, + password = map["password"] as? String?, + hash = map["hash"] as? String?, + hashOptions = map["hashOptions"] as? Any?, registration = map["registration"] as String, status = map["status"] as Boolean, passwordUpdate = map["passwordUpdate"] as String, diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index fec82f4..2a88a5b 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -24,11 +24,11 @@ class Account : Service { * * Get currently logged in user data as JSON object. * - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.User] */ suspend fun get( nestedType: Class, - ): io.appwrite.models.Account { + ): io.appwrite.models.User { val path = "/account" val params = mutableMapOf( @@ -36,8 +36,8 @@ class Account : Service { val headers = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it as Map, nestedType) + val converter: (Any) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( "GET", @@ -54,11 +54,11 @@ class Account : Service { * * Get currently logged in user data as JSON object. * - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.User] */ @Throws(AppwriteException::class) suspend fun get( - ) = get( + ): io.appwrite.models.User> = get( nestedType = classOf(), ) @@ -69,9 +69,9 @@ class Account : Service { * * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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 password New 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.User] */ @JvmOverloads suspend fun create( @@ -80,7 +80,7 @@ class Account : Service { password: String, name: String? = null, nestedType: Class, - ): io.appwrite.models.Account { + ): io.appwrite.models.User { val path = "/account" val params = mutableMapOf( @@ -92,8 +92,8 @@ class Account : Service { val headers = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it as Map, nestedType) + val converter: (Any) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( "POST", @@ -112,9 +112,9 @@ class Account : Service { * * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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 password New 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.User] */ @JvmOverloads @Throws(AppwriteException::class) @@ -123,7 +123,7 @@ class Account : Service { email: String, password: String, name: String? = null, - ) = create( + ): io.appwrite.models.User> = create( userId, email, password, @@ -138,13 +138,13 @@ class Account : Service { * * @param email User email. * @param password User password. Must be at least 8 chars. - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.User] */ suspend fun updateEmail( email: String, password: String, nestedType: Class, - ): io.appwrite.models.Account { + ): io.appwrite.models.User { val path = "/account/email" val params = mutableMapOf( @@ -154,8 +154,8 @@ class Account : Service { val headers = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it as Map, nestedType) + val converter: (Any) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( "PATCH", @@ -174,13 +174,13 @@ class Account : Service { * * @param email User email. * @param password User password. Must be at least 8 chars. - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.User] */ @Throws(AppwriteException::class) suspend fun updateEmail( email: String, password: String, - ) = updateEmail( + ): io.appwrite.models.User> = updateEmail( email, password, nestedType = classOf(), @@ -221,7 +221,7 @@ class Account : Service { * * 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 + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset * @return [io.appwrite.models.LogList] */ @JvmOverloads @@ -256,12 +256,12 @@ class Account : Service { * Update currently logged in user account name. * * @param name User name. Max length: 128 chars. - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.User] */ suspend fun updateName( name: String, nestedType: Class, - ): io.appwrite.models.Account { + ): io.appwrite.models.User { val path = "/account/name" val params = mutableMapOf( @@ -270,8 +270,8 @@ class Account : Service { val headers = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it as Map, nestedType) + val converter: (Any) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( "PATCH", @@ -289,12 +289,12 @@ class Account : Service { * Update currently logged in user account name. * * @param name User name. Max length: 128 chars. - * @return [io.appwrite.models.Account] + * @return [io.appwrite.models.User] */ @Throws(AppwriteException::class) suspend fun updateName( name: String, - ) = updateName( + ): io.appwrite.models.User> = updateName( name, nestedType = classOf(), ) @@ -306,14 +306,14 @@ class Account : Service { * * @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.User] */ @JvmOverloads suspend fun updatePassword( password: String, oldPassword: String? = null, nestedType: Class, - ): io.appwrite.models.Account { + ): io.appwrite.models.User { val path = "/account/password" val params = mutableMapOf( @@ -323,8 +323,8 @@ class Account : Service { val headers = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it as Map, nestedType) + val converter: (Any) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( "PATCH", @@ -343,14 +343,14 @@ class Account : Service { * * @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.User] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun updatePassword( password: String, oldPassword: String? = null, - ) = updatePassword( + ): io.appwrite.models.User> = updatePassword( password, oldPassword, nestedType = classOf(), @@ -363,13 +363,13 @@ class Account : Service { * * @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] + * @return [io.appwrite.models.User] */ suspend fun updatePhone( phone: String, password: String, nestedType: Class, - ): io.appwrite.models.Account { + ): io.appwrite.models.User { val path = "/account/phone" val params = mutableMapOf( @@ -379,8 +379,8 @@ class Account : Service { val headers = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it as Map, nestedType) + val converter: (Any) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( "PATCH", @@ -399,13 +399,13 @@ class Account : Service { * * @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] + * @return [io.appwrite.models.User] */ @Throws(AppwriteException::class) suspend fun updatePhone( phone: String, password: String, - ) = updatePhone( + ): io.appwrite.models.User> = updatePhone( phone, password, nestedType = classOf(), @@ -450,7 +450,7 @@ class Account : Service { */ @Throws(AppwriteException::class) suspend fun getPrefs( - ) = getPrefs( + ): io.appwrite.models.Preferences> = getPrefs( nestedType = classOf(), ) @@ -460,12 +460,12 @@ class Account : Service { * 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] + * @return [io.appwrite.models.User] */ suspend fun updatePrefs( prefs: Any, nestedType: Class, - ): io.appwrite.models.Account { + ): io.appwrite.models.User { val path = "/account/prefs" val params = mutableMapOf( @@ -474,8 +474,8 @@ class Account : Service { val headers = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it as Map, nestedType) + val converter: (Any) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( "PATCH", @@ -493,12 +493,12 @@ class Account : Service { * 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] + * @return [io.appwrite.models.User] */ @Throws(AppwriteException::class) suspend fun updatePrefs( prefs: Any, - ) = updatePrefs( + ): io.appwrite.models.User> = updatePrefs( prefs, nestedType = classOf(), ) @@ -670,7 +670,7 @@ class Account : Service { /** * 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.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](/docs/authentication#limits). + * 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-security#limits). * * @param email User email. * @param password User password. Must be at least 8 chars. @@ -706,7 +706,7 @@ class Account : Service { /** * 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.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](/docs/authentication#limits). + * 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-security#limits). * * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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. @@ -782,7 +782,7 @@ class Account : Service { /** * 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). + * 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-security#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. @@ -854,7 +854,7 @@ 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.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](/docs/authentication#limits). + * 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-security#limits). * * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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. @@ -1023,11 +1023,11 @@ class Account : Service { * * 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.User] */ suspend fun updateStatus( nestedType: Class, - ): io.appwrite.models.Account { + ): io.appwrite.models.User { val path = "/account/status" val params = mutableMapOf( @@ -1035,8 +1035,8 @@ class Account : Service { val headers = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.Account = { - io.appwrite.models.Account.from(map = it as Map, nestedType) + val converter: (Any) -> io.appwrite.models.User = { + io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( "PATCH", @@ -1053,11 +1053,11 @@ class Account : Service { * * 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.User] */ @Throws(AppwriteException::class) suspend fun updateStatus( - ) = updateStatus( + ): io.appwrite.models.User> = updateStatus( nestedType = classOf(), ) diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index 26094eb..0744693 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -22,7 +22,7 @@ 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 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. + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.DocumentList] */ @JvmOverloads @@ -62,7 +62,7 @@ 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 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. + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.DocumentList] */ @JvmOverloads @@ -71,7 +71,7 @@ class Databases : Service { databaseId: String, collectionId: String, queries: List? = null, - ) = listDocuments( + ): io.appwrite.models.DocumentList> = listDocuments( databaseId, collectionId, queries, @@ -144,7 +144,7 @@ class Databases : Service { documentId: String, data: Any, permissions: List? = null, - ) = createDocument( + ): io.appwrite.models.Document> = createDocument( databaseId, collectionId, documentId, @@ -161,12 +161,15 @@ 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. + * @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 method allowed is select. * @return [io.appwrite.models.Document] */ + @JvmOverloads suspend fun getDocument( databaseId: String, collectionId: String, documentId: String, + queries: List? = null, nestedType: Class, ): io.appwrite.models.Document { val path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" @@ -175,6 +178,7 @@ class Databases : Service { .replace("{documentId}", documentId) val params = mutableMapOf( + "queries" to queries, ) val headers = mutableMapOf( "content-type" to "application/json", @@ -200,17 +204,21 @@ 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. + * @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 method allowed is select. * @return [io.appwrite.models.Document] */ + @JvmOverloads @Throws(AppwriteException::class) suspend fun getDocument( databaseId: String, collectionId: String, documentId: String, - ) = getDocument( + queries: List? = null, + ): io.appwrite.models.Document> = getDocument( databaseId, collectionId, documentId, + queries, nestedType = classOf(), ) @@ -280,7 +288,7 @@ class Databases : Service { documentId: String, data: Any? = null, permissions: List? = null, - ) = updateDocument( + ): io.appwrite.models.Document> = updateDocument( databaseId, collectionId, documentId, diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index a9d33ca..ffa350a 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -21,7 +21,7 @@ class Functions : Service { * 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 queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). 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] */ diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index fd7dc1b..ecc9284 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -23,7 +23,7 @@ class Storage : Service { * 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 queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). 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] */ diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index e188330..333f438 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -20,15 +20,16 @@ class Teams : Service { * * Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results. * - * @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 queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). 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 - suspend fun list( + suspend fun list( queries: List? = null, search: String? = null, - ): io.appwrite.models.TeamList { + nestedType: Class, + ): io.appwrite.models.TeamList { val path = "/teams" val params = mutableMapOf( @@ -38,19 +39,38 @@ class Teams : Service { val headers = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.TeamList = { - io.appwrite.models.TeamList.from(map = it as Map) + val converter: (Any) -> io.appwrite.models.TeamList = { + io.appwrite.models.TeamList.from(map = it as Map, nestedType) } return client.call( "GET", path, headers, params, - responseType = io.appwrite.models.TeamList::class.java, + responseType = classOf(), converter, ) } + /** + * 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. + * + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). 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] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun list( + queries: List? = null, + search: String? = null, + ): io.appwrite.models.TeamList> = list( + queries, + search, + nestedType = classOf(), + ) /** * Create Team @@ -60,14 +80,15 @@ class Teams : Service { * @param teamId Team ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 - suspend fun create( + suspend fun create( teamId: String, name: String, roles: List? = null, - ): io.appwrite.models.Team { + nestedType: Class, + ): io.appwrite.models.Team { val path = "/teams" val params = mutableMapOf( @@ -78,19 +99,41 @@ class Teams : Service { val headers = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.Team = { - io.appwrite.models.Team.from(map = it as Map) + val converter: (Any) -> io.appwrite.models.Team = { + io.appwrite.models.Team.from(map = it as Map, nestedType) } return client.call( "POST", path, headers, params, - responseType = io.appwrite.models.Team::class.java, + responseType = classOf(), 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. + * + * @param teamId Team ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun create( + teamId: String, + name: String, + roles: List? = null, + ): io.appwrite.models.Team> = create( + teamId, + name, + roles, + nestedType = classOf(), + ) /** * Get Team @@ -98,11 +141,12 @@ class Teams : Service { * 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] */ - suspend fun get( + suspend fun get( teamId: String, - ): io.appwrite.models.Team { + nestedType: Class, + ): io.appwrite.models.Team { val path = "/teams/{teamId}" .replace("{teamId}", teamId) @@ -111,33 +155,49 @@ class Teams : Service { val headers = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.Team = { - io.appwrite.models.Team.from(map = it as Map) + val converter: (Any) -> io.appwrite.models.Team = { + io.appwrite.models.Team.from(map = it as Map, nestedType) } return client.call( "GET", path, headers, params, - responseType = io.appwrite.models.Team::class.java, + responseType = classOf(), 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] + */ + @Throws(AppwriteException::class) + suspend fun get( + teamId: String, + ): io.appwrite.models.Team> = get( + teamId, + nestedType = classOf(), + ) /** - * Update Team + * Update Name * - * Update a team using its ID. Only members with the owner role can update the team. + * Update the team's name by its unique ID. * * @param teamId Team ID. * @param name New team name. Max length: 128 chars. - * @return [io.appwrite.models.Team] + * @return [io.appwrite.models.Team] */ - suspend fun update( + suspend fun updateName( teamId: String, name: String, - ): io.appwrite.models.Team { + nestedType: Class, + ): io.appwrite.models.Team { val path = "/teams/{teamId}" .replace("{teamId}", teamId) @@ -147,19 +207,37 @@ class Teams : Service { val headers = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.Team = { - io.appwrite.models.Team.from(map = it as Map) + val converter: (Any) -> io.appwrite.models.Team = { + io.appwrite.models.Team.from(map = it as Map, nestedType) } return client.call( "PUT", path, headers, params, - responseType = io.appwrite.models.Team::class.java, + responseType = classOf(), converter, ) } + /** + * Update Name + * + * Update the team's name by its unique ID. + * + * @param teamId Team ID. + * @param name New team name. Max length: 128 chars. + * @return [io.appwrite.models.Team] + */ + @Throws(AppwriteException::class) + suspend fun updateName( + teamId: String, + name: String, + ): io.appwrite.models.Team> = updateName( + teamId, + name, + nestedType = classOf(), + ) /** * Delete Team @@ -196,7 +274,7 @@ class Teams : Service { * 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 queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). 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] */ @@ -233,21 +311,25 @@ class Teams : Service { /** * 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. Provide an ID for existing users, or invite unregistered users using an email or phone number. If initiated from a Client SDK, Appwrite will send an email or sms with a link to join the team to the invited user, and an account will be created for them if one doesn't exist. If initiated from a Server SDK, the new member will be added automatically to the team.You only need to provide one of a user ID, email, or phone number. Appwrite will prioritize accepting the user ID > email > phone number if you provide more than one of these parameters.Use the `url` parameter to redirect the user from the invitation email to your app. After 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) Appwrite will accept the only redirect URLs under the domains you have added as a platform on the Appwrite Console. * * @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 email Email of the new team member. + * @param userId ID of the user to be added to a team. + * @param phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @param name Name of the new team member. Max length: 128 chars. * @return [io.appwrite.models.Membership] */ @JvmOverloads suspend fun createMembership( teamId: String, - email: String, roles: List, url: String, + email: String? = null, + userId: String? = null, + phone: String? = null, name: String? = null, ): io.appwrite.models.Membership { val path = "/teams/{teamId}/memberships" @@ -255,6 +337,8 @@ class Teams : Service { val params = mutableMapOf( "email" to email, + "userId" to userId, + "phone" to phone, "roles" to roles, "url" to url, "name" to name, @@ -425,4 +509,108 @@ class Teams : Service { } + /** + * Get Team Preferences + * + * Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in [user preferences](/docs/client/account#accountGetPrefs). + * + * @param teamId Team ID. + * @return [io.appwrite.models.Preferences] + */ + suspend fun getPrefs( + teamId: String, + nestedType: Class, + ): io.appwrite.models.Preferences { + val path = "/teams/{teamId}/prefs" + .replace("{teamId}", teamId) + + val params = mutableMapOf( + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + 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 = classOf(), + converter, + ) + } + + /** + * Get Team Preferences + * + * Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in [user preferences](/docs/client/account#accountGetPrefs). + * + * @param teamId Team ID. + * @return [io.appwrite.models.Preferences] + */ + @Throws(AppwriteException::class) + suspend fun getPrefs( + teamId: String, + ): io.appwrite.models.Preferences> = getPrefs( + teamId, + nestedType = classOf(), + ) + + /** + * Update Preferences + * + * Update the team's preferences by its unique ID. The object you pass is stored as is and replaces any previous value. The maximum allowed prefs size is 64kB and throws an error if exceeded. + * + * @param teamId Team ID. + * @param prefs Prefs key-value JSON object. + * @return [io.appwrite.models.Preferences] + */ + suspend fun updatePrefs( + teamId: String, + prefs: Any, + nestedType: Class, + ): io.appwrite.models.Preferences { + val path = "/teams/{teamId}/prefs" + .replace("{teamId}", teamId) + + val params = mutableMapOf( + "prefs" to prefs, + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Preferences = { + io.appwrite.models.Preferences.from(map = it as Map, nestedType) + } + return client.call( + "PUT", + path, + headers, + params, + responseType = classOf(), + converter, + ) + } + + /** + * Update Preferences + * + * Update the team's preferences by its unique ID. The object you pass is stored as is and replaces any previous value. The maximum allowed prefs size is 64kB and throws an error if exceeded. + * + * @param teamId Team ID. + * @param prefs Prefs key-value JSON object. + * @return [io.appwrite.models.Preferences] + */ + @Throws(AppwriteException::class) + suspend fun updatePrefs( + teamId: String, + prefs: Any, + ): io.appwrite.models.Preferences> = updatePrefs( + teamId, + prefs, + nestedType = classOf(), + ) + } \ No newline at end of file From 06fcf67fa042b39f358fc9dcf7856023591c8e98 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 12 Apr 2023 20:36:02 +1200 Subject: [PATCH 048/118] Updates for 1.3.x --- README.md | 6 +++--- library/src/main/java/io/appwrite/Client.kt | 2 +- library/src/main/java/io/appwrite/services/Storage.kt | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 97b1780..304c80c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![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.2.1-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.3.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) @@ -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.3.0") +implementation("io.appwrite:sdk-for-android:2.0.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 1.3.0 + 2.0.0 ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 4460d4d..fe1234d 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.3.0", + "x-sdk-version" to "2.0.0", "x-appwrite-response-format" to "1.0.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index ecc9284..1dc5617 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -64,7 +64,7 @@ class Storage : Service { * * @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 a custom ID or generate a random ID with `ID.unique()`. 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 file Binary file. Appwrite SDKs provide helpers to handle file input. [Learn about file input](/docs/storage#file-input). * @param permissions An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](/docs/permissions). * @return [io.appwrite.models.File] */ From 267ece239014be9cd6325edd380f748cd3ab18bb Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 30 Aug 2023 10:29:53 +0200 Subject: [PATCH 049/118] feat: release 1.4.0 --- README.md | 8 +- .../java/account/create-anonymous-session.md | 2 +- .../java/account/create-email-session.md | 2 +- docs/examples/java/account/create-j-w-t.md | 2 +- .../account/create-magic-u-r-l-session.md | 2 +- .../java/account/create-o-auth2session.md | 2 +- .../java/account/create-phone-session.md | 2 +- .../java/account/create-phone-verification.md | 2 +- docs/examples/java/account/create-recovery.md | 2 +- .../java/account/create-verification.md | 2 +- docs/examples/java/account/create.md | 2 +- docs/examples/java/account/delete-identity.md | 21 ++ docs/examples/java/account/delete-session.md | 2 +- docs/examples/java/account/delete-sessions.md | 2 +- docs/examples/java/account/get-prefs.md | 2 +- docs/examples/java/account/get-session.md | 2 +- docs/examples/java/account/get.md | 2 +- docs/examples/java/account/list-identities.md | 20 ++ docs/examples/java/account/list-logs.md | 2 +- docs/examples/java/account/list-sessions.md | 2 +- docs/examples/java/account/update-email.md | 2 +- .../account/update-magic-u-r-l-session.md | 2 +- docs/examples/java/account/update-name.md | 2 +- docs/examples/java/account/update-password.md | 2 +- .../java/account/update-phone-session.md | 2 +- .../java/account/update-phone-verification.md | 2 +- docs/examples/java/account/update-phone.md | 2 +- docs/examples/java/account/update-prefs.md | 2 +- docs/examples/java/account/update-recovery.md | 2 +- docs/examples/java/account/update-session.md | 2 +- docs/examples/java/account/update-status.md | 2 +- .../java/account/update-verification.md | 2 +- docs/examples/java/assistant/chat.md | 21 ++ docs/examples/java/avatars/get-browser.md | 2 +- docs/examples/java/avatars/get-credit-card.md | 2 +- docs/examples/java/avatars/get-favicon.md | 2 +- docs/examples/java/avatars/get-flag.md | 2 +- docs/examples/java/avatars/get-image.md | 2 +- docs/examples/java/avatars/get-initials.md | 2 +- docs/examples/java/avatars/get-q-r.md | 2 +- .../java/databases/create-document.md | 2 +- .../java/databases/delete-document.md | 2 +- docs/examples/java/databases/get-document.md | 2 +- .../examples/java/databases/list-documents.md | 2 +- .../java/databases/update-document.md | 2 +- .../java/functions/create-execution.md | 2 +- docs/examples/java/functions/get-execution.md | 2 +- .../java/functions/list-executions.md | 2 +- docs/examples/java/graphql/mutation.md | 2 +- docs/examples/java/graphql/query.md | 2 +- docs/examples/java/locale/get.md | 2 +- docs/examples/java/locale/list-codes.md | 18 ++ docs/examples/java/locale/list-continents.md | 2 +- .../java/locale/list-countries-e-u.md | 2 +- .../java/locale/list-countries-phones.md | 2 +- docs/examples/java/locale/list-countries.md | 2 +- docs/examples/java/locale/list-currencies.md | 2 +- docs/examples/java/locale/list-languages.md | 2 +- .../java/migrations/delete-firebase-auth.md | 18 ++ .../java/migrations/list-firebase-projects.md | 18 ++ docs/examples/java/storage/create-file.md | 2 +- docs/examples/java/storage/delete-file.md | 2 +- .../java/storage/get-file-download.md | 2 +- .../examples/java/storage/get-file-preview.md | 2 +- docs/examples/java/storage/get-file-view.md | 2 +- docs/examples/java/storage/get-file.md | 2 +- docs/examples/java/storage/list-files.md | 2 +- docs/examples/java/storage/update-file.md | 2 +- docs/examples/java/teams/create-membership.md | 2 +- docs/examples/java/teams/create.md | 2 +- docs/examples/java/teams/delete-membership.md | 2 +- docs/examples/java/teams/delete.md | 2 +- docs/examples/java/teams/get-membership.md | 2 +- docs/examples/java/teams/get-prefs.md | 2 +- docs/examples/java/teams/get.md | 2 +- docs/examples/java/teams/list-memberships.md | 2 +- docs/examples/java/teams/list.md | 2 +- .../java/teams/update-membership-status.md | 2 +- ...mbership-roles.md => update-membership.md} | 4 +- docs/examples/java/teams/update-name.md | 2 +- docs/examples/java/teams/update-prefs.md | 2 +- .../java/vcs/create-repository-detection.md | 22 ++ docs/examples/java/vcs/create-repository.md | 23 ++ docs/examples/java/vcs/get-repository.md | 22 ++ docs/examples/java/vcs/list-repositories.md | 21 ++ .../java/vcs/list-repository-branches.md | 22 ++ .../java/vcs/update-external-deployments.md | 23 ++ .../account/create-anonymous-session.md | 2 +- .../kotlin/account/create-email-session.md | 2 +- docs/examples/kotlin/account/create-j-w-t.md | 2 +- .../account/create-magic-u-r-l-session.md | 2 +- .../kotlin/account/create-o-auth2session.md | 2 +- .../kotlin/account/create-phone-session.md | 2 +- .../account/create-phone-verification.md | 2 +- .../kotlin/account/create-recovery.md | 2 +- .../kotlin/account/create-verification.md | 2 +- docs/examples/kotlin/account/create.md | 2 +- .../kotlin/account/delete-identity.md | 12 + .../examples/kotlin/account/delete-session.md | 2 +- .../kotlin/account/delete-sessions.md | 2 +- docs/examples/kotlin/account/get-prefs.md | 2 +- docs/examples/kotlin/account/get-session.md | 2 +- docs/examples/kotlin/account/get.md | 2 +- .../kotlin/account/list-identities.md | 11 + docs/examples/kotlin/account/list-logs.md | 2 +- docs/examples/kotlin/account/list-sessions.md | 2 +- docs/examples/kotlin/account/update-email.md | 2 +- .../account/update-magic-u-r-l-session.md | 2 +- docs/examples/kotlin/account/update-name.md | 2 +- .../kotlin/account/update-password.md | 2 +- .../kotlin/account/update-phone-session.md | 2 +- .../account/update-phone-verification.md | 2 +- docs/examples/kotlin/account/update-phone.md | 2 +- docs/examples/kotlin/account/update-prefs.md | 2 +- .../kotlin/account/update-recovery.md | 2 +- .../examples/kotlin/account/update-session.md | 2 +- docs/examples/kotlin/account/update-status.md | 2 +- .../kotlin/account/update-verification.md | 2 +- docs/examples/kotlin/assistant/chat.md | 12 + docs/examples/kotlin/avatars/get-browser.md | 2 +- .../kotlin/avatars/get-credit-card.md | 2 +- docs/examples/kotlin/avatars/get-favicon.md | 2 +- docs/examples/kotlin/avatars/get-flag.md | 2 +- docs/examples/kotlin/avatars/get-image.md | 2 +- docs/examples/kotlin/avatars/get-initials.md | 2 +- docs/examples/kotlin/avatars/get-q-r.md | 2 +- .../kotlin/databases/create-document.md | 2 +- .../kotlin/databases/delete-document.md | 2 +- .../examples/kotlin/databases/get-document.md | 2 +- .../kotlin/databases/list-documents.md | 2 +- .../kotlin/databases/update-document.md | 2 +- .../kotlin/functions/create-execution.md | 2 +- .../kotlin/functions/get-execution.md | 2 +- .../kotlin/functions/list-executions.md | 2 +- docs/examples/kotlin/graphql/mutation.md | 2 +- docs/examples/kotlin/graphql/query.md | 2 +- docs/examples/kotlin/locale/get.md | 2 +- docs/examples/kotlin/locale/list-codes.md | 10 + .../examples/kotlin/locale/list-continents.md | 2 +- .../kotlin/locale/list-countries-e-u.md | 2 +- .../kotlin/locale/list-countries-phones.md | 2 +- docs/examples/kotlin/locale/list-countries.md | 2 +- .../examples/kotlin/locale/list-currencies.md | 2 +- docs/examples/kotlin/locale/list-languages.md | 2 +- .../kotlin/migrations/delete-firebase-auth.md | 10 + .../migrations/list-firebase-projects.md | 10 + docs/examples/kotlin/storage/create-file.md | 2 +- docs/examples/kotlin/storage/delete-file.md | 2 +- .../kotlin/storage/get-file-download.md | 2 +- .../kotlin/storage/get-file-preview.md | 2 +- docs/examples/kotlin/storage/get-file-view.md | 2 +- docs/examples/kotlin/storage/get-file.md | 2 +- docs/examples/kotlin/storage/list-files.md | 2 +- docs/examples/kotlin/storage/update-file.md | 2 +- .../kotlin/teams/create-membership.md | 2 +- docs/examples/kotlin/teams/create.md | 2 +- .../kotlin/teams/delete-membership.md | 2 +- docs/examples/kotlin/teams/delete.md | 2 +- docs/examples/kotlin/teams/get-membership.md | 2 +- docs/examples/kotlin/teams/get-prefs.md | 2 +- docs/examples/kotlin/teams/get.md | 2 +- .../examples/kotlin/teams/list-memberships.md | 2 +- docs/examples/kotlin/teams/list.md | 2 +- .../kotlin/teams/update-membership-status.md | 2 +- ...mbership-roles.md => update-membership.md} | 4 +- docs/examples/kotlin/teams/update-name.md | 2 +- docs/examples/kotlin/teams/update-prefs.md | 2 +- .../kotlin/vcs/create-repository-detection.md | 13 + docs/examples/kotlin/vcs/create-repository.md | 14 + docs/examples/kotlin/vcs/get-repository.md | 13 + docs/examples/kotlin/vcs/list-repositories.md | 12 + .../kotlin/vcs/list-repository-branches.md | 13 + .../kotlin/vcs/update-external-deployments.md | 14 + library/src/main/java/io/appwrite/Client.kt | 4 +- .../main/java/io/appwrite/models/Branch.kt | 30 +++ .../java/io/appwrite/models/BranchList.kt | 38 +++ .../main/java/io/appwrite/models/Detection.kt | 30 +++ .../main/java/io/appwrite/models/Execution.kt | 74 ++++-- .../io/appwrite/models/FirebaseProject.kt | 38 +++ .../io/appwrite/models/FirebaseProjectList.kt | 38 +++ .../main/java/io/appwrite/models/Headers.kt | 38 +++ .../main/java/io/appwrite/models/Identity.kt | 102 ++++++++ .../java/io/appwrite/models/IdentityList.kt | 38 +++ .../java/io/appwrite/models/LocaleCode.kt | 38 +++ .../java/io/appwrite/models/LocaleCodeList.kt | 38 +++ .../io/appwrite/models/ProviderRepository.kt | 78 ++++++ .../appwrite/models/ProviderRepositoryList.kt | 38 +++ .../src/main/java/io/appwrite/models/User.kt | 20 ++ .../main/java/io/appwrite/services/Account.kt | 201 ++++++++++----- .../java/io/appwrite/services/Assistant.kt | 47 ++++ .../main/java/io/appwrite/services/Avatars.kt | 28 +- .../java/io/appwrite/services/Databases.kt | 20 +- .../java/io/appwrite/services/Functions.kt | 29 ++- .../main/java/io/appwrite/services/Graphql.kt | 8 +- .../main/java/io/appwrite/services/Locale.kt | 58 ++++- .../java/io/appwrite/services/Migrations.kt | 74 ++++++ .../main/java/io/appwrite/services/Storage.kt | 35 +-- .../main/java/io/appwrite/services/Teams.kt | 56 ++-- .../src/main/java/io/appwrite/services/Vcs.kt | 241 ++++++++++++++++++ 199 files changed, 1798 insertions(+), 342 deletions(-) create mode 100644 docs/examples/java/account/delete-identity.md create mode 100644 docs/examples/java/account/list-identities.md create mode 100644 docs/examples/java/assistant/chat.md create mode 100644 docs/examples/java/locale/list-codes.md create mode 100644 docs/examples/java/migrations/delete-firebase-auth.md create mode 100644 docs/examples/java/migrations/list-firebase-projects.md rename docs/examples/java/teams/{update-membership-roles.md => update-membership.md} (83%) create mode 100644 docs/examples/java/vcs/create-repository-detection.md create mode 100644 docs/examples/java/vcs/create-repository.md create mode 100644 docs/examples/java/vcs/get-repository.md create mode 100644 docs/examples/java/vcs/list-repositories.md create mode 100644 docs/examples/java/vcs/list-repository-branches.md create mode 100644 docs/examples/java/vcs/update-external-deployments.md create mode 100644 docs/examples/kotlin/account/delete-identity.md create mode 100644 docs/examples/kotlin/account/list-identities.md create mode 100644 docs/examples/kotlin/assistant/chat.md create mode 100644 docs/examples/kotlin/locale/list-codes.md create mode 100644 docs/examples/kotlin/migrations/delete-firebase-auth.md create mode 100644 docs/examples/kotlin/migrations/list-firebase-projects.md rename docs/examples/kotlin/teams/{update-membership-roles.md => update-membership.md} (69%) create mode 100644 docs/examples/kotlin/vcs/create-repository-detection.md create mode 100644 docs/examples/kotlin/vcs/create-repository.md create mode 100644 docs/examples/kotlin/vcs/get-repository.md create mode 100644 docs/examples/kotlin/vcs/list-repositories.md create mode 100644 docs/examples/kotlin/vcs/list-repository-branches.md create mode 100644 docs/examples/kotlin/vcs/update-external-deployments.md create mode 100644 library/src/main/java/io/appwrite/models/Branch.kt create mode 100644 library/src/main/java/io/appwrite/models/BranchList.kt create mode 100644 library/src/main/java/io/appwrite/models/Detection.kt create mode 100644 library/src/main/java/io/appwrite/models/FirebaseProject.kt create mode 100644 library/src/main/java/io/appwrite/models/FirebaseProjectList.kt create mode 100644 library/src/main/java/io/appwrite/models/Headers.kt create mode 100644 library/src/main/java/io/appwrite/models/Identity.kt create mode 100644 library/src/main/java/io/appwrite/models/IdentityList.kt create mode 100644 library/src/main/java/io/appwrite/models/LocaleCode.kt create mode 100644 library/src/main/java/io/appwrite/models/LocaleCodeList.kt create mode 100644 library/src/main/java/io/appwrite/models/ProviderRepository.kt create mode 100644 library/src/main/java/io/appwrite/models/ProviderRepositoryList.kt create mode 100644 library/src/main/java/io/appwrite/services/Assistant.kt create mode 100644 library/src/main/java/io/appwrite/services/Migrations.kt create mode 100644 library/src/main/java/io/appwrite/services/Vcs.kt diff --git a/README.md b/README.md index 304c80c..76ed518 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.3.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.4.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.3.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).** +**This SDK is compatible with Appwrite server version latest. 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:2.0.0") +implementation("io.appwrite:sdk-for-android:3.0.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 2.0.0 + 3.0.0 ``` diff --git a/docs/examples/java/account/create-anonymous-session.md b/docs/examples/java/account/create-anonymous-session.md index 7d2123b..59c7630 100644 --- a/docs/examples/java/account/create-anonymous-session.md +++ b/docs/examples/java/account/create-anonymous-session.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-email-session.md b/docs/examples/java/account/create-email-session.md index 384dbaf..e3e6fdd 100644 --- a/docs/examples/java/account/create-email-session.md +++ b/docs/examples/java/account/create-email-session.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-j-w-t.md b/docs/examples/java/account/create-j-w-t.md index 86ad905..c312386 100644 --- a/docs/examples/java/account/create-j-w-t.md +++ b/docs/examples/java/account/create-j-w-t.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); 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 1789eec..0ed43dc 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 @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-o-auth2session.md b/docs/examples/java/account/create-o-auth2session.md index a2f5d02..cb9386a 100644 --- a/docs/examples/java/account/create-o-auth2session.md +++ b/docs/examples/java/account/create-o-auth2session.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-phone-session.md b/docs/examples/java/account/create-phone-session.md index 7c54dbd..df5bc86 100644 --- a/docs/examples/java/account/create-phone-session.md +++ b/docs/examples/java/account/create-phone-session.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-phone-verification.md b/docs/examples/java/account/create-phone-verification.md index f3e9526..1545d0f 100644 --- a/docs/examples/java/account/create-phone-verification.md +++ b/docs/examples/java/account/create-phone-verification.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-recovery.md b/docs/examples/java/account/create-recovery.md index 44773dd..5e8584f 100644 --- a/docs/examples/java/account/create-recovery.md +++ b/docs/examples/java/account/create-recovery.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-verification.md b/docs/examples/java/account/create-verification.md index 02d2934..fcea98f 100644 --- a/docs/examples/java/account/create-verification.md +++ b/docs/examples/java/account/create-verification.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create.md b/docs/examples/java/account/create.md index 68bb47e..e08731f 100644 --- a/docs/examples/java/account/create.md +++ b/docs/examples/java/account/create.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/delete-identity.md b/docs/examples/java/account/delete-identity.md new file mode 100644 index 0000000..0d92d04 --- /dev/null +++ b/docs/examples/java/account/delete-identity.md @@ -0,0 +1,21 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.deleteIdentity( + "[IDENTITY_ID]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/account/delete-session.md b/docs/examples/java/account/delete-session.md index b42b841..28009d0 100644 --- a/docs/examples/java/account/delete-session.md +++ b/docs/examples/java/account/delete-session.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/delete-sessions.md b/docs/examples/java/account/delete-sessions.md index 847c5c1..6bdc840 100644 --- a/docs/examples/java/account/delete-sessions.md +++ b/docs/examples/java/account/delete-sessions.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/get-prefs.md b/docs/examples/java/account/get-prefs.md index d7777d8..9911ad3 100644 --- a/docs/examples/java/account/get-prefs.md +++ b/docs/examples/java/account/get-prefs.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/get-session.md b/docs/examples/java/account/get-session.md index b7861b2..fecb543 100644 --- a/docs/examples/java/account/get-session.md +++ b/docs/examples/java/account/get-session.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/get.md b/docs/examples/java/account/get.md index 1351652..2e5f40a 100644 --- a/docs/examples/java/account/get.md +++ b/docs/examples/java/account/get.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/list-identities.md b/docs/examples/java/account/list-identities.md new file mode 100644 index 0000000..d1f6a48 --- /dev/null +++ b/docs/examples/java/account/list-identities.md @@ -0,0 +1,20 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.listIdentities( + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/account/list-logs.md b/docs/examples/java/account/list-logs.md index d073d4e..d2ce790 100644 --- a/docs/examples/java/account/list-logs.md +++ b/docs/examples/java/account/list-logs.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/list-sessions.md b/docs/examples/java/account/list-sessions.md index 91888bc..7fd587e 100644 --- a/docs/examples/java/account/list-sessions.md +++ b/docs/examples/java/account/list-sessions.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-email.md b/docs/examples/java/account/update-email.md index 53dd0bd..8034ada 100644 --- a/docs/examples/java/account/update-email.md +++ b/docs/examples/java/account/update-email.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); 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 e56da73..0f8f2b3 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 @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-name.md b/docs/examples/java/account/update-name.md index c722c85..5940f93 100644 --- a/docs/examples/java/account/update-name.md +++ b/docs/examples/java/account/update-name.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-password.md b/docs/examples/java/account/update-password.md index aaaee66..d942632 100644 --- a/docs/examples/java/account/update-password.md +++ b/docs/examples/java/account/update-password.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-phone-session.md b/docs/examples/java/account/update-phone-session.md index 952c7e0..589e4ff 100644 --- a/docs/examples/java/account/update-phone-session.md +++ b/docs/examples/java/account/update-phone-session.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-phone-verification.md b/docs/examples/java/account/update-phone-verification.md index ec5ddf1..81785f9 100644 --- a/docs/examples/java/account/update-phone-verification.md +++ b/docs/examples/java/account/update-phone-verification.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-phone.md b/docs/examples/java/account/update-phone.md index 61cff45..a8572f9 100644 --- a/docs/examples/java/account/update-phone.md +++ b/docs/examples/java/account/update-phone.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-prefs.md b/docs/examples/java/account/update-prefs.md index a004b45..ffd5ef0 100644 --- a/docs/examples/java/account/update-prefs.md +++ b/docs/examples/java/account/update-prefs.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-recovery.md b/docs/examples/java/account/update-recovery.md index e565a6b..7b0f392 100644 --- a/docs/examples/java/account/update-recovery.md +++ b/docs/examples/java/account/update-recovery.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-session.md b/docs/examples/java/account/update-session.md index 4c5d975..27b8f00 100644 --- a/docs/examples/java/account/update-session.md +++ b/docs/examples/java/account/update-session.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-status.md b/docs/examples/java/account/update-status.md index 739469a..1e18ded 100644 --- a/docs/examples/java/account/update-status.md +++ b/docs/examples/java/account/update-status.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-verification.md b/docs/examples/java/account/update-verification.md index b05dbc2..d852dbf 100644 --- a/docs/examples/java/account/update-verification.md +++ b/docs/examples/java/account/update-verification.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/assistant/chat.md b/docs/examples/java/assistant/chat.md new file mode 100644 index 0000000..62cf301 --- /dev/null +++ b/docs/examples/java/assistant/chat.md @@ -0,0 +1,21 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Assistant; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Assistant assistant = new Assistant(client); + +assistant.chat( + "[PROMPT]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/avatars/get-browser.md b/docs/examples/java/avatars/get-browser.md index 8ad3f18..f072110 100644 --- a/docs/examples/java/avatars/get-browser.md +++ b/docs/examples/java/avatars/get-browser.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Avatars; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-credit-card.md b/docs/examples/java/avatars/get-credit-card.md index 453718b..0a73312 100644 --- a/docs/examples/java/avatars/get-credit-card.md +++ b/docs/examples/java/avatars/get-credit-card.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Avatars; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-favicon.md b/docs/examples/java/avatars/get-favicon.md index a5b9fa6..e0c1cb6 100644 --- a/docs/examples/java/avatars/get-favicon.md +++ b/docs/examples/java/avatars/get-favicon.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Avatars; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-flag.md b/docs/examples/java/avatars/get-flag.md index 0bc4896..a5f4790 100644 --- a/docs/examples/java/avatars/get-flag.md +++ b/docs/examples/java/avatars/get-flag.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Avatars; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-image.md b/docs/examples/java/avatars/get-image.md index d77d79c..cdc8ac7 100644 --- a/docs/examples/java/avatars/get-image.md +++ b/docs/examples/java/avatars/get-image.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Avatars; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-initials.md b/docs/examples/java/avatars/get-initials.md index 491724f..c02490c 100644 --- a/docs/examples/java/avatars/get-initials.md +++ b/docs/examples/java/avatars/get-initials.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Avatars; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-q-r.md b/docs/examples/java/avatars/get-q-r.md index ae1a11d..2532f20 100644 --- a/docs/examples/java/avatars/get-q-r.md +++ b/docs/examples/java/avatars/get-q-r.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Avatars; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index d4412ce..715e4cd 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Databases; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Databases databases = new Databases(client); diff --git a/docs/examples/java/databases/delete-document.md b/docs/examples/java/databases/delete-document.md index 90ad1ce..1387f48 100644 --- a/docs/examples/java/databases/delete-document.md +++ b/docs/examples/java/databases/delete-document.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Databases; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Databases databases = new Databases(client); diff --git a/docs/examples/java/databases/get-document.md b/docs/examples/java/databases/get-document.md index 7e3b33b..b1a7161 100644 --- a/docs/examples/java/databases/get-document.md +++ b/docs/examples/java/databases/get-document.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Databases; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Databases databases = new Databases(client); diff --git a/docs/examples/java/databases/list-documents.md b/docs/examples/java/databases/list-documents.md index 6b897df..62dc2c7 100644 --- a/docs/examples/java/databases/list-documents.md +++ b/docs/examples/java/databases/list-documents.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Databases; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Databases databases = new Databases(client); diff --git a/docs/examples/java/databases/update-document.md b/docs/examples/java/databases/update-document.md index 7f04c8e..d1ed59d 100644 --- a/docs/examples/java/databases/update-document.md +++ b/docs/examples/java/databases/update-document.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Databases; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Databases databases = new Databases(client); diff --git a/docs/examples/java/functions/create-execution.md b/docs/examples/java/functions/create-execution.md index ee4eaf5..3cce1c3 100644 --- a/docs/examples/java/functions/create-execution.md +++ b/docs/examples/java/functions/create-execution.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Functions; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Functions functions = new Functions(client); diff --git a/docs/examples/java/functions/get-execution.md b/docs/examples/java/functions/get-execution.md index 90153f5..459d743 100644 --- a/docs/examples/java/functions/get-execution.md +++ b/docs/examples/java/functions/get-execution.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Functions; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Functions functions = new Functions(client); diff --git a/docs/examples/java/functions/list-executions.md b/docs/examples/java/functions/list-executions.md index fca903b..c1f982b 100644 --- a/docs/examples/java/functions/list-executions.md +++ b/docs/examples/java/functions/list-executions.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Functions; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Functions functions = new Functions(client); diff --git a/docs/examples/java/graphql/mutation.md b/docs/examples/java/graphql/mutation.md index e6ced40..262e513 100644 --- a/docs/examples/java/graphql/mutation.md +++ b/docs/examples/java/graphql/mutation.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Graphql; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Graphql graphql = new Graphql(client); diff --git a/docs/examples/java/graphql/query.md b/docs/examples/java/graphql/query.md index f0b8a86..4291b47 100644 --- a/docs/examples/java/graphql/query.md +++ b/docs/examples/java/graphql/query.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Graphql; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Graphql graphql = new Graphql(client); diff --git a/docs/examples/java/locale/get.md b/docs/examples/java/locale/get.md index 89de369..4d14be6 100644 --- a/docs/examples/java/locale/get.md +++ b/docs/examples/java/locale/get.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Locale; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-codes.md b/docs/examples/java/locale/list-codes.md new file mode 100644 index 0000000..599070e --- /dev/null +++ b/docs/examples/java/locale/list-codes.md @@ -0,0 +1,18 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Locale; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Locale locale = new Locale(client); + +locale.listCodes(new CoroutineCallback<>((result, error) -> { + if (error != null) + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/locale/list-continents.md b/docs/examples/java/locale/list-continents.md index 7205ad6..6abe97a 100644 --- a/docs/examples/java/locale/list-continents.md +++ b/docs/examples/java/locale/list-continents.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Locale; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-countries-e-u.md b/docs/examples/java/locale/list-countries-e-u.md index d6f37be..3c5ca3a 100644 --- a/docs/examples/java/locale/list-countries-e-u.md +++ b/docs/examples/java/locale/list-countries-e-u.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Locale; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-countries-phones.md b/docs/examples/java/locale/list-countries-phones.md index 1f947fe..81ef94d 100644 --- a/docs/examples/java/locale/list-countries-phones.md +++ b/docs/examples/java/locale/list-countries-phones.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Locale; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-countries.md b/docs/examples/java/locale/list-countries.md index 5b8c0ba..dc0d5f5 100644 --- a/docs/examples/java/locale/list-countries.md +++ b/docs/examples/java/locale/list-countries.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Locale; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-currencies.md b/docs/examples/java/locale/list-currencies.md index 880e1b2..7a327b3 100644 --- a/docs/examples/java/locale/list-currencies.md +++ b/docs/examples/java/locale/list-currencies.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Locale; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-languages.md b/docs/examples/java/locale/list-languages.md index 318c6dc..0688614 100644 --- a/docs/examples/java/locale/list-languages.md +++ b/docs/examples/java/locale/list-languages.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Locale; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/migrations/delete-firebase-auth.md b/docs/examples/java/migrations/delete-firebase-auth.md new file mode 100644 index 0000000..ab56fe9 --- /dev/null +++ b/docs/examples/java/migrations/delete-firebase-auth.md @@ -0,0 +1,18 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Migrations; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Migrations migrations = new Migrations(client); + +migrations.deleteFirebaseAuth(new CoroutineCallback<>((result, error) -> { + if (error != null) + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/migrations/list-firebase-projects.md b/docs/examples/java/migrations/list-firebase-projects.md new file mode 100644 index 0000000..7dba57e --- /dev/null +++ b/docs/examples/java/migrations/list-firebase-projects.md @@ -0,0 +1,18 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Migrations; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Migrations migrations = new Migrations(client); + +migrations.listFirebaseProjects(new CoroutineCallback<>((result, error) -> { + if (error != null) + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/storage/create-file.md b/docs/examples/java/storage/create-file.md index 161f882..732b302 100644 --- a/docs/examples/java/storage/create-file.md +++ b/docs/examples/java/storage/create-file.md @@ -4,7 +4,7 @@ import io.appwrite.models.InputFile; import io.appwrite.services.Storage; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/delete-file.md b/docs/examples/java/storage/delete-file.md index 654c127..69a0f0f 100644 --- a/docs/examples/java/storage/delete-file.md +++ b/docs/examples/java/storage/delete-file.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Storage; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/get-file-download.md b/docs/examples/java/storage/get-file-download.md index f12302a..2ab30dc 100644 --- a/docs/examples/java/storage/get-file-download.md +++ b/docs/examples/java/storage/get-file-download.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Storage; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/get-file-preview.md b/docs/examples/java/storage/get-file-preview.md index 8487922..483f2fc 100644 --- a/docs/examples/java/storage/get-file-preview.md +++ b/docs/examples/java/storage/get-file-preview.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Storage; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/get-file-view.md b/docs/examples/java/storage/get-file-view.md index 825b538..5614b69 100644 --- a/docs/examples/java/storage/get-file-view.md +++ b/docs/examples/java/storage/get-file-view.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Storage; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/get-file.md b/docs/examples/java/storage/get-file.md index bf97922..4ae0de0 100644 --- a/docs/examples/java/storage/get-file.md +++ b/docs/examples/java/storage/get-file.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Storage; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/list-files.md b/docs/examples/java/storage/list-files.md index fdf3e4f..dedfb6c 100644 --- a/docs/examples/java/storage/list-files.md +++ b/docs/examples/java/storage/list-files.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Storage; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/update-file.md b/docs/examples/java/storage/update-file.md index 9d9f192..9b4dd92 100644 --- a/docs/examples/java/storage/update-file.md +++ b/docs/examples/java/storage/update-file.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Storage; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/teams/create-membership.md b/docs/examples/java/teams/create-membership.md index 0e5590d..6c8b383 100644 --- a/docs/examples/java/teams/create-membership.md +++ b/docs/examples/java/teams/create-membership.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/create.md b/docs/examples/java/teams/create.md index 52207c6..263fa57 100644 --- a/docs/examples/java/teams/create.md +++ b/docs/examples/java/teams/create.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/delete-membership.md b/docs/examples/java/teams/delete-membership.md index 92d6d37..40f28f0 100644 --- a/docs/examples/java/teams/delete-membership.md +++ b/docs/examples/java/teams/delete-membership.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/delete.md b/docs/examples/java/teams/delete.md index ed81195..5b4c378 100644 --- a/docs/examples/java/teams/delete.md +++ b/docs/examples/java/teams/delete.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/get-membership.md b/docs/examples/java/teams/get-membership.md index 7e29171..f2f1d99 100644 --- a/docs/examples/java/teams/get-membership.md +++ b/docs/examples/java/teams/get-membership.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/get-prefs.md b/docs/examples/java/teams/get-prefs.md index bbf1256..6963cb4 100644 --- a/docs/examples/java/teams/get-prefs.md +++ b/docs/examples/java/teams/get-prefs.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/get.md b/docs/examples/java/teams/get.md index 36063c5..549af20 100644 --- a/docs/examples/java/teams/get.md +++ b/docs/examples/java/teams/get.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/list-memberships.md b/docs/examples/java/teams/list-memberships.md index d195978..3da4e33 100644 --- a/docs/examples/java/teams/list-memberships.md +++ b/docs/examples/java/teams/list-memberships.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/list.md b/docs/examples/java/teams/list.md index b4998ff..b20ad4a 100644 --- a/docs/examples/java/teams/list.md +++ b/docs/examples/java/teams/list.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/update-membership-status.md b/docs/examples/java/teams/update-membership-status.md index 1015b2e..499251f 100644 --- a/docs/examples/java/teams/update-membership-status.md +++ b/docs/examples/java/teams/update-membership-status.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/update-membership-roles.md b/docs/examples/java/teams/update-membership.md similarity index 83% rename from docs/examples/java/teams/update-membership-roles.md rename to docs/examples/java/teams/update-membership.md index 680c9a3..6cb3346 100644 --- a/docs/examples/java/teams/update-membership-roles.md +++ b/docs/examples/java/teams/update-membership.md @@ -3,12 +3,12 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Teams teams = new Teams(client); -teams.updateMembershipRoles( +teams.updateMembership( "[TEAM_ID]", "[MEMBERSHIP_ID]", listOf() diff --git a/docs/examples/java/teams/update-name.md b/docs/examples/java/teams/update-name.md index 22a2ee0..170ee59 100644 --- a/docs/examples/java/teams/update-name.md +++ b/docs/examples/java/teams/update-name.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/update-prefs.md b/docs/examples/java/teams/update-prefs.md index a4cf82d..a19ad82 100644 --- a/docs/examples/java/teams/update-prefs.md +++ b/docs/examples/java/teams/update-prefs.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/vcs/create-repository-detection.md b/docs/examples/java/vcs/create-repository-detection.md new file mode 100644 index 0000000..640414c --- /dev/null +++ b/docs/examples/java/vcs/create-repository-detection.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Vcs; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Vcs vcs = new Vcs(client); + +vcs.createRepositoryDetection( + "[INSTALLATION_ID]", + "[PROVIDER_REPOSITORY_ID]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/vcs/create-repository.md b/docs/examples/java/vcs/create-repository.md new file mode 100644 index 0000000..ebc22b3 --- /dev/null +++ b/docs/examples/java/vcs/create-repository.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Vcs; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Vcs vcs = new Vcs(client); + +vcs.createRepository( + "[INSTALLATION_ID]", + "[NAME]", + false + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/vcs/get-repository.md b/docs/examples/java/vcs/get-repository.md new file mode 100644 index 0000000..2e03db2 --- /dev/null +++ b/docs/examples/java/vcs/get-repository.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Vcs; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Vcs vcs = new Vcs(client); + +vcs.getRepository( + "[INSTALLATION_ID]", + "[PROVIDER_REPOSITORY_ID]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/vcs/list-repositories.md b/docs/examples/java/vcs/list-repositories.md new file mode 100644 index 0000000..3ebd41d --- /dev/null +++ b/docs/examples/java/vcs/list-repositories.md @@ -0,0 +1,21 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Vcs; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Vcs vcs = new Vcs(client); + +vcs.listRepositories( + "[INSTALLATION_ID]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/vcs/list-repository-branches.md b/docs/examples/java/vcs/list-repository-branches.md new file mode 100644 index 0000000..3cb3663 --- /dev/null +++ b/docs/examples/java/vcs/list-repository-branches.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Vcs; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Vcs vcs = new Vcs(client); + +vcs.listRepositoryBranches( + "[INSTALLATION_ID]", + "[PROVIDER_REPOSITORY_ID]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); diff --git a/docs/examples/java/vcs/update-external-deployments.md b/docs/examples/java/vcs/update-external-deployments.md new file mode 100644 index 0000000..0f27f4a --- /dev/null +++ b/docs/examples/java/vcs/update-external-deployments.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Vcs; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Vcs vcs = new Vcs(client); + +vcs.updateExternalDeployments( + "[INSTALLATION_ID]", + "[REPOSITORY_ID]", + "[PROVIDER_PULL_REQUEST_ID]" + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + 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 ccefc0a..cdcf401 100644 --- a/docs/examples/kotlin/account/create-anonymous-session.md +++ b/docs/examples/kotlin/account/create-anonymous-session.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-email-session.md b/docs/examples/kotlin/account/create-email-session.md index c58799c..ab8d581 100644 --- a/docs/examples/kotlin/account/create-email-session.md +++ b/docs/examples/kotlin/account/create-email-session.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-j-w-t.md b/docs/examples/kotlin/account/create-j-w-t.md index 59b7398..35e7a6f 100644 --- a/docs/examples/kotlin/account/create-j-w-t.md +++ b/docs/examples/kotlin/account/create-j-w-t.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) 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 5f36940..51368b5 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 @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-o-auth2session.md b/docs/examples/kotlin/account/create-o-auth2session.md index f909b59..395bfad 100644 --- a/docs/examples/kotlin/account/create-o-auth2session.md +++ b/docs/examples/kotlin/account/create-o-auth2session.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-phone-session.md b/docs/examples/kotlin/account/create-phone-session.md index 8f63c64..eed6f7a 100644 --- a/docs/examples/kotlin/account/create-phone-session.md +++ b/docs/examples/kotlin/account/create-phone-session.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-phone-verification.md b/docs/examples/kotlin/account/create-phone-verification.md index af36502..12fb9f7 100644 --- a/docs/examples/kotlin/account/create-phone-verification.md +++ b/docs/examples/kotlin/account/create-phone-verification.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-recovery.md b/docs/examples/kotlin/account/create-recovery.md index 23a3424..7d73a67 100644 --- a/docs/examples/kotlin/account/create-recovery.md +++ b/docs/examples/kotlin/account/create-recovery.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-verification.md b/docs/examples/kotlin/account/create-verification.md index 3fed01b..b3dc43a 100644 --- a/docs/examples/kotlin/account/create-verification.md +++ b/docs/examples/kotlin/account/create-verification.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create.md b/docs/examples/kotlin/account/create.md index eda87d3..c72ae90 100644 --- a/docs/examples/kotlin/account/create.md +++ b/docs/examples/kotlin/account/create.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/delete-identity.md b/docs/examples/kotlin/account/delete-identity.md new file mode 100644 index 0000000..440333e --- /dev/null +++ b/docs/examples/kotlin/account/delete-identity.md @@ -0,0 +1,12 @@ +import io.appwrite.Client +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val response = account.deleteIdentity( + identityId = "[IDENTITY_ID]" +) diff --git a/docs/examples/kotlin/account/delete-session.md b/docs/examples/kotlin/account/delete-session.md index 5c8988f..a98a286 100644 --- a/docs/examples/kotlin/account/delete-session.md +++ b/docs/examples/kotlin/account/delete-session.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/delete-sessions.md b/docs/examples/kotlin/account/delete-sessions.md index 86c9bc9..c9afbf1 100644 --- a/docs/examples/kotlin/account/delete-sessions.md +++ b/docs/examples/kotlin/account/delete-sessions.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/get-prefs.md b/docs/examples/kotlin/account/get-prefs.md index 70fa291..bd3f81a 100644 --- a/docs/examples/kotlin/account/get-prefs.md +++ b/docs/examples/kotlin/account/get-prefs.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/get-session.md b/docs/examples/kotlin/account/get-session.md index 58248ae..d6d6c72 100644 --- a/docs/examples/kotlin/account/get-session.md +++ b/docs/examples/kotlin/account/get-session.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/get.md b/docs/examples/kotlin/account/get.md index 09b0a17..4c8f0be 100644 --- a/docs/examples/kotlin/account/get.md +++ b/docs/examples/kotlin/account/get.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/list-identities.md b/docs/examples/kotlin/account/list-identities.md new file mode 100644 index 0000000..3292b35 --- /dev/null +++ b/docs/examples/kotlin/account/list-identities.md @@ -0,0 +1,11 @@ +import io.appwrite.Client +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val response = account.listIdentities( +) diff --git a/docs/examples/kotlin/account/list-logs.md b/docs/examples/kotlin/account/list-logs.md index dda9c72..eb337ca 100644 --- a/docs/examples/kotlin/account/list-logs.md +++ b/docs/examples/kotlin/account/list-logs.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/list-sessions.md b/docs/examples/kotlin/account/list-sessions.md index b7bb447..cd9f63b 100644 --- a/docs/examples/kotlin/account/list-sessions.md +++ b/docs/examples/kotlin/account/list-sessions.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-email.md b/docs/examples/kotlin/account/update-email.md index 2d1b66b..85a0242 100644 --- a/docs/examples/kotlin/account/update-email.md +++ b/docs/examples/kotlin/account/update-email.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) 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 49af217..c7286ba 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 @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-name.md b/docs/examples/kotlin/account/update-name.md index 5799344..574f493 100644 --- a/docs/examples/kotlin/account/update-name.md +++ b/docs/examples/kotlin/account/update-name.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-password.md b/docs/examples/kotlin/account/update-password.md index 14e746f..c5338b8 100644 --- a/docs/examples/kotlin/account/update-password.md +++ b/docs/examples/kotlin/account/update-password.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-phone-session.md b/docs/examples/kotlin/account/update-phone-session.md index 6efa2a4..d3b02e0 100644 --- a/docs/examples/kotlin/account/update-phone-session.md +++ b/docs/examples/kotlin/account/update-phone-session.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-phone-verification.md b/docs/examples/kotlin/account/update-phone-verification.md index 1b90372..0314f74 100644 --- a/docs/examples/kotlin/account/update-phone-verification.md +++ b/docs/examples/kotlin/account/update-phone-verification.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-phone.md b/docs/examples/kotlin/account/update-phone.md index 0534220..76eb8aa 100644 --- a/docs/examples/kotlin/account/update-phone.md +++ b/docs/examples/kotlin/account/update-phone.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-prefs.md b/docs/examples/kotlin/account/update-prefs.md index 408988b..f16e40b 100644 --- a/docs/examples/kotlin/account/update-prefs.md +++ b/docs/examples/kotlin/account/update-prefs.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-recovery.md b/docs/examples/kotlin/account/update-recovery.md index fd28f6e..9682899 100644 --- a/docs/examples/kotlin/account/update-recovery.md +++ b/docs/examples/kotlin/account/update-recovery.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-session.md b/docs/examples/kotlin/account/update-session.md index 67d900e..e9e83d0 100644 --- a/docs/examples/kotlin/account/update-session.md +++ b/docs/examples/kotlin/account/update-session.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-status.md b/docs/examples/kotlin/account/update-status.md index 35a4027..f7789ea 100644 --- a/docs/examples/kotlin/account/update-status.md +++ b/docs/examples/kotlin/account/update-status.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-verification.md b/docs/examples/kotlin/account/update-verification.md index f87192e..af800c1 100644 --- a/docs/examples/kotlin/account/update-verification.md +++ b/docs/examples/kotlin/account/update-verification.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/assistant/chat.md b/docs/examples/kotlin/assistant/chat.md new file mode 100644 index 0000000..ef4381b --- /dev/null +++ b/docs/examples/kotlin/assistant/chat.md @@ -0,0 +1,12 @@ +import io.appwrite.Client +import io.appwrite.services.Assistant + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val assistant = Assistant(client) + +val response = assistant.chat( + prompt = "[PROMPT]" +) diff --git a/docs/examples/kotlin/avatars/get-browser.md b/docs/examples/kotlin/avatars/get-browser.md index 9ea6739..b1b2d08 100644 --- a/docs/examples/kotlin/avatars/get-browser.md +++ b/docs/examples/kotlin/avatars/get-browser.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Avatars val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-credit-card.md b/docs/examples/kotlin/avatars/get-credit-card.md index cf82474..411e05a 100644 --- a/docs/examples/kotlin/avatars/get-credit-card.md +++ b/docs/examples/kotlin/avatars/get-credit-card.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Avatars val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-favicon.md b/docs/examples/kotlin/avatars/get-favicon.md index 102d773..1a4b217 100644 --- a/docs/examples/kotlin/avatars/get-favicon.md +++ b/docs/examples/kotlin/avatars/get-favicon.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Avatars val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-flag.md b/docs/examples/kotlin/avatars/get-flag.md index 7a618a7..5c882d6 100644 --- a/docs/examples/kotlin/avatars/get-flag.md +++ b/docs/examples/kotlin/avatars/get-flag.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Avatars val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-image.md b/docs/examples/kotlin/avatars/get-image.md index fc1fe1d..20d8dff 100644 --- a/docs/examples/kotlin/avatars/get-image.md +++ b/docs/examples/kotlin/avatars/get-image.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Avatars val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-initials.md b/docs/examples/kotlin/avatars/get-initials.md index 448467e..70ef9b2 100644 --- a/docs/examples/kotlin/avatars/get-initials.md +++ b/docs/examples/kotlin/avatars/get-initials.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Avatars val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-q-r.md b/docs/examples/kotlin/avatars/get-q-r.md index 8d24934..92b17e1 100644 --- a/docs/examples/kotlin/avatars/get-q-r.md +++ b/docs/examples/kotlin/avatars/get-q-r.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Avatars val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index da4d1eb..d7f1991 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Databases val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val databases = Databases(client) diff --git a/docs/examples/kotlin/databases/delete-document.md b/docs/examples/kotlin/databases/delete-document.md index bb2193e..c5bf2a2 100644 --- a/docs/examples/kotlin/databases/delete-document.md +++ b/docs/examples/kotlin/databases/delete-document.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Databases val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val databases = Databases(client) diff --git a/docs/examples/kotlin/databases/get-document.md b/docs/examples/kotlin/databases/get-document.md index 17c6047..abdee36 100644 --- a/docs/examples/kotlin/databases/get-document.md +++ b/docs/examples/kotlin/databases/get-document.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Databases val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val databases = Databases(client) diff --git a/docs/examples/kotlin/databases/list-documents.md b/docs/examples/kotlin/databases/list-documents.md index 0c2be1a..f97d878 100644 --- a/docs/examples/kotlin/databases/list-documents.md +++ b/docs/examples/kotlin/databases/list-documents.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Databases val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val databases = Databases(client) diff --git a/docs/examples/kotlin/databases/update-document.md b/docs/examples/kotlin/databases/update-document.md index 68cc42e..3820b89 100644 --- a/docs/examples/kotlin/databases/update-document.md +++ b/docs/examples/kotlin/databases/update-document.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Databases val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val databases = Databases(client) diff --git a/docs/examples/kotlin/functions/create-execution.md b/docs/examples/kotlin/functions/create-execution.md index b064201..77d4587 100644 --- a/docs/examples/kotlin/functions/create-execution.md +++ b/docs/examples/kotlin/functions/create-execution.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Functions val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val functions = Functions(client) diff --git a/docs/examples/kotlin/functions/get-execution.md b/docs/examples/kotlin/functions/get-execution.md index 2f9d5ef..b576686 100644 --- a/docs/examples/kotlin/functions/get-execution.md +++ b/docs/examples/kotlin/functions/get-execution.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Functions val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val functions = Functions(client) diff --git a/docs/examples/kotlin/functions/list-executions.md b/docs/examples/kotlin/functions/list-executions.md index d8a1aa1..14b613f 100644 --- a/docs/examples/kotlin/functions/list-executions.md +++ b/docs/examples/kotlin/functions/list-executions.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Functions val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val functions = Functions(client) diff --git a/docs/examples/kotlin/graphql/mutation.md b/docs/examples/kotlin/graphql/mutation.md index 7222301..dc37a3e 100644 --- a/docs/examples/kotlin/graphql/mutation.md +++ b/docs/examples/kotlin/graphql/mutation.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Graphql val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val graphql = Graphql(client) diff --git a/docs/examples/kotlin/graphql/query.md b/docs/examples/kotlin/graphql/query.md index db0f571..d821070 100644 --- a/docs/examples/kotlin/graphql/query.md +++ b/docs/examples/kotlin/graphql/query.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Graphql val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val graphql = Graphql(client) diff --git a/docs/examples/kotlin/locale/get.md b/docs/examples/kotlin/locale/get.md index da6b040..a2044c7 100644 --- a/docs/examples/kotlin/locale/get.md +++ b/docs/examples/kotlin/locale/get.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Locale val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-codes.md b/docs/examples/kotlin/locale/list-codes.md new file mode 100644 index 0000000..b4e949b --- /dev/null +++ b/docs/examples/kotlin/locale/list-codes.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Locale + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val locale = Locale(client) + +val response = locale.listCodes() diff --git a/docs/examples/kotlin/locale/list-continents.md b/docs/examples/kotlin/locale/list-continents.md index 8836a6c..610747e 100644 --- a/docs/examples/kotlin/locale/list-continents.md +++ b/docs/examples/kotlin/locale/list-continents.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Locale val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-countries-e-u.md b/docs/examples/kotlin/locale/list-countries-e-u.md index 051c191..fa5483f 100644 --- a/docs/examples/kotlin/locale/list-countries-e-u.md +++ b/docs/examples/kotlin/locale/list-countries-e-u.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Locale val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-countries-phones.md b/docs/examples/kotlin/locale/list-countries-phones.md index c6efaae..6aba463 100644 --- a/docs/examples/kotlin/locale/list-countries-phones.md +++ b/docs/examples/kotlin/locale/list-countries-phones.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Locale val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-countries.md b/docs/examples/kotlin/locale/list-countries.md index 4e2eeef..c58456b 100644 --- a/docs/examples/kotlin/locale/list-countries.md +++ b/docs/examples/kotlin/locale/list-countries.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Locale val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-currencies.md b/docs/examples/kotlin/locale/list-currencies.md index f565be6..2cf0644 100644 --- a/docs/examples/kotlin/locale/list-currencies.md +++ b/docs/examples/kotlin/locale/list-currencies.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Locale val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-languages.md b/docs/examples/kotlin/locale/list-languages.md index 284f5ba..afc00b1 100644 --- a/docs/examples/kotlin/locale/list-languages.md +++ b/docs/examples/kotlin/locale/list-languages.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Locale val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/migrations/delete-firebase-auth.md b/docs/examples/kotlin/migrations/delete-firebase-auth.md new file mode 100644 index 0000000..0aae427 --- /dev/null +++ b/docs/examples/kotlin/migrations/delete-firebase-auth.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Migrations + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val migrations = Migrations(client) + +val response = migrations.deleteFirebaseAuth() diff --git a/docs/examples/kotlin/migrations/list-firebase-projects.md b/docs/examples/kotlin/migrations/list-firebase-projects.md new file mode 100644 index 0000000..fe33e4a --- /dev/null +++ b/docs/examples/kotlin/migrations/list-firebase-projects.md @@ -0,0 +1,10 @@ +import io.appwrite.Client +import io.appwrite.services.Migrations + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val migrations = Migrations(client) + +val response = migrations.listFirebaseProjects() diff --git a/docs/examples/kotlin/storage/create-file.md b/docs/examples/kotlin/storage/create-file.md index fd52716..7bb79ac 100644 --- a/docs/examples/kotlin/storage/create-file.md +++ b/docs/examples/kotlin/storage/create-file.md @@ -3,7 +3,7 @@ import io.appwrite.models.InputFile import io.appwrite.services.Storage val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/delete-file.md b/docs/examples/kotlin/storage/delete-file.md index 945e1b9..9430d7e 100644 --- a/docs/examples/kotlin/storage/delete-file.md +++ b/docs/examples/kotlin/storage/delete-file.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Storage val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/get-file-download.md b/docs/examples/kotlin/storage/get-file-download.md index b5fde87..85bd22c 100644 --- a/docs/examples/kotlin/storage/get-file-download.md +++ b/docs/examples/kotlin/storage/get-file-download.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Storage val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/get-file-preview.md b/docs/examples/kotlin/storage/get-file-preview.md index ea7d8d4..c5bbdef 100644 --- a/docs/examples/kotlin/storage/get-file-preview.md +++ b/docs/examples/kotlin/storage/get-file-preview.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Storage val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/get-file-view.md b/docs/examples/kotlin/storage/get-file-view.md index c266fca..7e7589c 100644 --- a/docs/examples/kotlin/storage/get-file-view.md +++ b/docs/examples/kotlin/storage/get-file-view.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Storage val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/get-file.md b/docs/examples/kotlin/storage/get-file.md index 73fd9a8..8fb6e24 100644 --- a/docs/examples/kotlin/storage/get-file.md +++ b/docs/examples/kotlin/storage/get-file.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Storage val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/list-files.md b/docs/examples/kotlin/storage/list-files.md index f915e5a..191a3cc 100644 --- a/docs/examples/kotlin/storage/list-files.md +++ b/docs/examples/kotlin/storage/list-files.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Storage val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/update-file.md b/docs/examples/kotlin/storage/update-file.md index 23ce52a..005270f 100644 --- a/docs/examples/kotlin/storage/update-file.md +++ b/docs/examples/kotlin/storage/update-file.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Storage val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/teams/create-membership.md b/docs/examples/kotlin/teams/create-membership.md index 33bbe56..afc9336 100644 --- a/docs/examples/kotlin/teams/create-membership.md +++ b/docs/examples/kotlin/teams/create-membership.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/create.md b/docs/examples/kotlin/teams/create.md index 26bef65..5e70bd8 100644 --- a/docs/examples/kotlin/teams/create.md +++ b/docs/examples/kotlin/teams/create.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/delete-membership.md b/docs/examples/kotlin/teams/delete-membership.md index ac1b37a..04ef5d3 100644 --- a/docs/examples/kotlin/teams/delete-membership.md +++ b/docs/examples/kotlin/teams/delete-membership.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/delete.md b/docs/examples/kotlin/teams/delete.md index c5bcd37..7d58960 100644 --- a/docs/examples/kotlin/teams/delete.md +++ b/docs/examples/kotlin/teams/delete.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/get-membership.md b/docs/examples/kotlin/teams/get-membership.md index 1ee6ec0..653bd52 100644 --- a/docs/examples/kotlin/teams/get-membership.md +++ b/docs/examples/kotlin/teams/get-membership.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/get-prefs.md b/docs/examples/kotlin/teams/get-prefs.md index b8c2382..bfd8f75 100644 --- a/docs/examples/kotlin/teams/get-prefs.md +++ b/docs/examples/kotlin/teams/get-prefs.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/get.md b/docs/examples/kotlin/teams/get.md index 557e998..72aea07 100644 --- a/docs/examples/kotlin/teams/get.md +++ b/docs/examples/kotlin/teams/get.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/list-memberships.md b/docs/examples/kotlin/teams/list-memberships.md index d7f2920..53bd6f3 100644 --- a/docs/examples/kotlin/teams/list-memberships.md +++ b/docs/examples/kotlin/teams/list-memberships.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/list.md b/docs/examples/kotlin/teams/list.md index f056d33..57c5fe8 100644 --- a/docs/examples/kotlin/teams/list.md +++ b/docs/examples/kotlin/teams/list.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/update-membership-status.md b/docs/examples/kotlin/teams/update-membership-status.md index a36b710..33de006 100644 --- a/docs/examples/kotlin/teams/update-membership-status.md +++ b/docs/examples/kotlin/teams/update-membership-status.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/update-membership-roles.md b/docs/examples/kotlin/teams/update-membership.md similarity index 69% rename from docs/examples/kotlin/teams/update-membership-roles.md rename to docs/examples/kotlin/teams/update-membership.md index 5727e11..40005ed 100644 --- a/docs/examples/kotlin/teams/update-membership-roles.md +++ b/docs/examples/kotlin/teams/update-membership.md @@ -2,12 +2,12 @@ import io.appwrite.Client import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val teams = Teams(client) -val response = teams.updateMembershipRoles( +val response = teams.updateMembership( teamId = "[TEAM_ID]", membershipId = "[MEMBERSHIP_ID]", roles = listOf() diff --git a/docs/examples/kotlin/teams/update-name.md b/docs/examples/kotlin/teams/update-name.md index 9a2dc4a..59c6812 100644 --- a/docs/examples/kotlin/teams/update-name.md +++ b/docs/examples/kotlin/teams/update-name.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/update-prefs.md b/docs/examples/kotlin/teams/update-prefs.md index f7f8f50..6a89ac7 100644 --- a/docs/examples/kotlin/teams/update-prefs.md +++ b/docs/examples/kotlin/teams/update-prefs.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/vcs/create-repository-detection.md b/docs/examples/kotlin/vcs/create-repository-detection.md new file mode 100644 index 0000000..02dece0 --- /dev/null +++ b/docs/examples/kotlin/vcs/create-repository-detection.md @@ -0,0 +1,13 @@ +import io.appwrite.Client +import io.appwrite.services.Vcs + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val vcs = Vcs(client) + +val response = vcs.createRepositoryDetection( + installationId = "[INSTALLATION_ID]", + providerRepositoryId = "[PROVIDER_REPOSITORY_ID]", +) diff --git a/docs/examples/kotlin/vcs/create-repository.md b/docs/examples/kotlin/vcs/create-repository.md new file mode 100644 index 0000000..1c9d9f0 --- /dev/null +++ b/docs/examples/kotlin/vcs/create-repository.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.services.Vcs + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val vcs = Vcs(client) + +val response = vcs.createRepository( + installationId = "[INSTALLATION_ID]", + name = "[NAME]", + private = false +) diff --git a/docs/examples/kotlin/vcs/get-repository.md b/docs/examples/kotlin/vcs/get-repository.md new file mode 100644 index 0000000..0f2964a --- /dev/null +++ b/docs/examples/kotlin/vcs/get-repository.md @@ -0,0 +1,13 @@ +import io.appwrite.Client +import io.appwrite.services.Vcs + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val vcs = Vcs(client) + +val response = vcs.getRepository( + installationId = "[INSTALLATION_ID]", + providerRepositoryId = "[PROVIDER_REPOSITORY_ID]" +) diff --git a/docs/examples/kotlin/vcs/list-repositories.md b/docs/examples/kotlin/vcs/list-repositories.md new file mode 100644 index 0000000..471f00d --- /dev/null +++ b/docs/examples/kotlin/vcs/list-repositories.md @@ -0,0 +1,12 @@ +import io.appwrite.Client +import io.appwrite.services.Vcs + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val vcs = Vcs(client) + +val response = vcs.listRepositories( + installationId = "[INSTALLATION_ID]", +) diff --git a/docs/examples/kotlin/vcs/list-repository-branches.md b/docs/examples/kotlin/vcs/list-repository-branches.md new file mode 100644 index 0000000..dd891fe --- /dev/null +++ b/docs/examples/kotlin/vcs/list-repository-branches.md @@ -0,0 +1,13 @@ +import io.appwrite.Client +import io.appwrite.services.Vcs + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val vcs = Vcs(client) + +val response = vcs.listRepositoryBranches( + installationId = "[INSTALLATION_ID]", + providerRepositoryId = "[PROVIDER_REPOSITORY_ID]" +) diff --git a/docs/examples/kotlin/vcs/update-external-deployments.md b/docs/examples/kotlin/vcs/update-external-deployments.md new file mode 100644 index 0000000..32164cc --- /dev/null +++ b/docs/examples/kotlin/vcs/update-external-deployments.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.services.Vcs + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val vcs = Vcs(client) + +val response = vcs.updateExternalDeployments( + installationId = "[INSTALLATION_ID]", + repositoryId = "[REPOSITORY_ID]", + providerPullRequestId = "[PROVIDER_PULL_REQUEST_ID]" +) diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index fe1234d..852ef98 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -88,8 +88,8 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "2.0.0", - "x-appwrite-response-format" to "1.0.0" + "x-sdk-version" to "3.0.0", + "x-appwrite-response-format" to "1.4.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/models/Branch.kt b/library/src/main/java/io/appwrite/models/Branch.kt new file mode 100644 index 0000000..674deef --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Branch.kt @@ -0,0 +1,30 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Branch + */ +data class Branch( + /** + * Branch Name. + */ + @SerializedName("name") + val name: String, + +) { + fun toMap(): Map = mapOf( + "name" to name as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = Branch( + name = map["name"] as String, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/BranchList.kt b/library/src/main/java/io/appwrite/models/BranchList.kt new file mode 100644 index 0000000..d87248b --- /dev/null +++ b/library/src/main/java/io/appwrite/models/BranchList.kt @@ -0,0 +1,38 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Branches List + */ +data class BranchList( + /** + * Total number of branches documents that matched your query. + */ + @SerializedName("total") + val total: Long, + + /** + * List of branches. + */ + @SerializedName("branches") + val branches: List, + +) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "branches" to branches.map { it.toMap() } as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = BranchList( + total = (map["total"] as Number).toLong(), + branches = (map["branches"] as List>).map { Branch.from(map = it) }, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Detection.kt b/library/src/main/java/io/appwrite/models/Detection.kt new file mode 100644 index 0000000..3ed4631 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Detection.kt @@ -0,0 +1,30 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Detection + */ +data class Detection( + /** + * Runtime + */ + @SerializedName("runtime") + val runtime: String, + +) { + fun toMap(): Map = mapOf( + "runtime" to runtime as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = Detection( + runtime = map["runtime"] as String, + ) + } +} \ 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 a573562..8252aa1 100644 --- a/library/src/main/java/io/appwrite/models/Execution.kt +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -50,31 +50,55 @@ data class Execution( val status: String, /** - * The script status code. + * HTTP request method type. */ - @SerializedName("statusCode") - val statusCode: Long, + @SerializedName("requestMethod") + val requestMethod: String, /** - * The script response output string. Logs the last 4,000 characters of the execution response output. + * HTTP request path and query. */ - @SerializedName("response") - val response: String, + @SerializedName("requestPath") + val requestPath: 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. + * HTTP response headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. */ - @SerializedName("stdout") - val stdout: String, + @SerializedName("requestHeaders") + val requestHeaders: List, /** - * 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. + * HTTP response status code. */ - @SerializedName("stderr") - val stderr: String, + @SerializedName("responseStatusCode") + val responseStatusCode: Long, /** - * The script execution duration in seconds. + * HTTP response body. This will return empty unless execution is created as synchronous. + */ + @SerializedName("responseBody") + val responseBody: String, + + /** + * HTTP response headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. + */ + @SerializedName("responseHeaders") + val responseHeaders: List, + + /** + * Function logs. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + */ + @SerializedName("logs") + val logs: String, + + /** + * Function errors. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + */ + @SerializedName("errors") + val errors: String, + + /** + * Function execution duration in seconds. */ @SerializedName("duration") val duration: Double, @@ -88,10 +112,14 @@ data class Execution( "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, + "requestMethod" to requestMethod as Any, + "requestPath" to requestPath as Any, + "requestHeaders" to requestHeaders.map { it.toMap() } as Any, + "responseStatusCode" to responseStatusCode as Any, + "responseBody" to responseBody as Any, + "responseHeaders" to responseHeaders.map { it.toMap() } as Any, + "logs" to logs as Any, + "errors" to errors as Any, "duration" to duration as Any, ) @@ -108,10 +136,14 @@ data class Execution( functionId = map["functionId"] as String, trigger = map["trigger"] as String, status = map["status"] as String, - statusCode = (map["statusCode"] as Number).toLong(), - response = map["response"] as String, - stdout = map["stdout"] as String, - stderr = map["stderr"] as String, + requestMethod = map["requestMethod"] as String, + requestPath = map["requestPath"] as String, + requestHeaders = (map["requestHeaders"] as List>).map { Headers.from(map = it) }, + responseStatusCode = (map["responseStatusCode"] as Number).toLong(), + responseBody = map["responseBody"] as String, + responseHeaders = (map["responseHeaders"] as List>).map { Headers.from(map = it) }, + logs = map["logs"] as String, + errors = map["errors"] as String, duration = (map["duration"] as Number).toDouble(), ) } diff --git a/library/src/main/java/io/appwrite/models/FirebaseProject.kt b/library/src/main/java/io/appwrite/models/FirebaseProject.kt new file mode 100644 index 0000000..7f27597 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/FirebaseProject.kt @@ -0,0 +1,38 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * MigrationFirebaseProject + */ +data class FirebaseProject( + /** + * Project ID. + */ + @SerializedName("projectId") + val projectId: String, + + /** + * Project display name. + */ + @SerializedName("displayName") + val displayName: String, + +) { + fun toMap(): Map = mapOf( + "projectId" to projectId as Any, + "displayName" to displayName as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = FirebaseProject( + projectId = map["projectId"] as String, + displayName = map["displayName"] as String, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/FirebaseProjectList.kt b/library/src/main/java/io/appwrite/models/FirebaseProjectList.kt new file mode 100644 index 0000000..510ad8a --- /dev/null +++ b/library/src/main/java/io/appwrite/models/FirebaseProjectList.kt @@ -0,0 +1,38 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Migrations Firebase Projects List + */ +data class FirebaseProjectList( + /** + * Total number of projects documents that matched your query. + */ + @SerializedName("total") + val total: Long, + + /** + * List of projects. + */ + @SerializedName("projects") + val projects: List, + +) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "projects" to projects.map { it.toMap() } as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = FirebaseProjectList( + total = (map["total"] as Number).toLong(), + projects = (map["projects"] as List>).map { FirebaseProject.from(map = it) }, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Headers.kt b/library/src/main/java/io/appwrite/models/Headers.kt new file mode 100644 index 0000000..230d6a6 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Headers.kt @@ -0,0 +1,38 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Headers + */ +data class Headers( + /** + * Header name. + */ + @SerializedName("name") + val name: String, + + /** + * Header value. + */ + @SerializedName("value") + val value: String, + +) { + fun toMap(): Map = mapOf( + "name" to name as Any, + "value" to value as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = Headers( + name = map["name"] as String, + value = map["value"] as String, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Identity.kt b/library/src/main/java/io/appwrite/models/Identity.kt new file mode 100644 index 0000000..70ff5ea --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Identity.kt @@ -0,0 +1,102 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Identity + */ +data class Identity( + /** + * Identity ID. + */ + @SerializedName("\$id") + val id: String, + + /** + * Identity creation date in ISO 8601 format. + */ + @SerializedName("\$createdAt") + val createdAt: String, + + /** + * Identity update date in ISO 8601 format. + */ + @SerializedName("\$updatedAt") + val updatedAt: String, + + /** + * User ID. + */ + @SerializedName("userId") + val userId: String, + + /** + * Identity Provider. + */ + @SerializedName("provider") + val provider: String, + + /** + * ID of the User in the Identity Provider. + */ + @SerializedName("providerUid") + val providerUid: String, + + /** + * Email of the User in the Identity Provider. + */ + @SerializedName("providerEmail") + val providerEmail: String, + + /** + * Identity 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, + + /** + * Identity Provider Refresh Token. + */ + @SerializedName("providerRefreshToken") + val providerRefreshToken: String, + +) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "userId" to userId as Any, + "provider" to provider as Any, + "providerUid" to providerUid as Any, + "providerEmail" to providerEmail as Any, + "providerAccessToken" to providerAccessToken as Any, + "providerAccessTokenExpiry" to providerAccessTokenExpiry as Any, + "providerRefreshToken" to providerRefreshToken as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = Identity( + id = map["\$id"] as String, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, + userId = map["userId"] as String, + provider = map["provider"] as String, + providerUid = map["providerUid"] as String, + providerEmail = map["providerEmail"] as String, + providerAccessToken = map["providerAccessToken"] as String, + providerAccessTokenExpiry = map["providerAccessTokenExpiry"] as String, + providerRefreshToken = map["providerRefreshToken"] as String, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/IdentityList.kt b/library/src/main/java/io/appwrite/models/IdentityList.kt new file mode 100644 index 0000000..1cbb07d --- /dev/null +++ b/library/src/main/java/io/appwrite/models/IdentityList.kt @@ -0,0 +1,38 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Identities List + */ +data class IdentityList( + /** + * Total number of identities documents that matched your query. + */ + @SerializedName("total") + val total: Long, + + /** + * List of identities. + */ + @SerializedName("identities") + val identities: List, + +) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "identities" to identities.map { it.toMap() } as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = IdentityList( + total = (map["total"] as Number).toLong(), + identities = (map["identities"] as List>).map { Identity.from(map = it) }, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/LocaleCode.kt b/library/src/main/java/io/appwrite/models/LocaleCode.kt new file mode 100644 index 0000000..ed886b7 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/LocaleCode.kt @@ -0,0 +1,38 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * LocaleCode + */ +data class LocaleCode( + /** + * Locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) + */ + @SerializedName("code") + val code: String, + + /** + * Locale name + */ + @SerializedName("name") + val name: String, + +) { + fun toMap(): Map = mapOf( + "code" to code as Any, + "name" to name as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = LocaleCode( + code = map["code"] as String, + name = map["name"] as String, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/LocaleCodeList.kt b/library/src/main/java/io/appwrite/models/LocaleCodeList.kt new file mode 100644 index 0000000..3973a03 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/LocaleCodeList.kt @@ -0,0 +1,38 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Locale codes list + */ +data class LocaleCodeList( + /** + * Total number of localeCodes documents that matched your query. + */ + @SerializedName("total") + val total: Long, + + /** + * List of localeCodes. + */ + @SerializedName("localeCodes") + val localeCodes: List, + +) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "localeCodes" to localeCodes.map { it.toMap() } as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = LocaleCodeList( + total = (map["total"] as Number).toLong(), + localeCodes = (map["localeCodes"] as List>).map { LocaleCode.from(map = it) }, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/ProviderRepository.kt b/library/src/main/java/io/appwrite/models/ProviderRepository.kt new file mode 100644 index 0000000..bf4f7ad --- /dev/null +++ b/library/src/main/java/io/appwrite/models/ProviderRepository.kt @@ -0,0 +1,78 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * ProviderRepository + */ +data class ProviderRepository( + /** + * VCS (Version Control System) repository ID. + */ + @SerializedName("id") + val id: String, + + /** + * VCS (Version Control System) repository name. + */ + @SerializedName("name") + val name: String, + + /** + * VCS (Version Control System) organization name + */ + @SerializedName("organization") + val organization: String, + + /** + * VCS (Version Control System) provider name. + */ + @SerializedName("provider") + val provider: String, + + /** + * Is VCS (Version Control System) repository private? + */ + @SerializedName("xprivate") + val xprivate: Boolean, + + /** + * Auto-detected runtime suggestion. Empty if getting response of getRuntime(). + */ + @SerializedName("runtime") + val runtime: String, + + /** + * Last commit date in ISO 8601 format. + */ + @SerializedName("pushedAt") + val pushedAt: String, + +) { + fun toMap(): Map = mapOf( + "id" to id as Any, + "name" to name as Any, + "organization" to organization as Any, + "provider" to provider as Any, + "private" to xprivate as Any, + "runtime" to runtime as Any, + "pushedAt" to pushedAt as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = ProviderRepository( + id = map["id"] as String, + name = map["name"] as String, + organization = map["organization"] as String, + provider = map["provider"] as String, + xprivate = map["private"] as Boolean, + runtime = map["runtime"] as String, + pushedAt = map["pushedAt"] as String, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/ProviderRepositoryList.kt b/library/src/main/java/io/appwrite/models/ProviderRepositoryList.kt new file mode 100644 index 0000000..129527d --- /dev/null +++ b/library/src/main/java/io/appwrite/models/ProviderRepositoryList.kt @@ -0,0 +1,38 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Provider Repositories List + */ +data class ProviderRepositoryList( + /** + * Total number of providerRepositories documents that matched your query. + */ + @SerializedName("total") + val total: Long, + + /** + * List of providerRepositories. + */ + @SerializedName("providerRepositories") + val providerRepositories: List, + +) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "providerRepositories" to providerRepositories.map { it.toMap() } as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = ProviderRepositoryList( + total = (map["total"] as Number).toLong(), + providerRepositories = (map["providerRepositories"] as List>).map { ProviderRepository.from(map = it) }, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/User.kt b/library/src/main/java/io/appwrite/models/User.kt index 81551e6..9bf7eb4 100644 --- a/library/src/main/java/io/appwrite/models/User.kt +++ b/library/src/main/java/io/appwrite/models/User.kt @@ -61,6 +61,12 @@ data class User( @SerializedName("status") val status: Boolean, + /** + * Labels for the user. + */ + @SerializedName("labels") + val labels: List, + /** * Password update time in ISO 8601 format. */ @@ -97,6 +103,12 @@ data class User( @SerializedName("prefs") val prefs: Preferences, + /** + * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + */ + @SerializedName("accessedAt") + val accessedAt: String, + ) { fun toMap(): Map = mapOf( "\$id" to id as Any, @@ -108,12 +120,14 @@ data class User( "hashOptions" to hashOptions as Any, "registration" to registration as Any, "status" to status as Any, + "labels" to labels 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, + "accessedAt" to accessedAt as Any, ) companion object { @@ -127,12 +141,14 @@ data class User( hashOptions: Any?, registration: String, status: Boolean, + labels: List, passwordUpdate: String, email: String, phone: String, emailVerification: Boolean, phoneVerification: Boolean, prefs: Preferences>, + accessedAt: String, ) = User>( id, createdAt, @@ -143,12 +159,14 @@ data class User( hashOptions, registration, status, + labels, passwordUpdate, email, phone, emailVerification, phoneVerification, prefs, + accessedAt, ) @Suppress("UNCHECKED_CAST") @@ -165,12 +183,14 @@ data class User( hashOptions = map["hashOptions"] as? Any?, registration = map["registration"] as String, status = map["status"] as Boolean, + labels = map["labels"] as List, passwordUpdate = map["passwordUpdate"] as String, email = map["email"] as String, phone = map["phone"] as String, emailVerification = map["emailVerification"] as Boolean, phoneVerification = map["phoneVerification"] as Boolean, prefs = Preferences.from(map = map["prefs"] as Map, nestedType), + accessedAt = map["accessedAt"] as String, ) } } \ 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 2a88a5b..f64e4b0 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -22,14 +22,14 @@ class Account : Service { /** * Get Account * - * Get currently logged in user data as JSON object. + * Get the currently logged in user. * * @return [io.appwrite.models.User] */ suspend fun get( nestedType: Class, ): io.appwrite.models.User { - val path = "/account" + val apiPath = "/account" val params = mutableMapOf( ) @@ -41,7 +41,7 @@ class Account : Service { } return client.call( "GET", - path, + apiPath, headers, params, responseType = classOf(), @@ -52,7 +52,7 @@ class Account : Service { /** * Get Account * - * Get currently logged in user data as JSON object. + * Get the currently logged in user. * * @return [io.appwrite.models.User] */ @@ -81,7 +81,7 @@ class Account : Service { name: String? = null, nestedType: Class, ): io.appwrite.models.User { - val path = "/account" + val apiPath = "/account" val params = mutableMapOf( "userId" to userId, @@ -97,7 +97,7 @@ class Account : Service { } return client.call( "POST", - path, + apiPath, headers, params, responseType = classOf(), @@ -145,7 +145,7 @@ class Account : Service { password: String, nestedType: Class, ): io.appwrite.models.User { - val path = "/account/email" + val apiPath = "/account/email" val params = mutableMapOf( "email" to email, @@ -159,7 +159,7 @@ class Account : Service { } return client.call( "PATCH", - path, + apiPath, headers, params, responseType = classOf(), @@ -186,6 +186,69 @@ class Account : Service { nestedType = classOf(), ) + /** + * List Identities + * + * Get the list of identities for the currently logged in user. + * + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry + * @return [io.appwrite.models.IdentityList] + */ + @JvmOverloads + suspend fun listIdentities( + queries: String? = null, + ): io.appwrite.models.IdentityList { + val apiPath = "/account/identities" + + val params = mutableMapOf( + "queries" to queries, + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.IdentityList = { + io.appwrite.models.IdentityList.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + headers, + params, + responseType = io.appwrite.models.IdentityList::class.java, + converter, + ) + } + + + /** + * Delete Identity + * + * Delete an identity by its unique ID. + * + * @param identityId Identity ID. + * @return [Any] + */ + suspend fun deleteIdentity( + identityId: String, + ): Any { + val apiPath = "/account/identities/{identityId}" + .replace("{identityId}", identityId) + + val params = mutableMapOf( + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + return client.call( + "DELETE", + apiPath, + headers, + params, + responseType = Any::class.java, + ) + } + + /** * Create JWT * @@ -195,7 +258,7 @@ class Account : Service { */ suspend fun createJWT( ): io.appwrite.models.Jwt { - val path = "/account/jwt" + val apiPath = "/account/jwt" val params = mutableMapOf( ) @@ -207,7 +270,7 @@ class Account : Service { } return client.call( "POST", - path, + apiPath, headers, params, responseType = io.appwrite.models.Jwt::class.java, @@ -219,7 +282,7 @@ class Account : Service { /** * 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 the list of latest security activity logs for the currently logged in user. 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/queries). Only supported methods are limit and offset * @return [io.appwrite.models.LogList] @@ -228,7 +291,7 @@ class Account : Service { suspend fun listLogs( queries: List? = null, ): io.appwrite.models.LogList { - val path = "/account/logs" + val apiPath = "/account/logs" val params = mutableMapOf( "queries" to queries, @@ -241,7 +304,7 @@ class Account : Service { } return client.call( "GET", - path, + apiPath, headers, params, responseType = io.appwrite.models.LogList::class.java, @@ -262,7 +325,7 @@ class Account : Service { name: String, nestedType: Class, ): io.appwrite.models.User { - val path = "/account/name" + val apiPath = "/account/name" val params = mutableMapOf( "name" to name, @@ -275,7 +338,7 @@ class Account : Service { } return client.call( "PATCH", - path, + apiPath, headers, params, responseType = classOf(), @@ -314,7 +377,7 @@ class Account : Service { oldPassword: String? = null, nestedType: Class, ): io.appwrite.models.User { - val path = "/account/password" + val apiPath = "/account/password" val params = mutableMapOf( "password" to password, @@ -328,7 +391,7 @@ class Account : Service { } return client.call( "PATCH", - path, + apiPath, headers, params, responseType = classOf(), @@ -370,7 +433,7 @@ class Account : Service { password: String, nestedType: Class, ): io.appwrite.models.User { - val path = "/account/phone" + val apiPath = "/account/phone" val params = mutableMapOf( "phone" to phone, @@ -384,7 +447,7 @@ class Account : Service { } return client.call( "PATCH", - path, + apiPath, headers, params, responseType = classOf(), @@ -414,14 +477,14 @@ class Account : Service { /** * Get Account Preferences * - * Get currently logged in user preferences as a key-value object. + * Get the preferences as a key-value object for the currently logged in user. * * @return [io.appwrite.models.Preferences] */ suspend fun getPrefs( nestedType: Class, ): io.appwrite.models.Preferences { - val path = "/account/prefs" + val apiPath = "/account/prefs" val params = mutableMapOf( ) @@ -433,7 +496,7 @@ class Account : Service { } return client.call( "GET", - path, + apiPath, headers, params, responseType = classOf(), @@ -444,7 +507,7 @@ class Account : Service { /** * Get Account Preferences * - * Get currently logged in user preferences as a key-value object. + * Get the preferences as a key-value object for the currently logged in user. * * @return [io.appwrite.models.Preferences] */ @@ -466,7 +529,7 @@ class Account : Service { prefs: Any, nestedType: Class, ): io.appwrite.models.User { - val path = "/account/prefs" + val apiPath = "/account/prefs" val params = mutableMapOf( "prefs" to prefs, @@ -479,7 +542,7 @@ class Account : Service { } return client.call( "PATCH", - path, + apiPath, headers, params, responseType = classOf(), @@ -516,7 +579,7 @@ class Account : Service { email: String, url: String, ): io.appwrite.models.Token { - val path = "/account/recovery" + val apiPath = "/account/recovery" val params = mutableMapOf( "email" to email, @@ -530,7 +593,7 @@ class Account : Service { } return client.call( "POST", - path, + apiPath, headers, params, responseType = io.appwrite.models.Token::class.java, @@ -556,7 +619,7 @@ class Account : Service { password: String, passwordAgain: String, ): io.appwrite.models.Token { - val path = "/account/recovery" + val apiPath = "/account/recovery" val params = mutableMapOf( "userId" to userId, @@ -572,7 +635,7 @@ class Account : Service { } return client.call( "PUT", - path, + apiPath, headers, params, responseType = io.appwrite.models.Token::class.java, @@ -584,13 +647,13 @@ class Account : Service { /** * List Sessions * - * Get currently logged in user list of active sessions across different devices. + * Get the list of active sessions across different devices for the currently logged in user. * * @return [io.appwrite.models.SessionList] */ suspend fun listSessions( ): io.appwrite.models.SessionList { - val path = "/account/sessions" + val apiPath = "/account/sessions" val params = mutableMapOf( ) @@ -602,7 +665,7 @@ class Account : Service { } return client.call( "GET", - path, + apiPath, headers, params, responseType = io.appwrite.models.SessionList::class.java, @@ -620,7 +683,7 @@ class Account : Service { */ suspend fun deleteSessions( ): Any { - val path = "/account/sessions" + val apiPath = "/account/sessions" val params = mutableMapOf( ) @@ -629,7 +692,7 @@ class Account : Service { ) return client.call( "DELETE", - path, + apiPath, headers, params, responseType = Any::class.java, @@ -646,7 +709,7 @@ class Account : Service { */ suspend fun createAnonymousSession( ): io.appwrite.models.Session { - val path = "/account/sessions/anonymous" + val apiPath = "/account/sessions/anonymous" val params = mutableMapOf( ) @@ -658,7 +721,7 @@ class Account : Service { } return client.call( "POST", - path, + apiPath, headers, params, responseType = io.appwrite.models.Session::class.java, @@ -680,7 +743,7 @@ class Account : Service { email: String, password: String, ): io.appwrite.models.Session { - val path = "/account/sessions/email" + val apiPath = "/account/sessions/email" val params = mutableMapOf( "email" to email, @@ -694,7 +757,7 @@ class Account : Service { } return client.call( "POST", - path, + apiPath, headers, params, responseType = io.appwrite.models.Session::class.java, @@ -706,7 +769,7 @@ class Account : Service { /** * 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.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](/docs/authentication-security#limits). + * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [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-security#limits). * * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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. @@ -719,7 +782,7 @@ class Account : Service { email: String, url: String? = null, ): io.appwrite.models.Token { - val path = "/account/sessions/magic-url" + val apiPath = "/account/sessions/magic-url" val params = mutableMapOf( "userId" to userId, @@ -734,7 +797,7 @@ class Account : Service { } return client.call( "POST", - path, + apiPath, headers, params, responseType = io.appwrite.models.Token::class.java, @@ -756,7 +819,7 @@ class Account : Service { userId: String, secret: String, ): io.appwrite.models.Session { - val path = "/account/sessions/magic-url" + val apiPath = "/account/sessions/magic-url" val params = mutableMapOf( "userId" to userId, @@ -770,7 +833,7 @@ class Account : Service { } return client.call( "PUT", - path, + apiPath, headers, params, responseType = io.appwrite.models.Session::class.java, @@ -784,9 +847,9 @@ class Account : Service { * * 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-security#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 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, oidc, 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's 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's 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 @@ -797,7 +860,7 @@ class Account : Service { failure: String? = null, scopes: List? = null, ) { - val path = "/account/sessions/oauth2/{provider}" + val apiPath = "/account/sessions/oauth2/{provider}" .replace("{provider}", provider) val params = mutableMapOf( @@ -821,7 +884,7 @@ class Account : Service { } } - val url = Uri.parse("${client.endPoint}${path}?${query.joinToString("&")}") + val url = Uri.parse("${client.endPoint}${apiPath}?${query.joinToString("&")}") val callbackUrlScheme = "appwrite-callback-${client.config["project"]}" WebAuthComponent.authenticate(activity, url, callbackUrlScheme) { @@ -864,7 +927,7 @@ class Account : Service { userId: String, phone: String, ): io.appwrite.models.Token { - val path = "/account/sessions/phone" + val apiPath = "/account/sessions/phone" val params = mutableMapOf( "userId" to userId, @@ -878,7 +941,7 @@ class Account : Service { } return client.call( "POST", - path, + apiPath, headers, params, responseType = io.appwrite.models.Token::class.java, @@ -900,7 +963,7 @@ class Account : Service { userId: String, secret: String, ): io.appwrite.models.Session { - val path = "/account/sessions/phone" + val apiPath = "/account/sessions/phone" val params = mutableMapOf( "userId" to userId, @@ -914,7 +977,7 @@ class Account : Service { } return client.call( "PUT", - path, + apiPath, headers, params, responseType = io.appwrite.models.Session::class.java, @@ -934,7 +997,7 @@ class Account : Service { suspend fun getSession( sessionId: String, ): io.appwrite.models.Session { - val path = "/account/sessions/{sessionId}" + val apiPath = "/account/sessions/{sessionId}" .replace("{sessionId}", sessionId) val params = mutableMapOf( @@ -947,7 +1010,7 @@ class Account : Service { } return client.call( "GET", - path, + apiPath, headers, params, responseType = io.appwrite.models.Session::class.java, @@ -967,7 +1030,7 @@ class Account : Service { suspend fun updateSession( sessionId: String, ): io.appwrite.models.Session { - val path = "/account/sessions/{sessionId}" + val apiPath = "/account/sessions/{sessionId}" .replace("{sessionId}", sessionId) val params = mutableMapOf( @@ -980,7 +1043,7 @@ class Account : Service { } return client.call( "PATCH", - path, + apiPath, headers, params, responseType = io.appwrite.models.Session::class.java, @@ -992,7 +1055,7 @@ class Account : Service { /** * 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. + * Logout the user. Use 'current' as the session ID to logout on this device, use a session ID to logout on another device. If you're looking to logout the user on all devices, use [Delete Sessions](/docs/client/account#accountDeleteSessions) instead. * * @param sessionId Session ID. Use the string 'current' to delete the current device session. * @return [Any] @@ -1000,7 +1063,7 @@ class Account : Service { suspend fun deleteSession( sessionId: String, ): Any { - val path = "/account/sessions/{sessionId}" + val apiPath = "/account/sessions/{sessionId}" .replace("{sessionId}", sessionId) val params = mutableMapOf( @@ -1010,7 +1073,7 @@ class Account : Service { ) return client.call( "DELETE", - path, + apiPath, headers, params, responseType = Any::class.java, @@ -1028,7 +1091,7 @@ class Account : Service { suspend fun updateStatus( nestedType: Class, ): io.appwrite.models.User { - val path = "/account/status" + val apiPath = "/account/status" val params = mutableMapOf( ) @@ -1040,7 +1103,7 @@ class Account : Service { } return client.call( "PATCH", - path, + apiPath, headers, params, responseType = classOf(), @@ -1072,7 +1135,7 @@ class Account : Service { suspend fun createVerification( url: String, ): io.appwrite.models.Token { - val path = "/account/verification" + val apiPath = "/account/verification" val params = mutableMapOf( "url" to url, @@ -1085,7 +1148,7 @@ class Account : Service { } return client.call( "POST", - path, + apiPath, headers, params, responseType = io.appwrite.models.Token::class.java, @@ -1107,7 +1170,7 @@ class Account : Service { userId: String, secret: String, ): io.appwrite.models.Token { - val path = "/account/verification" + val apiPath = "/account/verification" val params = mutableMapOf( "userId" to userId, @@ -1121,7 +1184,7 @@ class Account : Service { } return client.call( "PUT", - path, + apiPath, headers, params, responseType = io.appwrite.models.Token::class.java, @@ -1139,7 +1202,7 @@ class Account : Service { */ suspend fun createPhoneVerification( ): io.appwrite.models.Token { - val path = "/account/verification/phone" + val apiPath = "/account/verification/phone" val params = mutableMapOf( ) @@ -1151,7 +1214,7 @@ class Account : Service { } return client.call( "POST", - path, + apiPath, headers, params, responseType = io.appwrite.models.Token::class.java, @@ -1173,7 +1236,7 @@ class Account : Service { userId: String, secret: String, ): io.appwrite.models.Token { - val path = "/account/verification/phone" + val apiPath = "/account/verification/phone" val params = mutableMapOf( "userId" to userId, @@ -1187,7 +1250,7 @@ class Account : Service { } return client.call( "PUT", - path, + apiPath, headers, params, responseType = io.appwrite.models.Token::class.java, diff --git a/library/src/main/java/io/appwrite/services/Assistant.kt b/library/src/main/java/io/appwrite/services/Assistant.kt new file mode 100644 index 0000000..c38a2eb --- /dev/null +++ b/library/src/main/java/io/appwrite/services/Assistant.kt @@ -0,0 +1,47 @@ +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 + +/** + * +**/ +class Assistant : Service { + + public constructor (client: Client) : super(client) { } + + /** + * Ask Query + * + * + * + * @param prompt Prompt. A string containing questions asked to the AI assistant. + * @return [Any] + */ + suspend fun chat( + prompt: String, + ): Any { + val apiPath = "/console/assistant" + + val params = mutableMapOf( + "prompt" to prompt, + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + return client.call( + "POST", + apiPath, + headers, + params, + responseType = Any::class.java, + ) + } + + +} \ 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 69f158b..53277d8 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -35,7 +35,7 @@ class Avatars : Service { height: Long? = null, quality: Long? = null, ): ByteArray { - val path = "/avatars/browsers/{code}" + val apiPath = "/avatars/browsers/{code}" .replace("{code}", code) val params = mutableMapOf( @@ -46,7 +46,7 @@ class Avatars : Service { ) return client.call( "GET", - path, + apiPath, params = params, responseType = ByteArray::class.java ) @@ -71,7 +71,7 @@ class Avatars : Service { height: Long? = null, quality: Long? = null, ): ByteArray { - val path = "/avatars/credit-cards/{code}" + val apiPath = "/avatars/credit-cards/{code}" .replace("{code}", code) val params = mutableMapOf( @@ -82,7 +82,7 @@ class Avatars : Service { ) return client.call( "GET", - path, + apiPath, params = params, responseType = ByteArray::class.java ) @@ -100,7 +100,7 @@ class Avatars : Service { suspend fun getFavicon( url: String, ): ByteArray { - val path = "/avatars/favicon" + val apiPath = "/avatars/favicon" val params = mutableMapOf( "url" to url, @@ -108,7 +108,7 @@ class Avatars : Service { ) return client.call( "GET", - path, + apiPath, params = params, responseType = ByteArray::class.java ) @@ -133,7 +133,7 @@ class Avatars : Service { height: Long? = null, quality: Long? = null, ): ByteArray { - val path = "/avatars/flags/{code}" + val apiPath = "/avatars/flags/{code}" .replace("{code}", code) val params = mutableMapOf( @@ -144,7 +144,7 @@ class Avatars : Service { ) return client.call( "GET", - path, + apiPath, params = params, responseType = ByteArray::class.java ) @@ -167,7 +167,7 @@ class Avatars : Service { width: Long? = null, height: Long? = null, ): ByteArray { - val path = "/avatars/image" + val apiPath = "/avatars/image" val params = mutableMapOf( "url" to url, @@ -177,7 +177,7 @@ class Avatars : Service { ) return client.call( "GET", - path, + apiPath, params = params, responseType = ByteArray::class.java ) @@ -202,7 +202,7 @@ class Avatars : Service { height: Long? = null, background: String? = null, ): ByteArray { - val path = "/avatars/initials" + val apiPath = "/avatars/initials" val params = mutableMapOf( "name" to name, @@ -213,7 +213,7 @@ class Avatars : Service { ) return client.call( "GET", - path, + apiPath, params = params, responseType = ByteArray::class.java ) @@ -238,7 +238,7 @@ class Avatars : Service { margin: Long? = null, download: Boolean? = null, ): ByteArray { - val path = "/avatars/qr" + val apiPath = "/avatars/qr" val params = mutableMapOf( "text" to text, @@ -249,7 +249,7 @@ class Avatars : Service { ) return client.call( "GET", - path, + apiPath, params = params, responseType = ByteArray::class.java ) diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index 0744693..9822e1c 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -32,7 +32,7 @@ class Databases : Service { queries: List? = null, nestedType: Class, ): io.appwrite.models.DocumentList { - val path = "/databases/{databaseId}/collections/{collectionId}/documents" + val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) @@ -47,7 +47,7 @@ class Databases : Service { } return client.call( "GET", - path, + apiPath, headers, params, responseType = classOf(), @@ -99,7 +99,7 @@ class Databases : Service { permissions: List? = null, nestedType: Class, ): io.appwrite.models.Document { - val path = "/databases/{databaseId}/collections/{collectionId}/documents" + val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) @@ -116,7 +116,7 @@ class Databases : Service { } return client.call( "POST", - path, + apiPath, headers, params, responseType = classOf(), @@ -172,7 +172,7 @@ class Databases : Service { queries: List? = null, nestedType: Class, ): io.appwrite.models.Document { - val path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" + val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) .replace("{documentId}", documentId) @@ -188,7 +188,7 @@ class Databases : Service { } return client.call( "GET", - path, + apiPath, headers, params, responseType = classOf(), @@ -243,7 +243,7 @@ class Databases : Service { permissions: List? = null, nestedType: Class, ): io.appwrite.models.Document { - val path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" + val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) .replace("{documentId}", documentId) @@ -260,7 +260,7 @@ class Databases : Service { } return client.call( "PATCH", - path, + apiPath, headers, params, responseType = classOf(), @@ -312,7 +312,7 @@ class Databases : Service { collectionId: String, documentId: String, ): Any { - val path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" + val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) .replace("{documentId}", documentId) @@ -324,7 +324,7 @@ class Databases : Service { ) return client.call( "DELETE", - path, + apiPath, headers, params, responseType = Any::class.java, diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index ffa350a..eadcf0d 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -21,7 +21,7 @@ class Functions : Service { * 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/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, statusCode, duration + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, responseStatusCode, duration * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.ExecutionList] */ @@ -31,7 +31,7 @@ class Functions : Service { queries: List? = null, search: String? = null, ): io.appwrite.models.ExecutionList { - val path = "/functions/{functionId}/executions" + val apiPath = "/functions/{functionId}/executions" .replace("{functionId}", functionId) val params = mutableMapOf( @@ -46,7 +46,7 @@ class Functions : Service { } return client.call( "GET", - path, + apiPath, headers, params, responseType = io.appwrite.models.ExecutionList::class.java, @@ -61,22 +61,31 @@ class Functions : Service { * 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 body HTTP body of execution. Default value is empty string. * @param async Execute code in the background. Default value is false. + * @param path HTTP path of execution. Path can include query params. Default value is / + * @param method HTTP method of execution. Default value is GET. + * @param headers HTTP headers of execution. Defaults to empty. * @return [io.appwrite.models.Execution] */ @JvmOverloads suspend fun createExecution( functionId: String, - data: String? = null, + body: String? = null, async: Boolean? = null, + path: String? = null, + method: String? = null, + headers: Any? = null, ): io.appwrite.models.Execution { - val path = "/functions/{functionId}/executions" + val apiPath = "/functions/{functionId}/executions" .replace("{functionId}", functionId) val params = mutableMapOf( - "data" to data, + "body" to body, "async" to async, + "path" to path, + "method" to method, + "headers" to headers, ) val headers = mutableMapOf( "content-type" to "application/json", @@ -86,7 +95,7 @@ class Functions : Service { } return client.call( "POST", - path, + apiPath, headers, params, responseType = io.appwrite.models.Execution::class.java, @@ -108,7 +117,7 @@ class Functions : Service { functionId: String, executionId: String, ): io.appwrite.models.Execution { - val path = "/functions/{functionId}/executions/{executionId}" + val apiPath = "/functions/{functionId}/executions/{executionId}" .replace("{functionId}", functionId) .replace("{executionId}", executionId) @@ -122,7 +131,7 @@ class Functions : Service { } return client.call( "GET", - path, + apiPath, headers, params, responseType = io.appwrite.models.Execution::class.java, diff --git a/library/src/main/java/io/appwrite/services/Graphql.kt b/library/src/main/java/io/appwrite/services/Graphql.kt index d661ccf..2d9bbbd 100644 --- a/library/src/main/java/io/appwrite/services/Graphql.kt +++ b/library/src/main/java/io/appwrite/services/Graphql.kt @@ -26,7 +26,7 @@ class Graphql : Service { suspend fun query( query: Any, ): Any { - val path = "/graphql" + val apiPath = "/graphql" val params = mutableMapOf( "query" to query, @@ -40,7 +40,7 @@ class Graphql : Service { } return client.call( "POST", - path, + apiPath, headers, params, responseType = Any::class.java, @@ -60,7 +60,7 @@ class Graphql : Service { suspend fun mutation( query: Any, ): Any { - val path = "/graphql/mutation" + val apiPath = "/graphql/mutation" val params = mutableMapOf( "query" to query, @@ -74,7 +74,7 @@ class Graphql : Service { } return client.call( "POST", - path, + apiPath, headers, params, responseType = Any::class.java, diff --git a/library/src/main/java/io/appwrite/services/Locale.kt b/library/src/main/java/io/appwrite/services/Locale.kt index 5c9cc95..b0e93a6 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -24,7 +24,7 @@ class Locale : Service { */ suspend fun get( ): io.appwrite.models.Locale { - val path = "/locale" + val apiPath = "/locale" val params = mutableMapOf( ) @@ -36,7 +36,7 @@ class Locale : Service { } return client.call( "GET", - path, + apiPath, headers, params, responseType = io.appwrite.models.Locale::class.java, @@ -45,6 +45,36 @@ class Locale : Service { } + /** + * List Locale Codes + * + * List of all locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). + * + * @return [io.appwrite.models.LocaleCodeList] + */ + suspend fun listCodes( + ): io.appwrite.models.LocaleCodeList { + val apiPath = "/locale/codes" + + val params = mutableMapOf( + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.LocaleCodeList = { + io.appwrite.models.LocaleCodeList.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + headers, + params, + responseType = io.appwrite.models.LocaleCodeList::class.java, + converter, + ) + } + + /** * List Continents * @@ -54,7 +84,7 @@ class Locale : Service { */ suspend fun listContinents( ): io.appwrite.models.ContinentList { - val path = "/locale/continents" + val apiPath = "/locale/continents" val params = mutableMapOf( ) @@ -66,7 +96,7 @@ class Locale : Service { } return client.call( "GET", - path, + apiPath, headers, params, responseType = io.appwrite.models.ContinentList::class.java, @@ -84,7 +114,7 @@ class Locale : Service { */ suspend fun listCountries( ): io.appwrite.models.CountryList { - val path = "/locale/countries" + val apiPath = "/locale/countries" val params = mutableMapOf( ) @@ -96,7 +126,7 @@ class Locale : Service { } return client.call( "GET", - path, + apiPath, headers, params, responseType = io.appwrite.models.CountryList::class.java, @@ -114,7 +144,7 @@ class Locale : Service { */ suspend fun listCountriesEU( ): io.appwrite.models.CountryList { - val path = "/locale/countries/eu" + val apiPath = "/locale/countries/eu" val params = mutableMapOf( ) @@ -126,7 +156,7 @@ class Locale : Service { } return client.call( "GET", - path, + apiPath, headers, params, responseType = io.appwrite.models.CountryList::class.java, @@ -144,7 +174,7 @@ class Locale : Service { */ suspend fun listCountriesPhones( ): io.appwrite.models.PhoneList { - val path = "/locale/countries/phones" + val apiPath = "/locale/countries/phones" val params = mutableMapOf( ) @@ -156,7 +186,7 @@ class Locale : Service { } return client.call( "GET", - path, + apiPath, headers, params, responseType = io.appwrite.models.PhoneList::class.java, @@ -174,7 +204,7 @@ class Locale : Service { */ suspend fun listCurrencies( ): io.appwrite.models.CurrencyList { - val path = "/locale/currencies" + val apiPath = "/locale/currencies" val params = mutableMapOf( ) @@ -186,7 +216,7 @@ class Locale : Service { } return client.call( "GET", - path, + apiPath, headers, params, responseType = io.appwrite.models.CurrencyList::class.java, @@ -204,7 +234,7 @@ class Locale : Service { */ suspend fun listLanguages( ): io.appwrite.models.LanguageList { - val path = "/locale/languages" + val apiPath = "/locale/languages" val params = mutableMapOf( ) @@ -216,7 +246,7 @@ class Locale : Service { } return client.call( "GET", - path, + apiPath, headers, params, responseType = io.appwrite.models.LanguageList::class.java, diff --git a/library/src/main/java/io/appwrite/services/Migrations.kt b/library/src/main/java/io/appwrite/services/Migrations.kt new file mode 100644 index 0000000..4fd3163 --- /dev/null +++ b/library/src/main/java/io/appwrite/services/Migrations.kt @@ -0,0 +1,74 @@ +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 Migrations service allows you to migrate third-party data to your Appwrite project. +**/ +class Migrations : Service { + + public constructor (client: Client) : super(client) { } + + /** + * Revoke Appwrite's authorization to access Firebase Projects + * + * + * + * @return [Any] + */ + suspend fun deleteFirebaseAuth( + ): Any { + val apiPath = "/migrations/firebase/deauthorize" + + val params = mutableMapOf( + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + return client.call( + "GET", + apiPath, + headers, + params, + responseType = Any::class.java, + ) + } + + + /** + * List Firebase Projects + * + * + * + * @return [io.appwrite.models.FirebaseProjectList] + */ + suspend fun listFirebaseProjects( + ): io.appwrite.models.FirebaseProjectList { + val apiPath = "/migrations/firebase/projects" + + val params = mutableMapOf( + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.FirebaseProjectList = { + io.appwrite.models.FirebaseProjectList.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + headers, + params, + responseType = io.appwrite.models.FirebaseProjectList::class.java, + 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 1dc5617..bb5a59e 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -33,7 +33,7 @@ class Storage : Service { queries: List? = null, search: String? = null, ): io.appwrite.models.FileList { - val path = "/storage/buckets/{bucketId}/files" + val apiPath = "/storage/buckets/{bucketId}/files" .replace("{bucketId}", bucketId) val params = mutableMapOf( @@ -48,7 +48,7 @@ class Storage : Service { } return client.call( "GET", - path, + apiPath, headers, params, responseType = io.appwrite.models.FileList::class.java, @@ -76,7 +76,7 @@ class Storage : Service { permissions: List? = null, onProgress: ((UploadProgress) -> Unit)? = null ): io.appwrite.models.File { - val path = "/storage/buckets/{bucketId}/files" + val apiPath = "/storage/buckets/{bucketId}/files" .replace("{bucketId}", bucketId) val params = mutableMapOf( @@ -93,7 +93,7 @@ class Storage : Service { val idParamName: String? = "fileId" val paramName = "file" return client.chunkedUpload( - path, + apiPath, headers, params, responseType = io.appwrite.models.File::class.java, @@ -118,7 +118,7 @@ class Storage : Service { bucketId: String, fileId: String, ): io.appwrite.models.File { - val path = "/storage/buckets/{bucketId}/files/{fileId}" + val apiPath = "/storage/buckets/{bucketId}/files/{fileId}" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) @@ -132,7 +132,7 @@ class Storage : Service { } return client.call( "GET", - path, + apiPath, headers, params, responseType = io.appwrite.models.File::class.java, @@ -148,6 +148,7 @@ class Storage : Service { * * @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 name Name of the file * @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] */ @@ -155,13 +156,15 @@ class Storage : Service { suspend fun updateFile( bucketId: String, fileId: String, + name: String? = null, permissions: List? = null, ): io.appwrite.models.File { - val path = "/storage/buckets/{bucketId}/files/{fileId}" + val apiPath = "/storage/buckets/{bucketId}/files/{fileId}" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) val params = mutableMapOf( + "name" to name, "permissions" to permissions, ) val headers = mutableMapOf( @@ -172,7 +175,7 @@ class Storage : Service { } return client.call( "PUT", - path, + apiPath, headers, params, responseType = io.appwrite.models.File::class.java, @@ -194,7 +197,7 @@ class Storage : Service { bucketId: String, fileId: String, ): Any { - val path = "/storage/buckets/{bucketId}/files/{fileId}" + val apiPath = "/storage/buckets/{bucketId}/files/{fileId}" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) @@ -205,7 +208,7 @@ class Storage : Service { ) return client.call( "DELETE", - path, + apiPath, headers, params, responseType = Any::class.java, @@ -226,7 +229,7 @@ class Storage : Service { bucketId: String, fileId: String, ): ByteArray { - val path = "/storage/buckets/{bucketId}/files/{fileId}/download" + val apiPath = "/storage/buckets/{bucketId}/files/{fileId}/download" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) @@ -235,7 +238,7 @@ class Storage : Service { ) return client.call( "GET", - path, + apiPath, params = params, responseType = ByteArray::class.java ) @@ -278,7 +281,7 @@ class Storage : Service { background: String? = null, output: String? = null, ): ByteArray { - val path = "/storage/buckets/{bucketId}/files/{fileId}/preview" + val apiPath = "/storage/buckets/{bucketId}/files/{fileId}/preview" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) @@ -298,7 +301,7 @@ class Storage : Service { ) return client.call( "GET", - path, + apiPath, params = params, responseType = ByteArray::class.java ) @@ -318,7 +321,7 @@ class Storage : Service { bucketId: String, fileId: String, ): ByteArray { - val path = "/storage/buckets/{bucketId}/files/{fileId}/view" + val apiPath = "/storage/buckets/{bucketId}/files/{fileId}/view" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) @@ -327,7 +330,7 @@ class Storage : Service { ) return client.call( "GET", - path, + apiPath, params = params, responseType = ByteArray::class.java ) diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 333f438..a64a152 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -30,7 +30,7 @@ class Teams : Service { search: String? = null, nestedType: Class, ): io.appwrite.models.TeamList { - val path = "/teams" + val apiPath = "/teams" val params = mutableMapOf( "queries" to queries, @@ -44,7 +44,7 @@ class Teams : Service { } return client.call( "GET", - path, + apiPath, headers, params, responseType = classOf(), @@ -89,7 +89,7 @@ class Teams : Service { roles: List? = null, nestedType: Class, ): io.appwrite.models.Team { - val path = "/teams" + val apiPath = "/teams" val params = mutableMapOf( "teamId" to teamId, @@ -104,7 +104,7 @@ class Teams : Service { } return client.call( "POST", - path, + apiPath, headers, params, responseType = classOf(), @@ -147,7 +147,7 @@ class Teams : Service { teamId: String, nestedType: Class, ): io.appwrite.models.Team { - val path = "/teams/{teamId}" + val apiPath = "/teams/{teamId}" .replace("{teamId}", teamId) val params = mutableMapOf( @@ -160,7 +160,7 @@ class Teams : Service { } return client.call( "GET", - path, + apiPath, headers, params, responseType = classOf(), @@ -198,7 +198,7 @@ class Teams : Service { name: String, nestedType: Class, ): io.appwrite.models.Team { - val path = "/teams/{teamId}" + val apiPath = "/teams/{teamId}" .replace("{teamId}", teamId) val params = mutableMapOf( @@ -212,7 +212,7 @@ class Teams : Service { } return client.call( "PUT", - path, + apiPath, headers, params, responseType = classOf(), @@ -250,7 +250,7 @@ class Teams : Service { suspend fun delete( teamId: String, ): Any { - val path = "/teams/{teamId}" + val apiPath = "/teams/{teamId}" .replace("{teamId}", teamId) val params = mutableMapOf( @@ -260,7 +260,7 @@ class Teams : Service { ) return client.call( "DELETE", - path, + apiPath, headers, params, responseType = Any::class.java, @@ -284,7 +284,7 @@ class Teams : Service { queries: List? = null, search: String? = null, ): io.appwrite.models.MembershipList { - val path = "/teams/{teamId}/memberships" + val apiPath = "/teams/{teamId}/memberships" .replace("{teamId}", teamId) val params = mutableMapOf( @@ -299,7 +299,7 @@ class Teams : Service { } return client.call( "GET", - path, + apiPath, headers, params, responseType = io.appwrite.models.MembershipList::class.java, @@ -332,7 +332,7 @@ class Teams : Service { phone: String? = null, name: String? = null, ): io.appwrite.models.Membership { - val path = "/teams/{teamId}/memberships" + val apiPath = "/teams/{teamId}/memberships" .replace("{teamId}", teamId) val params = mutableMapOf( @@ -351,7 +351,7 @@ class Teams : Service { } return client.call( "POST", - path, + apiPath, headers, params, responseType = io.appwrite.models.Membership::class.java, @@ -373,7 +373,7 @@ class Teams : Service { teamId: String, membershipId: String, ): io.appwrite.models.Membership { - val path = "/teams/{teamId}/memberships/{membershipId}" + val apiPath = "/teams/{teamId}/memberships/{membershipId}" .replace("{teamId}", teamId) .replace("{membershipId}", membershipId) @@ -387,7 +387,7 @@ class Teams : Service { } return client.call( "GET", - path, + apiPath, headers, params, responseType = io.appwrite.models.Membership::class.java, @@ -397,7 +397,7 @@ class Teams : Service { /** - * Update Membership Roles + * Update Membership * * 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). * @@ -406,12 +406,12 @@ class Teams : Service { * @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] */ - suspend fun updateMembershipRoles( + suspend fun updateMembership( teamId: String, membershipId: String, roles: List, ): io.appwrite.models.Membership { - val path = "/teams/{teamId}/memberships/{membershipId}" + val apiPath = "/teams/{teamId}/memberships/{membershipId}" .replace("{teamId}", teamId) .replace("{membershipId}", membershipId) @@ -426,7 +426,7 @@ class Teams : Service { } return client.call( "PATCH", - path, + apiPath, headers, params, responseType = io.appwrite.models.Membership::class.java, @@ -448,7 +448,7 @@ class Teams : Service { teamId: String, membershipId: String, ): Any { - val path = "/teams/{teamId}/memberships/{membershipId}" + val apiPath = "/teams/{teamId}/memberships/{membershipId}" .replace("{teamId}", teamId) .replace("{membershipId}", membershipId) @@ -459,7 +459,7 @@ class Teams : Service { ) return client.call( "DELETE", - path, + apiPath, headers, params, responseType = Any::class.java, @@ -484,7 +484,7 @@ class Teams : Service { userId: String, secret: String, ): io.appwrite.models.Membership { - val path = "/teams/{teamId}/memberships/{membershipId}/status" + val apiPath = "/teams/{teamId}/memberships/{membershipId}/status" .replace("{teamId}", teamId) .replace("{membershipId}", membershipId) @@ -500,7 +500,7 @@ class Teams : Service { } return client.call( "PATCH", - path, + apiPath, headers, params, responseType = io.appwrite.models.Membership::class.java, @@ -521,7 +521,7 @@ class Teams : Service { teamId: String, nestedType: Class, ): io.appwrite.models.Preferences { - val path = "/teams/{teamId}/prefs" + val apiPath = "/teams/{teamId}/prefs" .replace("{teamId}", teamId) val params = mutableMapOf( @@ -534,7 +534,7 @@ class Teams : Service { } return client.call( "GET", - path, + apiPath, headers, params, responseType = classOf(), @@ -572,7 +572,7 @@ class Teams : Service { prefs: Any, nestedType: Class, ): io.appwrite.models.Preferences { - val path = "/teams/{teamId}/prefs" + val apiPath = "/teams/{teamId}/prefs" .replace("{teamId}", teamId) val params = mutableMapOf( @@ -586,7 +586,7 @@ class Teams : Service { } return client.call( "PUT", - path, + apiPath, headers, params, responseType = classOf(), diff --git a/library/src/main/java/io/appwrite/services/Vcs.kt b/library/src/main/java/io/appwrite/services/Vcs.kt new file mode 100644 index 0000000..21c2b02 --- /dev/null +++ b/library/src/main/java/io/appwrite/services/Vcs.kt @@ -0,0 +1,241 @@ +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 + +/** + * +**/ +class Vcs : Service { + + public constructor (client: Client) : super(client) { } + + /** + * List Repositories + * + * + * + * @param installationId Installation Id + * @param search Search term to filter your list results. Max length: 256 chars. + * @return [io.appwrite.models.ProviderRepositoryList] + */ + @JvmOverloads + suspend fun listRepositories( + installationId: String, + search: String? = null, + ): io.appwrite.models.ProviderRepositoryList { + val apiPath = "/vcs/github/installations/{installationId}/providerRepositories" + .replace("{installationId}", installationId) + + val params = mutableMapOf( + "search" to search, + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.ProviderRepositoryList = { + io.appwrite.models.ProviderRepositoryList.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + headers, + params, + responseType = io.appwrite.models.ProviderRepositoryList::class.java, + converter, + ) + } + + + /** + * Create repository + * + * + * + * @param installationId Installation Id + * @param name Repository name (slug) + * @param private Mark repository public or private + * @return [io.appwrite.models.ProviderRepository] + */ + suspend fun createRepository( + installationId: String, + name: String, + private: Boolean, + ): io.appwrite.models.ProviderRepository { + val apiPath = "/vcs/github/installations/{installationId}/providerRepositories" + .replace("{installationId}", installationId) + + val params = mutableMapOf( + "name" to name, + "private" to private, + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.ProviderRepository = { + io.appwrite.models.ProviderRepository.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + headers, + params, + responseType = io.appwrite.models.ProviderRepository::class.java, + converter, + ) + } + + + /** + * Get repository + * + * + * + * @param installationId Installation Id + * @param providerRepositoryId Repository Id + * @return [io.appwrite.models.ProviderRepository] + */ + suspend fun getRepository( + installationId: String, + providerRepositoryId: String, + ): io.appwrite.models.ProviderRepository { + val apiPath = "/vcs/github/installations/{installationId}/providerRepositories/{providerRepositoryId}" + .replace("{installationId}", installationId) + .replace("{providerRepositoryId}", providerRepositoryId) + + val params = mutableMapOf( + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.ProviderRepository = { + io.appwrite.models.ProviderRepository.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + headers, + params, + responseType = io.appwrite.models.ProviderRepository::class.java, + converter, + ) + } + + + /** + * List Repository Branches + * + * + * + * @param installationId Installation Id + * @param providerRepositoryId Repository Id + * @return [io.appwrite.models.BranchList] + */ + suspend fun listRepositoryBranches( + installationId: String, + providerRepositoryId: String, + ): io.appwrite.models.BranchList { + val apiPath = "/vcs/github/installations/{installationId}/providerRepositories/{providerRepositoryId}/branches" + .replace("{installationId}", installationId) + .replace("{providerRepositoryId}", providerRepositoryId) + + val params = mutableMapOf( + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.BranchList = { + io.appwrite.models.BranchList.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + headers, + params, + responseType = io.appwrite.models.BranchList::class.java, + converter, + ) + } + + + /** + * Detect runtime settings from source code + * + * + * + * @param installationId Installation Id + * @param providerRepositoryId Repository Id + * @param providerRootDirectory Path to Root Directory + * @return [io.appwrite.models.Detection] + */ + @JvmOverloads + suspend fun createRepositoryDetection( + installationId: String, + providerRepositoryId: String, + providerRootDirectory: String? = null, + ): io.appwrite.models.Detection { + val apiPath = "/vcs/github/installations/{installationId}/providerRepositories/{providerRepositoryId}/detection" + .replace("{installationId}", installationId) + .replace("{providerRepositoryId}", providerRepositoryId) + + val params = mutableMapOf( + "providerRootDirectory" to providerRootDirectory, + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Detection = { + io.appwrite.models.Detection.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + headers, + params, + responseType = io.appwrite.models.Detection::class.java, + converter, + ) + } + + + /** + * Authorize external deployment + * + * + * + * @param installationId Installation Id + * @param repositoryId VCS Repository Id + * @param providerPullRequestId GitHub Pull Request Id + * @return [Any] + */ + suspend fun updateExternalDeployments( + installationId: String, + repositoryId: String, + providerPullRequestId: String, + ): Any { + val apiPath = "/vcs/github/installations/{installationId}/repositories/{repositoryId}" + .replace("{installationId}", installationId) + .replace("{repositoryId}", repositoryId) + + val params = mutableMapOf( + "providerPullRequestId" to providerPullRequestId, + ) + val headers = mutableMapOf( + "content-type" to "application/json", + ) + return client.call( + "PATCH", + apiPath, + headers, + params, + responseType = Any::class.java, + ) + } + + +} \ No newline at end of file From 7ca2e77e825a881d1209e4ac716972af358085d7 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 30 Aug 2023 10:46:41 +0200 Subject: [PATCH 050/118] feat: release 1.4.x --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 76ed518..a7340a8 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![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 latest. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).** +**This SDK is compatible with Appwrite server version 1.4.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) From c5751212312efbfd3fcc7cf32f0f80221e937071 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 30 Aug 2023 11:13:04 +0200 Subject: [PATCH 051/118] feat: release 1.4.x --- docs/examples/java/assistant/chat.md | 21 -- .../java/migrations/delete-firebase-auth.md | 18 -- .../java/migrations/list-firebase-projects.md | 18 -- .../java/vcs/create-repository-detection.md | 22 -- docs/examples/java/vcs/create-repository.md | 23 -- docs/examples/java/vcs/get-repository.md | 22 -- docs/examples/java/vcs/list-repositories.md | 21 -- .../java/vcs/list-repository-branches.md | 22 -- .../java/vcs/update-external-deployments.md | 23 -- docs/examples/kotlin/assistant/chat.md | 12 - .../kotlin/migrations/delete-firebase-auth.md | 10 - .../migrations/list-firebase-projects.md | 10 - .../kotlin/vcs/create-repository-detection.md | 13 - docs/examples/kotlin/vcs/create-repository.md | 14 - docs/examples/kotlin/vcs/get-repository.md | 13 - docs/examples/kotlin/vcs/list-repositories.md | 12 - .../kotlin/vcs/list-repository-branches.md | 13 - .../kotlin/vcs/update-external-deployments.md | 14 - .../main/java/io/appwrite/models/Branch.kt | 30 --- .../java/io/appwrite/models/BranchList.kt | 38 --- .../main/java/io/appwrite/models/Detection.kt | 30 --- .../io/appwrite/models/FirebaseProject.kt | 38 --- .../io/appwrite/models/FirebaseProjectList.kt | 38 --- .../io/appwrite/models/ProviderRepository.kt | 78 ------ .../appwrite/models/ProviderRepositoryList.kt | 38 --- .../java/io/appwrite/services/Assistant.kt | 47 ---- .../java/io/appwrite/services/Migrations.kt | 74 ------ .../src/main/java/io/appwrite/services/Vcs.kt | 241 ------------------ 28 files changed, 953 deletions(-) delete mode 100644 docs/examples/java/assistant/chat.md delete mode 100644 docs/examples/java/migrations/delete-firebase-auth.md delete mode 100644 docs/examples/java/migrations/list-firebase-projects.md delete mode 100644 docs/examples/java/vcs/create-repository-detection.md delete mode 100644 docs/examples/java/vcs/create-repository.md delete mode 100644 docs/examples/java/vcs/get-repository.md delete mode 100644 docs/examples/java/vcs/list-repositories.md delete mode 100644 docs/examples/java/vcs/list-repository-branches.md delete mode 100644 docs/examples/java/vcs/update-external-deployments.md delete mode 100644 docs/examples/kotlin/assistant/chat.md delete mode 100644 docs/examples/kotlin/migrations/delete-firebase-auth.md delete mode 100644 docs/examples/kotlin/migrations/list-firebase-projects.md delete mode 100644 docs/examples/kotlin/vcs/create-repository-detection.md delete mode 100644 docs/examples/kotlin/vcs/create-repository.md delete mode 100644 docs/examples/kotlin/vcs/get-repository.md delete mode 100644 docs/examples/kotlin/vcs/list-repositories.md delete mode 100644 docs/examples/kotlin/vcs/list-repository-branches.md delete mode 100644 docs/examples/kotlin/vcs/update-external-deployments.md delete mode 100644 library/src/main/java/io/appwrite/models/Branch.kt delete mode 100644 library/src/main/java/io/appwrite/models/BranchList.kt delete mode 100644 library/src/main/java/io/appwrite/models/Detection.kt delete mode 100644 library/src/main/java/io/appwrite/models/FirebaseProject.kt delete mode 100644 library/src/main/java/io/appwrite/models/FirebaseProjectList.kt delete mode 100644 library/src/main/java/io/appwrite/models/ProviderRepository.kt delete mode 100644 library/src/main/java/io/appwrite/models/ProviderRepositoryList.kt delete mode 100644 library/src/main/java/io/appwrite/services/Assistant.kt delete mode 100644 library/src/main/java/io/appwrite/services/Migrations.kt delete mode 100644 library/src/main/java/io/appwrite/services/Vcs.kt diff --git a/docs/examples/java/assistant/chat.md b/docs/examples/java/assistant/chat.md deleted file mode 100644 index 62cf301..0000000 --- a/docs/examples/java/assistant/chat.md +++ /dev/null @@ -1,21 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Assistant; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - -Assistant assistant = new Assistant(client); - -assistant.chat( - "[PROMPT]" - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); diff --git a/docs/examples/java/migrations/delete-firebase-auth.md b/docs/examples/java/migrations/delete-firebase-auth.md deleted file mode 100644 index ab56fe9..0000000 --- a/docs/examples/java/migrations/delete-firebase-auth.md +++ /dev/null @@ -1,18 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Migrations; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - -Migrations migrations = new Migrations(client); - -migrations.deleteFirebaseAuth(new CoroutineCallback<>((result, error) -> { - if (error != null) - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); -})); diff --git a/docs/examples/java/migrations/list-firebase-projects.md b/docs/examples/java/migrations/list-firebase-projects.md deleted file mode 100644 index 7dba57e..0000000 --- a/docs/examples/java/migrations/list-firebase-projects.md +++ /dev/null @@ -1,18 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Migrations; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - -Migrations migrations = new Migrations(client); - -migrations.listFirebaseProjects(new CoroutineCallback<>((result, error) -> { - if (error != null) - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); -})); diff --git a/docs/examples/java/vcs/create-repository-detection.md b/docs/examples/java/vcs/create-repository-detection.md deleted file mode 100644 index 640414c..0000000 --- a/docs/examples/java/vcs/create-repository-detection.md +++ /dev/null @@ -1,22 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Vcs; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - -Vcs vcs = new Vcs(client); - -vcs.createRepositoryDetection( - "[INSTALLATION_ID]", - "[PROVIDER_REPOSITORY_ID]", - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); diff --git a/docs/examples/java/vcs/create-repository.md b/docs/examples/java/vcs/create-repository.md deleted file mode 100644 index ebc22b3..0000000 --- a/docs/examples/java/vcs/create-repository.md +++ /dev/null @@ -1,23 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Vcs; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - -Vcs vcs = new Vcs(client); - -vcs.createRepository( - "[INSTALLATION_ID]", - "[NAME]", - false - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); diff --git a/docs/examples/java/vcs/get-repository.md b/docs/examples/java/vcs/get-repository.md deleted file mode 100644 index 2e03db2..0000000 --- a/docs/examples/java/vcs/get-repository.md +++ /dev/null @@ -1,22 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Vcs; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - -Vcs vcs = new Vcs(client); - -vcs.getRepository( - "[INSTALLATION_ID]", - "[PROVIDER_REPOSITORY_ID]" - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); diff --git a/docs/examples/java/vcs/list-repositories.md b/docs/examples/java/vcs/list-repositories.md deleted file mode 100644 index 3ebd41d..0000000 --- a/docs/examples/java/vcs/list-repositories.md +++ /dev/null @@ -1,21 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Vcs; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - -Vcs vcs = new Vcs(client); - -vcs.listRepositories( - "[INSTALLATION_ID]", - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); diff --git a/docs/examples/java/vcs/list-repository-branches.md b/docs/examples/java/vcs/list-repository-branches.md deleted file mode 100644 index 3cb3663..0000000 --- a/docs/examples/java/vcs/list-repository-branches.md +++ /dev/null @@ -1,22 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Vcs; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - -Vcs vcs = new Vcs(client); - -vcs.listRepositoryBranches( - "[INSTALLATION_ID]", - "[PROVIDER_REPOSITORY_ID]" - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); diff --git a/docs/examples/java/vcs/update-external-deployments.md b/docs/examples/java/vcs/update-external-deployments.md deleted file mode 100644 index 0f27f4a..0000000 --- a/docs/examples/java/vcs/update-external-deployments.md +++ /dev/null @@ -1,23 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Vcs; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - -Vcs vcs = new Vcs(client); - -vcs.updateExternalDeployments( - "[INSTALLATION_ID]", - "[REPOSITORY_ID]", - "[PROVIDER_PULL_REQUEST_ID]" - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); diff --git a/docs/examples/kotlin/assistant/chat.md b/docs/examples/kotlin/assistant/chat.md deleted file mode 100644 index ef4381b..0000000 --- a/docs/examples/kotlin/assistant/chat.md +++ /dev/null @@ -1,12 +0,0 @@ -import io.appwrite.Client -import io.appwrite.services.Assistant - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - -val assistant = Assistant(client) - -val response = assistant.chat( - prompt = "[PROMPT]" -) diff --git a/docs/examples/kotlin/migrations/delete-firebase-auth.md b/docs/examples/kotlin/migrations/delete-firebase-auth.md deleted file mode 100644 index 0aae427..0000000 --- a/docs/examples/kotlin/migrations/delete-firebase-auth.md +++ /dev/null @@ -1,10 +0,0 @@ -import io.appwrite.Client -import io.appwrite.services.Migrations - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - -val migrations = Migrations(client) - -val response = migrations.deleteFirebaseAuth() diff --git a/docs/examples/kotlin/migrations/list-firebase-projects.md b/docs/examples/kotlin/migrations/list-firebase-projects.md deleted file mode 100644 index fe33e4a..0000000 --- a/docs/examples/kotlin/migrations/list-firebase-projects.md +++ /dev/null @@ -1,10 +0,0 @@ -import io.appwrite.Client -import io.appwrite.services.Migrations - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - -val migrations = Migrations(client) - -val response = migrations.listFirebaseProjects() diff --git a/docs/examples/kotlin/vcs/create-repository-detection.md b/docs/examples/kotlin/vcs/create-repository-detection.md deleted file mode 100644 index 02dece0..0000000 --- a/docs/examples/kotlin/vcs/create-repository-detection.md +++ /dev/null @@ -1,13 +0,0 @@ -import io.appwrite.Client -import io.appwrite.services.Vcs - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - -val vcs = Vcs(client) - -val response = vcs.createRepositoryDetection( - installationId = "[INSTALLATION_ID]", - providerRepositoryId = "[PROVIDER_REPOSITORY_ID]", -) diff --git a/docs/examples/kotlin/vcs/create-repository.md b/docs/examples/kotlin/vcs/create-repository.md deleted file mode 100644 index 1c9d9f0..0000000 --- a/docs/examples/kotlin/vcs/create-repository.md +++ /dev/null @@ -1,14 +0,0 @@ -import io.appwrite.Client -import io.appwrite.services.Vcs - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - -val vcs = Vcs(client) - -val response = vcs.createRepository( - installationId = "[INSTALLATION_ID]", - name = "[NAME]", - private = false -) diff --git a/docs/examples/kotlin/vcs/get-repository.md b/docs/examples/kotlin/vcs/get-repository.md deleted file mode 100644 index 0f2964a..0000000 --- a/docs/examples/kotlin/vcs/get-repository.md +++ /dev/null @@ -1,13 +0,0 @@ -import io.appwrite.Client -import io.appwrite.services.Vcs - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - -val vcs = Vcs(client) - -val response = vcs.getRepository( - installationId = "[INSTALLATION_ID]", - providerRepositoryId = "[PROVIDER_REPOSITORY_ID]" -) diff --git a/docs/examples/kotlin/vcs/list-repositories.md b/docs/examples/kotlin/vcs/list-repositories.md deleted file mode 100644 index 471f00d..0000000 --- a/docs/examples/kotlin/vcs/list-repositories.md +++ /dev/null @@ -1,12 +0,0 @@ -import io.appwrite.Client -import io.appwrite.services.Vcs - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - -val vcs = Vcs(client) - -val response = vcs.listRepositories( - installationId = "[INSTALLATION_ID]", -) diff --git a/docs/examples/kotlin/vcs/list-repository-branches.md b/docs/examples/kotlin/vcs/list-repository-branches.md deleted file mode 100644 index dd891fe..0000000 --- a/docs/examples/kotlin/vcs/list-repository-branches.md +++ /dev/null @@ -1,13 +0,0 @@ -import io.appwrite.Client -import io.appwrite.services.Vcs - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - -val vcs = Vcs(client) - -val response = vcs.listRepositoryBranches( - installationId = "[INSTALLATION_ID]", - providerRepositoryId = "[PROVIDER_REPOSITORY_ID]" -) diff --git a/docs/examples/kotlin/vcs/update-external-deployments.md b/docs/examples/kotlin/vcs/update-external-deployments.md deleted file mode 100644 index 32164cc..0000000 --- a/docs/examples/kotlin/vcs/update-external-deployments.md +++ /dev/null @@ -1,14 +0,0 @@ -import io.appwrite.Client -import io.appwrite.services.Vcs - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - -val vcs = Vcs(client) - -val response = vcs.updateExternalDeployments( - installationId = "[INSTALLATION_ID]", - repositoryId = "[REPOSITORY_ID]", - providerPullRequestId = "[PROVIDER_PULL_REQUEST_ID]" -) diff --git a/library/src/main/java/io/appwrite/models/Branch.kt b/library/src/main/java/io/appwrite/models/Branch.kt deleted file mode 100644 index 674deef..0000000 --- a/library/src/main/java/io/appwrite/models/Branch.kt +++ /dev/null @@ -1,30 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * Branch - */ -data class Branch( - /** - * Branch Name. - */ - @SerializedName("name") - val name: String, - -) { - fun toMap(): Map = mapOf( - "name" to name as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = Branch( - name = map["name"] as String, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/BranchList.kt b/library/src/main/java/io/appwrite/models/BranchList.kt deleted file mode 100644 index d87248b..0000000 --- a/library/src/main/java/io/appwrite/models/BranchList.kt +++ /dev/null @@ -1,38 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * Branches List - */ -data class BranchList( - /** - * Total number of branches documents that matched your query. - */ - @SerializedName("total") - val total: Long, - - /** - * List of branches. - */ - @SerializedName("branches") - val branches: List, - -) { - fun toMap(): Map = mapOf( - "total" to total as Any, - "branches" to branches.map { it.toMap() } as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = BranchList( - total = (map["total"] as Number).toLong(), - branches = (map["branches"] as List>).map { Branch.from(map = it) }, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Detection.kt b/library/src/main/java/io/appwrite/models/Detection.kt deleted file mode 100644 index 3ed4631..0000000 --- a/library/src/main/java/io/appwrite/models/Detection.kt +++ /dev/null @@ -1,30 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * Detection - */ -data class Detection( - /** - * Runtime - */ - @SerializedName("runtime") - val runtime: String, - -) { - fun toMap(): Map = mapOf( - "runtime" to runtime as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = Detection( - runtime = map["runtime"] as String, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/FirebaseProject.kt b/library/src/main/java/io/appwrite/models/FirebaseProject.kt deleted file mode 100644 index 7f27597..0000000 --- a/library/src/main/java/io/appwrite/models/FirebaseProject.kt +++ /dev/null @@ -1,38 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * MigrationFirebaseProject - */ -data class FirebaseProject( - /** - * Project ID. - */ - @SerializedName("projectId") - val projectId: String, - - /** - * Project display name. - */ - @SerializedName("displayName") - val displayName: String, - -) { - fun toMap(): Map = mapOf( - "projectId" to projectId as Any, - "displayName" to displayName as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = FirebaseProject( - projectId = map["projectId"] as String, - displayName = map["displayName"] as String, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/FirebaseProjectList.kt b/library/src/main/java/io/appwrite/models/FirebaseProjectList.kt deleted file mode 100644 index 510ad8a..0000000 --- a/library/src/main/java/io/appwrite/models/FirebaseProjectList.kt +++ /dev/null @@ -1,38 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * Migrations Firebase Projects List - */ -data class FirebaseProjectList( - /** - * Total number of projects documents that matched your query. - */ - @SerializedName("total") - val total: Long, - - /** - * List of projects. - */ - @SerializedName("projects") - val projects: List, - -) { - fun toMap(): Map = mapOf( - "total" to total as Any, - "projects" to projects.map { it.toMap() } as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = FirebaseProjectList( - total = (map["total"] as Number).toLong(), - projects = (map["projects"] as List>).map { FirebaseProject.from(map = it) }, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/ProviderRepository.kt b/library/src/main/java/io/appwrite/models/ProviderRepository.kt deleted file mode 100644 index bf4f7ad..0000000 --- a/library/src/main/java/io/appwrite/models/ProviderRepository.kt +++ /dev/null @@ -1,78 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * ProviderRepository - */ -data class ProviderRepository( - /** - * VCS (Version Control System) repository ID. - */ - @SerializedName("id") - val id: String, - - /** - * VCS (Version Control System) repository name. - */ - @SerializedName("name") - val name: String, - - /** - * VCS (Version Control System) organization name - */ - @SerializedName("organization") - val organization: String, - - /** - * VCS (Version Control System) provider name. - */ - @SerializedName("provider") - val provider: String, - - /** - * Is VCS (Version Control System) repository private? - */ - @SerializedName("xprivate") - val xprivate: Boolean, - - /** - * Auto-detected runtime suggestion. Empty if getting response of getRuntime(). - */ - @SerializedName("runtime") - val runtime: String, - - /** - * Last commit date in ISO 8601 format. - */ - @SerializedName("pushedAt") - val pushedAt: String, - -) { - fun toMap(): Map = mapOf( - "id" to id as Any, - "name" to name as Any, - "organization" to organization as Any, - "provider" to provider as Any, - "private" to xprivate as Any, - "runtime" to runtime as Any, - "pushedAt" to pushedAt as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = ProviderRepository( - id = map["id"] as String, - name = map["name"] as String, - organization = map["organization"] as String, - provider = map["provider"] as String, - xprivate = map["private"] as Boolean, - runtime = map["runtime"] as String, - pushedAt = map["pushedAt"] as String, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/ProviderRepositoryList.kt b/library/src/main/java/io/appwrite/models/ProviderRepositoryList.kt deleted file mode 100644 index 129527d..0000000 --- a/library/src/main/java/io/appwrite/models/ProviderRepositoryList.kt +++ /dev/null @@ -1,38 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * Provider Repositories List - */ -data class ProviderRepositoryList( - /** - * Total number of providerRepositories documents that matched your query. - */ - @SerializedName("total") - val total: Long, - - /** - * List of providerRepositories. - */ - @SerializedName("providerRepositories") - val providerRepositories: List, - -) { - fun toMap(): Map = mapOf( - "total" to total as Any, - "providerRepositories" to providerRepositories.map { it.toMap() } as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = ProviderRepositoryList( - total = (map["total"] as Number).toLong(), - providerRepositories = (map["providerRepositories"] as List>).map { ProviderRepository.from(map = it) }, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Assistant.kt b/library/src/main/java/io/appwrite/services/Assistant.kt deleted file mode 100644 index c38a2eb..0000000 --- a/library/src/main/java/io/appwrite/services/Assistant.kt +++ /dev/null @@ -1,47 +0,0 @@ -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 - -/** - * -**/ -class Assistant : Service { - - public constructor (client: Client) : super(client) { } - - /** - * Ask Query - * - * - * - * @param prompt Prompt. A string containing questions asked to the AI assistant. - * @return [Any] - */ - suspend fun chat( - prompt: String, - ): Any { - val apiPath = "/console/assistant" - - val params = mutableMapOf( - "prompt" to prompt, - ) - val headers = mutableMapOf( - "content-type" to "application/json", - ) - return client.call( - "POST", - apiPath, - headers, - params, - responseType = Any::class.java, - ) - } - - -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Migrations.kt b/library/src/main/java/io/appwrite/services/Migrations.kt deleted file mode 100644 index 4fd3163..0000000 --- a/library/src/main/java/io/appwrite/services/Migrations.kt +++ /dev/null @@ -1,74 +0,0 @@ -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 Migrations service allows you to migrate third-party data to your Appwrite project. -**/ -class Migrations : Service { - - public constructor (client: Client) : super(client) { } - - /** - * Revoke Appwrite's authorization to access Firebase Projects - * - * - * - * @return [Any] - */ - suspend fun deleteFirebaseAuth( - ): Any { - val apiPath = "/migrations/firebase/deauthorize" - - val params = mutableMapOf( - ) - val headers = mutableMapOf( - "content-type" to "application/json", - ) - return client.call( - "GET", - apiPath, - headers, - params, - responseType = Any::class.java, - ) - } - - - /** - * List Firebase Projects - * - * - * - * @return [io.appwrite.models.FirebaseProjectList] - */ - suspend fun listFirebaseProjects( - ): io.appwrite.models.FirebaseProjectList { - val apiPath = "/migrations/firebase/projects" - - val params = mutableMapOf( - ) - val headers = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.FirebaseProjectList = { - io.appwrite.models.FirebaseProjectList.from(map = it as Map) - } - return client.call( - "GET", - apiPath, - headers, - params, - responseType = io.appwrite.models.FirebaseProjectList::class.java, - converter, - ) - } - - -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Vcs.kt b/library/src/main/java/io/appwrite/services/Vcs.kt deleted file mode 100644 index 21c2b02..0000000 --- a/library/src/main/java/io/appwrite/services/Vcs.kt +++ /dev/null @@ -1,241 +0,0 @@ -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 - -/** - * -**/ -class Vcs : Service { - - public constructor (client: Client) : super(client) { } - - /** - * List Repositories - * - * - * - * @param installationId Installation Id - * @param search Search term to filter your list results. Max length: 256 chars. - * @return [io.appwrite.models.ProviderRepositoryList] - */ - @JvmOverloads - suspend fun listRepositories( - installationId: String, - search: String? = null, - ): io.appwrite.models.ProviderRepositoryList { - val apiPath = "/vcs/github/installations/{installationId}/providerRepositories" - .replace("{installationId}", installationId) - - val params = mutableMapOf( - "search" to search, - ) - val headers = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.ProviderRepositoryList = { - io.appwrite.models.ProviderRepositoryList.from(map = it as Map) - } - return client.call( - "GET", - apiPath, - headers, - params, - responseType = io.appwrite.models.ProviderRepositoryList::class.java, - converter, - ) - } - - - /** - * Create repository - * - * - * - * @param installationId Installation Id - * @param name Repository name (slug) - * @param private Mark repository public or private - * @return [io.appwrite.models.ProviderRepository] - */ - suspend fun createRepository( - installationId: String, - name: String, - private: Boolean, - ): io.appwrite.models.ProviderRepository { - val apiPath = "/vcs/github/installations/{installationId}/providerRepositories" - .replace("{installationId}", installationId) - - val params = mutableMapOf( - "name" to name, - "private" to private, - ) - val headers = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.ProviderRepository = { - io.appwrite.models.ProviderRepository.from(map = it as Map) - } - return client.call( - "POST", - apiPath, - headers, - params, - responseType = io.appwrite.models.ProviderRepository::class.java, - converter, - ) - } - - - /** - * Get repository - * - * - * - * @param installationId Installation Id - * @param providerRepositoryId Repository Id - * @return [io.appwrite.models.ProviderRepository] - */ - suspend fun getRepository( - installationId: String, - providerRepositoryId: String, - ): io.appwrite.models.ProviderRepository { - val apiPath = "/vcs/github/installations/{installationId}/providerRepositories/{providerRepositoryId}" - .replace("{installationId}", installationId) - .replace("{providerRepositoryId}", providerRepositoryId) - - val params = mutableMapOf( - ) - val headers = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.ProviderRepository = { - io.appwrite.models.ProviderRepository.from(map = it as Map) - } - return client.call( - "GET", - apiPath, - headers, - params, - responseType = io.appwrite.models.ProviderRepository::class.java, - converter, - ) - } - - - /** - * List Repository Branches - * - * - * - * @param installationId Installation Id - * @param providerRepositoryId Repository Id - * @return [io.appwrite.models.BranchList] - */ - suspend fun listRepositoryBranches( - installationId: String, - providerRepositoryId: String, - ): io.appwrite.models.BranchList { - val apiPath = "/vcs/github/installations/{installationId}/providerRepositories/{providerRepositoryId}/branches" - .replace("{installationId}", installationId) - .replace("{providerRepositoryId}", providerRepositoryId) - - val params = mutableMapOf( - ) - val headers = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.BranchList = { - io.appwrite.models.BranchList.from(map = it as Map) - } - return client.call( - "GET", - apiPath, - headers, - params, - responseType = io.appwrite.models.BranchList::class.java, - converter, - ) - } - - - /** - * Detect runtime settings from source code - * - * - * - * @param installationId Installation Id - * @param providerRepositoryId Repository Id - * @param providerRootDirectory Path to Root Directory - * @return [io.appwrite.models.Detection] - */ - @JvmOverloads - suspend fun createRepositoryDetection( - installationId: String, - providerRepositoryId: String, - providerRootDirectory: String? = null, - ): io.appwrite.models.Detection { - val apiPath = "/vcs/github/installations/{installationId}/providerRepositories/{providerRepositoryId}/detection" - .replace("{installationId}", installationId) - .replace("{providerRepositoryId}", providerRepositoryId) - - val params = mutableMapOf( - "providerRootDirectory" to providerRootDirectory, - ) - val headers = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Detection = { - io.appwrite.models.Detection.from(map = it as Map) - } - return client.call( - "POST", - apiPath, - headers, - params, - responseType = io.appwrite.models.Detection::class.java, - converter, - ) - } - - - /** - * Authorize external deployment - * - * - * - * @param installationId Installation Id - * @param repositoryId VCS Repository Id - * @param providerPullRequestId GitHub Pull Request Id - * @return [Any] - */ - suspend fun updateExternalDeployments( - installationId: String, - repositoryId: String, - providerPullRequestId: String, - ): Any { - val apiPath = "/vcs/github/installations/{installationId}/repositories/{repositoryId}" - .replace("{installationId}", installationId) - .replace("{repositoryId}", repositoryId) - - val params = mutableMapOf( - "providerPullRequestId" to providerPullRequestId, - ) - val headers = mutableMapOf( - "content-type" to "application/json", - ) - return client.call( - "PATCH", - apiPath, - headers, - params, - responseType = Any::class.java, - ) - } - - -} \ No newline at end of file From a0ded72aa754905c3bc50b6955c8a59de15cb6e8 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 31 Aug 2023 22:01:52 +0000 Subject: [PATCH 052/118] fix: for appwrite 1.4.x --- README.md | 4 +- library/src/main/java/io/appwrite/Client.kt | 8 +- library/src/main/java/io/appwrite/Role.kt | 43 +++ .../main/java/io/appwrite/services/Account.kt | 254 +++++++++--------- .../main/java/io/appwrite/services/Avatars.kt | 28 +- .../java/io/appwrite/services/Databases.kt | 40 +-- .../java/io/appwrite/services/Functions.kt | 24 +- .../main/java/io/appwrite/services/Graphql.kt | 16 +- .../main/java/io/appwrite/services/Locale.kt | 64 ++--- .../main/java/io/appwrite/services/Storage.kt | 52 ++-- .../main/java/io/appwrite/services/Teams.kt | 104 +++---- 11 files changed, 340 insertions(+), 297 deletions(-) diff --git a/README.md b/README.md index a7340a8..31b2006 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:3.0.0") +implementation("io.appwrite:sdk-for-android:3.0.1") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 3.0.0 + 3.0.1 ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 852ef98..d0e546a 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 "3.0.0", + "x-sdk-version" to "3.0.1", "x-appwrite-response-format" to "1.4.0" ) config = mutableMapOf() @@ -394,7 +394,7 @@ class Client @JvmOverloads constructor( responseType = Map::class.java, ) val chunksUploaded = current["chunksUploaded"] as Long - offset = (chunksUploaded * CHUNK_SIZE).coerceAtMost(size) + offset = chunksUploaded * CHUNK_SIZE } while (offset < size) { @@ -405,7 +405,7 @@ class Client @JvmOverloads constructor( } "bytes" -> { val end = if (offset + CHUNK_SIZE < size) { - offset + CHUNK_SIZE + offset + CHUNK_SIZE - 1 } else { size - 1 } @@ -425,7 +425,7 @@ class Client @JvmOverloads constructor( ) headers["Content-Range"] = - "bytes $offset-${((offset + CHUNK_SIZE) - 1).coerceAtMost(size)}/$size" + "bytes $offset-${((offset + CHUNK_SIZE) - 1).coerceAtMost(size - 1)}/$size" result = call( method = "POST", diff --git a/library/src/main/java/io/appwrite/Role.kt b/library/src/main/java/io/appwrite/Role.kt index d9ccbd2..da9ccb1 100644 --- a/library/src/main/java/io/appwrite/Role.kt +++ b/library/src/main/java/io/appwrite/Role.kt @@ -1,29 +1,72 @@ package io.appwrite +/** + * Helper class to generate role strings for [Permission]. + */ class Role { companion object { + + /** + * Grants access to anyone. + * + * This includes authenticated and unauthenticated users. + */ fun any(): String = "any" + /** + * Grants access to a specific user by user ID. + * + * You can optionally pass verified or unverified for + * [status] to target specific types of users. + */ fun user(id: String, status: String = ""): String = if(status.isEmpty()) { "user:$id" } else { "user:$id/$status" } + /** + * Grants access to any authenticated or anonymous user. + * + * You can optionally pass verified or unverified for + * [status] to target specific types of users. + */ fun users(status: String = ""): String = if(status.isEmpty()) { "users" } else { "users/$status" } + /** + * Grants access to any guest user without a session. + * + * Authenticated users don't have access to this role. + */ fun guests(): String = "guests" + /** + * Grants access to a team by team ID. + * + * You can optionally pass a role for [role] to target + * team members with the specified role. + */ fun team(id: String, role: String = ""): String = if(role.isEmpty()) { "team:$id" } else { "team:$id/$role" } + /** + * Grants access to a specific member of a team. + * + * When the member is removed from the team, they will + * no longer have access. + */ fun member(id: String): String = "member:$id" + + /** + * Grants access to a user with the specified label. + */ + fun label(name: String): String = "label:$name" } } \ 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 f64e4b0..863ad27 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -31,9 +31,9 @@ class Account : Service { ): io.appwrite.models.User { val apiPath = "/account" - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @@ -42,8 +42,8 @@ class Account : Service { return client.call( "GET", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = classOf(), converter, ) @@ -83,13 +83,13 @@ class Account : Service { ): io.appwrite.models.User { val apiPath = "/account" - val params = mutableMapOf( + val apiParams = mutableMapOf( "userId" to userId, "email" to email, "password" to password, "name" to name, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @@ -98,8 +98,8 @@ class Account : Service { return client.call( "POST", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = classOf(), converter, ) @@ -147,11 +147,11 @@ class Account : Service { ): io.appwrite.models.User { val apiPath = "/account/email" - val params = mutableMapOf( + val apiParams = mutableMapOf( "email" to email, "password" to password, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @@ -160,8 +160,8 @@ class Account : Service { return client.call( "PATCH", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = classOf(), converter, ) @@ -200,10 +200,10 @@ class Account : Service { ): io.appwrite.models.IdentityList { val apiPath = "/account/identities" - val params = mutableMapOf( + val apiParams = mutableMapOf( "queries" to queries, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.IdentityList = { @@ -212,8 +212,8 @@ class Account : Service { return client.call( "GET", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.IdentityList::class.java, converter, ) @@ -234,16 +234,16 @@ class Account : Service { val apiPath = "/account/identities/{identityId}" .replace("{identityId}", identityId) - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) return client.call( "DELETE", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = Any::class.java, ) } @@ -260,9 +260,9 @@ class Account : Service { ): io.appwrite.models.Jwt { val apiPath = "/account/jwt" - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Jwt = { @@ -271,8 +271,8 @@ class Account : Service { return client.call( "POST", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.Jwt::class.java, converter, ) @@ -293,10 +293,10 @@ class Account : Service { ): io.appwrite.models.LogList { val apiPath = "/account/logs" - val params = mutableMapOf( + val apiParams = mutableMapOf( "queries" to queries, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LogList = { @@ -305,8 +305,8 @@ class Account : Service { return client.call( "GET", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.LogList::class.java, converter, ) @@ -327,10 +327,10 @@ class Account : Service { ): io.appwrite.models.User { val apiPath = "/account/name" - val params = mutableMapOf( + val apiParams = mutableMapOf( "name" to name, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @@ -339,8 +339,8 @@ class Account : Service { return client.call( "PATCH", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = classOf(), converter, ) @@ -379,11 +379,11 @@ class Account : Service { ): io.appwrite.models.User { val apiPath = "/account/password" - val params = mutableMapOf( + val apiParams = mutableMapOf( "password" to password, "oldPassword" to oldPassword, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @@ -392,8 +392,8 @@ class Account : Service { return client.call( "PATCH", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = classOf(), converter, ) @@ -435,11 +435,11 @@ class Account : Service { ): io.appwrite.models.User { val apiPath = "/account/phone" - val params = mutableMapOf( + val apiParams = mutableMapOf( "phone" to phone, "password" to password, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @@ -448,8 +448,8 @@ class Account : Service { return client.call( "PATCH", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = classOf(), converter, ) @@ -486,9 +486,9 @@ class Account : Service { ): io.appwrite.models.Preferences { val apiPath = "/account/prefs" - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { @@ -497,8 +497,8 @@ class Account : Service { return client.call( "GET", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = classOf(), converter, ) @@ -531,10 +531,10 @@ class Account : Service { ): io.appwrite.models.User { val apiPath = "/account/prefs" - val params = mutableMapOf( + val apiParams = mutableMapOf( "prefs" to prefs, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @@ -543,8 +543,8 @@ class Account : Service { return client.call( "PATCH", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = classOf(), converter, ) @@ -581,11 +581,11 @@ class Account : Service { ): io.appwrite.models.Token { val apiPath = "/account/recovery" - val params = mutableMapOf( + val apiParams = mutableMapOf( "email" to email, "url" to url, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @@ -594,8 +594,8 @@ class Account : Service { return client.call( "POST", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.Token::class.java, converter, ) @@ -621,13 +621,13 @@ class Account : Service { ): io.appwrite.models.Token { val apiPath = "/account/recovery" - val params = mutableMapOf( + val apiParams = mutableMapOf( "userId" to userId, "secret" to secret, "password" to password, "passwordAgain" to passwordAgain, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @@ -636,8 +636,8 @@ class Account : Service { return client.call( "PUT", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.Token::class.java, converter, ) @@ -655,9 +655,9 @@ class Account : Service { ): io.appwrite.models.SessionList { val apiPath = "/account/sessions" - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.SessionList = { @@ -666,8 +666,8 @@ class Account : Service { return client.call( "GET", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.SessionList::class.java, converter, ) @@ -685,16 +685,16 @@ class Account : Service { ): Any { val apiPath = "/account/sessions" - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) return client.call( "DELETE", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = Any::class.java, ) } @@ -711,9 +711,9 @@ class Account : Service { ): io.appwrite.models.Session { val apiPath = "/account/sessions/anonymous" - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @@ -722,8 +722,8 @@ class Account : Service { return client.call( "POST", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.Session::class.java, converter, ) @@ -745,11 +745,11 @@ class Account : Service { ): io.appwrite.models.Session { val apiPath = "/account/sessions/email" - val params = mutableMapOf( + val apiParams = mutableMapOf( "email" to email, "password" to password, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @@ -758,8 +758,8 @@ class Account : Service { return client.call( "POST", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.Session::class.java, converter, ) @@ -784,12 +784,12 @@ class Account : Service { ): io.appwrite.models.Token { val apiPath = "/account/sessions/magic-url" - val params = mutableMapOf( + val apiParams = mutableMapOf( "userId" to userId, "email" to email, "url" to url, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @@ -798,8 +798,8 @@ class Account : Service { return client.call( "POST", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.Token::class.java, converter, ) @@ -821,11 +821,11 @@ class Account : Service { ): io.appwrite.models.Session { val apiPath = "/account/sessions/magic-url" - val params = mutableMapOf( + val apiParams = mutableMapOf( "userId" to userId, "secret" to secret, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @@ -834,8 +834,8 @@ class Account : Service { return client.call( "PUT", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.Session::class.java, converter, ) @@ -863,31 +863,31 @@ class Account : Service { val apiPath = "/account/sessions/oauth2/{provider}" .replace("{provider}", provider) - val params = mutableMapOf( + val apiParams = mutableMapOf( "success" to success, "failure" to failure, "scopes" to scopes, "project" to client.config["project"], ) - val query = mutableListOf() - params.forEach { + val apiQuery = mutableListOf() + apiParams.forEach { when (it.value) { null -> { return@forEach } is List<*> -> { - query.add("${it.key}[]=${it.value.toString()}") + apiQuery.add("${it.key}[]=${it.value.toString()}") } else -> { - query.add("${it.key}=${it.value.toString()}") + apiQuery.add("${it.key}=${it.value.toString()}") } } } - val url = Uri.parse("${client.endPoint}${apiPath}?${query.joinToString("&")}") + val apiUrl = Uri.parse("${client.endPoint}${apiPath}?${apiQuery.joinToString("&")}") val callbackUrlScheme = "appwrite-callback-${client.config["project"]}" - WebAuthComponent.authenticate(activity, url, callbackUrlScheme) { + WebAuthComponent.authenticate(activity, apiUrl, callbackUrlScheme) { if (it.isFailure) { throw it.exceptionOrNull()!! } @@ -929,11 +929,11 @@ class Account : Service { ): io.appwrite.models.Token { val apiPath = "/account/sessions/phone" - val params = mutableMapOf( + val apiParams = mutableMapOf( "userId" to userId, "phone" to phone, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @@ -942,8 +942,8 @@ class Account : Service { return client.call( "POST", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.Token::class.java, converter, ) @@ -965,11 +965,11 @@ class Account : Service { ): io.appwrite.models.Session { val apiPath = "/account/sessions/phone" - val params = mutableMapOf( + val apiParams = mutableMapOf( "userId" to userId, "secret" to secret, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @@ -978,8 +978,8 @@ class Account : Service { return client.call( "PUT", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.Session::class.java, converter, ) @@ -1000,9 +1000,9 @@ class Account : Service { val apiPath = "/account/sessions/{sessionId}" .replace("{sessionId}", sessionId) - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @@ -1011,8 +1011,8 @@ class Account : Service { return client.call( "GET", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.Session::class.java, converter, ) @@ -1033,9 +1033,9 @@ class Account : Service { val apiPath = "/account/sessions/{sessionId}" .replace("{sessionId}", sessionId) - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @@ -1044,8 +1044,8 @@ class Account : Service { return client.call( "PATCH", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.Session::class.java, converter, ) @@ -1066,16 +1066,16 @@ class Account : Service { val apiPath = "/account/sessions/{sessionId}" .replace("{sessionId}", sessionId) - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) return client.call( "DELETE", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = Any::class.java, ) } @@ -1093,9 +1093,9 @@ class Account : Service { ): io.appwrite.models.User { val apiPath = "/account/status" - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @@ -1104,8 +1104,8 @@ class Account : Service { return client.call( "PATCH", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = classOf(), converter, ) @@ -1137,10 +1137,10 @@ class Account : Service { ): io.appwrite.models.Token { val apiPath = "/account/verification" - val params = mutableMapOf( + val apiParams = mutableMapOf( "url" to url, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @@ -1149,8 +1149,8 @@ class Account : Service { return client.call( "POST", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.Token::class.java, converter, ) @@ -1172,11 +1172,11 @@ class Account : Service { ): io.appwrite.models.Token { val apiPath = "/account/verification" - val params = mutableMapOf( + val apiParams = mutableMapOf( "userId" to userId, "secret" to secret, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @@ -1185,8 +1185,8 @@ class Account : Service { return client.call( "PUT", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.Token::class.java, converter, ) @@ -1204,9 +1204,9 @@ class Account : Service { ): io.appwrite.models.Token { val apiPath = "/account/verification/phone" - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @@ -1215,8 +1215,8 @@ class Account : Service { return client.call( "POST", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.Token::class.java, converter, ) @@ -1238,11 +1238,11 @@ class Account : Service { ): io.appwrite.models.Token { val apiPath = "/account/verification/phone" - val params = mutableMapOf( + val apiParams = mutableMapOf( "userId" to userId, "secret" to secret, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @@ -1251,8 +1251,8 @@ class Account : Service { return client.call( "PUT", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.Token::class.java, converter, ) diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt index 53277d8..4ee7c4b 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -38,7 +38,7 @@ class Avatars : Service { val apiPath = "/avatars/browsers/{code}" .replace("{code}", code) - val params = mutableMapOf( + val apiParams = mutableMapOf( "width" to width, "height" to height, "quality" to quality, @@ -47,7 +47,7 @@ class Avatars : Service { return client.call( "GET", apiPath, - params = params, + params = apiParams, responseType = ByteArray::class.java ) } @@ -74,7 +74,7 @@ class Avatars : Service { val apiPath = "/avatars/credit-cards/{code}" .replace("{code}", code) - val params = mutableMapOf( + val apiParams = mutableMapOf( "width" to width, "height" to height, "quality" to quality, @@ -83,7 +83,7 @@ class Avatars : Service { return client.call( "GET", apiPath, - params = params, + params = apiParams, responseType = ByteArray::class.java ) } @@ -102,14 +102,14 @@ class Avatars : Service { ): ByteArray { val apiPath = "/avatars/favicon" - val params = mutableMapOf( + val apiParams = mutableMapOf( "url" to url, "project" to client.config["project"], ) return client.call( "GET", apiPath, - params = params, + params = apiParams, responseType = ByteArray::class.java ) } @@ -136,7 +136,7 @@ class Avatars : Service { val apiPath = "/avatars/flags/{code}" .replace("{code}", code) - val params = mutableMapOf( + val apiParams = mutableMapOf( "width" to width, "height" to height, "quality" to quality, @@ -145,7 +145,7 @@ class Avatars : Service { return client.call( "GET", apiPath, - params = params, + params = apiParams, responseType = ByteArray::class.java ) } @@ -169,7 +169,7 @@ class Avatars : Service { ): ByteArray { val apiPath = "/avatars/image" - val params = mutableMapOf( + val apiParams = mutableMapOf( "url" to url, "width" to width, "height" to height, @@ -178,7 +178,7 @@ class Avatars : Service { return client.call( "GET", apiPath, - params = params, + params = apiParams, responseType = ByteArray::class.java ) } @@ -204,7 +204,7 @@ class Avatars : Service { ): ByteArray { val apiPath = "/avatars/initials" - val params = mutableMapOf( + val apiParams = mutableMapOf( "name" to name, "width" to width, "height" to height, @@ -214,7 +214,7 @@ class Avatars : Service { return client.call( "GET", apiPath, - params = params, + params = apiParams, responseType = ByteArray::class.java ) } @@ -240,7 +240,7 @@ class Avatars : Service { ): ByteArray { val apiPath = "/avatars/qr" - val params = mutableMapOf( + val apiParams = mutableMapOf( "text" to text, "size" to size, "margin" to margin, @@ -250,7 +250,7 @@ class Avatars : Service { return client.call( "GET", apiPath, - params = params, + params = apiParams, responseType = ByteArray::class.java ) } diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index 9822e1c..fcc9f74 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -36,10 +36,10 @@ class Databases : Service { .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) - val params = mutableMapOf( + val apiParams = mutableMapOf( "queries" to queries, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.DocumentList = { @@ -48,8 +48,8 @@ class Databases : Service { return client.call( "GET", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = classOf(), converter, ) @@ -103,12 +103,12 @@ class Databases : Service { .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) - val params = mutableMapOf( + val apiParams = mutableMapOf( "documentId" to documentId, "data" to data, "permissions" to permissions, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { @@ -117,8 +117,8 @@ class Databases : Service { return client.call( "POST", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = classOf(), converter, ) @@ -177,10 +177,10 @@ class Databases : Service { .replace("{collectionId}", collectionId) .replace("{documentId}", documentId) - val params = mutableMapOf( + val apiParams = mutableMapOf( "queries" to queries, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { @@ -189,8 +189,8 @@ class Databases : Service { return client.call( "GET", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = classOf(), converter, ) @@ -248,11 +248,11 @@ class Databases : Service { .replace("{collectionId}", collectionId) .replace("{documentId}", documentId) - val params = mutableMapOf( + val apiParams = mutableMapOf( "data" to data, "permissions" to permissions, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { @@ -261,8 +261,8 @@ class Databases : Service { return client.call( "PATCH", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = classOf(), converter, ) @@ -317,16 +317,16 @@ class Databases : Service { .replace("{collectionId}", collectionId) .replace("{documentId}", documentId) - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) return client.call( "DELETE", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = Any::class.java, ) } diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index eadcf0d..6b13e67 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -34,11 +34,11 @@ class Functions : Service { val apiPath = "/functions/{functionId}/executions" .replace("{functionId}", functionId) - val params = mutableMapOf( + val apiParams = mutableMapOf( "queries" to queries, "search" to search, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.ExecutionList = { @@ -47,8 +47,8 @@ class Functions : Service { return client.call( "GET", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.ExecutionList::class.java, converter, ) @@ -80,14 +80,14 @@ class Functions : Service { val apiPath = "/functions/{functionId}/executions" .replace("{functionId}", functionId) - val params = mutableMapOf( + val apiParams = mutableMapOf( "body" to body, "async" to async, "path" to path, "method" to method, "headers" to headers, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Execution = { @@ -96,8 +96,8 @@ class Functions : Service { return client.call( "POST", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.Execution::class.java, converter, ) @@ -121,9 +121,9 @@ class Functions : Service { .replace("{functionId}", functionId) .replace("{executionId}", executionId) - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Execution = { @@ -132,8 +132,8 @@ class Functions : Service { return client.call( "GET", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.Execution::class.java, converter, ) diff --git a/library/src/main/java/io/appwrite/services/Graphql.kt b/library/src/main/java/io/appwrite/services/Graphql.kt index 2d9bbbd..dfe884a 100644 --- a/library/src/main/java/io/appwrite/services/Graphql.kt +++ b/library/src/main/java/io/appwrite/services/Graphql.kt @@ -28,10 +28,10 @@ class Graphql : Service { ): Any { val apiPath = "/graphql" - val params = mutableMapOf( + val apiParams = mutableMapOf( "query" to query, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "x-sdk-graphql" to "true", "content-type" to "application/json", ) @@ -41,8 +41,8 @@ class Graphql : Service { return client.call( "POST", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = Any::class.java, converter, ) @@ -62,10 +62,10 @@ class Graphql : Service { ): Any { val apiPath = "/graphql/mutation" - val params = mutableMapOf( + val apiParams = mutableMapOf( "query" to query, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "x-sdk-graphql" to "true", "content-type" to "application/json", ) @@ -75,8 +75,8 @@ class Graphql : Service { return client.call( "POST", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = Any::class.java, converter, ) diff --git a/library/src/main/java/io/appwrite/services/Locale.kt b/library/src/main/java/io/appwrite/services/Locale.kt index b0e93a6..3c3c418 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -26,9 +26,9 @@ class Locale : Service { ): io.appwrite.models.Locale { val apiPath = "/locale" - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Locale = { @@ -37,8 +37,8 @@ class Locale : Service { return client.call( "GET", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.Locale::class.java, converter, ) @@ -56,9 +56,9 @@ class Locale : Service { ): io.appwrite.models.LocaleCodeList { val apiPath = "/locale/codes" - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LocaleCodeList = { @@ -67,8 +67,8 @@ class Locale : Service { return client.call( "GET", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.LocaleCodeList::class.java, converter, ) @@ -86,9 +86,9 @@ class Locale : Service { ): io.appwrite.models.ContinentList { val apiPath = "/locale/continents" - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.ContinentList = { @@ -97,8 +97,8 @@ class Locale : Service { return client.call( "GET", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.ContinentList::class.java, converter, ) @@ -116,9 +116,9 @@ class Locale : Service { ): io.appwrite.models.CountryList { val apiPath = "/locale/countries" - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CountryList = { @@ -127,8 +127,8 @@ class Locale : Service { return client.call( "GET", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.CountryList::class.java, converter, ) @@ -146,9 +146,9 @@ class Locale : Service { ): io.appwrite.models.CountryList { val apiPath = "/locale/countries/eu" - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CountryList = { @@ -157,8 +157,8 @@ class Locale : Service { return client.call( "GET", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.CountryList::class.java, converter, ) @@ -176,9 +176,9 @@ class Locale : Service { ): io.appwrite.models.PhoneList { val apiPath = "/locale/countries/phones" - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.PhoneList = { @@ -187,8 +187,8 @@ class Locale : Service { return client.call( "GET", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.PhoneList::class.java, converter, ) @@ -206,9 +206,9 @@ class Locale : Service { ): io.appwrite.models.CurrencyList { val apiPath = "/locale/currencies" - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CurrencyList = { @@ -217,8 +217,8 @@ class Locale : Service { return client.call( "GET", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.CurrencyList::class.java, converter, ) @@ -236,9 +236,9 @@ class Locale : Service { ): io.appwrite.models.LanguageList { val apiPath = "/locale/languages" - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LanguageList = { @@ -247,8 +247,8 @@ class Locale : Service { return client.call( "GET", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.LanguageList::class.java, converter, ) diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index bb5a59e..4d61bbb 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -36,11 +36,11 @@ class Storage : Service { val apiPath = "/storage/buckets/{bucketId}/files" .replace("{bucketId}", bucketId) - val params = mutableMapOf( + val apiParams = mutableMapOf( "queries" to queries, "search" to search, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.FileList = { @@ -49,8 +49,8 @@ class Storage : Service { return client.call( "GET", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.FileList::class.java, converter, ) @@ -79,12 +79,12 @@ class Storage : Service { val apiPath = "/storage/buckets/{bucketId}/files" .replace("{bucketId}", bucketId) - val params = mutableMapOf( + val apiParams = mutableMapOf( "fileId" to fileId, "file" to file, "permissions" to permissions, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "multipart/form-data", ) val converter: (Any) -> io.appwrite.models.File = { @@ -94,8 +94,8 @@ class Storage : Service { val paramName = "file" return client.chunkedUpload( apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.File::class.java, converter, paramName, @@ -122,9 +122,9 @@ class Storage : Service { .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.File = { @@ -133,8 +133,8 @@ class Storage : Service { return client.call( "GET", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.File::class.java, converter, ) @@ -163,11 +163,11 @@ class Storage : Service { .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) - val params = mutableMapOf( + val apiParams = mutableMapOf( "name" to name, "permissions" to permissions, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.File = { @@ -176,8 +176,8 @@ class Storage : Service { return client.call( "PUT", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.File::class.java, converter, ) @@ -201,16 +201,16 @@ class Storage : Service { .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) return client.call( "DELETE", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = Any::class.java, ) } @@ -233,13 +233,13 @@ class Storage : Service { .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) - val params = mutableMapOf( + val apiParams = mutableMapOf( "project" to client.config["project"], ) return client.call( "GET", apiPath, - params = params, + params = apiParams, responseType = ByteArray::class.java ) } @@ -285,7 +285,7 @@ class Storage : Service { .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) - val params = mutableMapOf( + val apiParams = mutableMapOf( "width" to width, "height" to height, "gravity" to gravity, @@ -302,7 +302,7 @@ class Storage : Service { return client.call( "GET", apiPath, - params = params, + params = apiParams, responseType = ByteArray::class.java ) } @@ -325,13 +325,13 @@ class Storage : Service { .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) - val params = mutableMapOf( + val apiParams = mutableMapOf( "project" to client.config["project"], ) return client.call( "GET", apiPath, - params = params, + params = apiParams, responseType = ByteArray::class.java ) } diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index a64a152..8cec2d4 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -32,11 +32,11 @@ class Teams : Service { ): io.appwrite.models.TeamList { val apiPath = "/teams" - val params = mutableMapOf( + val apiParams = mutableMapOf( "queries" to queries, "search" to search, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.TeamList = { @@ -45,8 +45,8 @@ class Teams : Service { return client.call( "GET", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = classOf(), converter, ) @@ -91,12 +91,12 @@ class Teams : Service { ): io.appwrite.models.Team { val apiPath = "/teams" - val params = mutableMapOf( + val apiParams = mutableMapOf( "teamId" to teamId, "name" to name, "roles" to roles, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Team = { @@ -105,8 +105,8 @@ class Teams : Service { return client.call( "POST", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = classOf(), converter, ) @@ -150,9 +150,9 @@ class Teams : Service { val apiPath = "/teams/{teamId}" .replace("{teamId}", teamId) - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Team = { @@ -161,8 +161,8 @@ class Teams : Service { return client.call( "GET", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = classOf(), converter, ) @@ -201,10 +201,10 @@ class Teams : Service { val apiPath = "/teams/{teamId}" .replace("{teamId}", teamId) - val params = mutableMapOf( + val apiParams = mutableMapOf( "name" to name, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Team = { @@ -213,8 +213,8 @@ class Teams : Service { return client.call( "PUT", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = classOf(), converter, ) @@ -253,16 +253,16 @@ class Teams : Service { val apiPath = "/teams/{teamId}" .replace("{teamId}", teamId) - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) return client.call( "DELETE", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = Any::class.java, ) } @@ -287,11 +287,11 @@ class Teams : Service { val apiPath = "/teams/{teamId}/memberships" .replace("{teamId}", teamId) - val params = mutableMapOf( + val apiParams = mutableMapOf( "queries" to queries, "search" to search, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MembershipList = { @@ -300,8 +300,8 @@ class Teams : Service { return client.call( "GET", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.MembershipList::class.java, converter, ) @@ -335,7 +335,7 @@ class Teams : Service { val apiPath = "/teams/{teamId}/memberships" .replace("{teamId}", teamId) - val params = mutableMapOf( + val apiParams = mutableMapOf( "email" to email, "userId" to userId, "phone" to phone, @@ -343,7 +343,7 @@ class Teams : Service { "url" to url, "name" to name, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { @@ -352,8 +352,8 @@ class Teams : Service { return client.call( "POST", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.Membership::class.java, converter, ) @@ -377,9 +377,9 @@ class Teams : Service { .replace("{teamId}", teamId) .replace("{membershipId}", membershipId) - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { @@ -388,8 +388,8 @@ class Teams : Service { return client.call( "GET", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.Membership::class.java, converter, ) @@ -415,10 +415,10 @@ class Teams : Service { .replace("{teamId}", teamId) .replace("{membershipId}", membershipId) - val params = mutableMapOf( + val apiParams = mutableMapOf( "roles" to roles, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { @@ -427,8 +427,8 @@ class Teams : Service { return client.call( "PATCH", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.Membership::class.java, converter, ) @@ -452,16 +452,16 @@ class Teams : Service { .replace("{teamId}", teamId) .replace("{membershipId}", membershipId) - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) return client.call( "DELETE", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = Any::class.java, ) } @@ -488,11 +488,11 @@ class Teams : Service { .replace("{teamId}", teamId) .replace("{membershipId}", membershipId) - val params = mutableMapOf( + val apiParams = mutableMapOf( "userId" to userId, "secret" to secret, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { @@ -501,8 +501,8 @@ class Teams : Service { return client.call( "PATCH", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = io.appwrite.models.Membership::class.java, converter, ) @@ -524,9 +524,9 @@ class Teams : Service { val apiPath = "/teams/{teamId}/prefs" .replace("{teamId}", teamId) - val params = mutableMapOf( + val apiParams = mutableMapOf( ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { @@ -535,8 +535,8 @@ class Teams : Service { return client.call( "GET", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = classOf(), converter, ) @@ -575,10 +575,10 @@ class Teams : Service { val apiPath = "/teams/{teamId}/prefs" .replace("{teamId}", teamId) - val params = mutableMapOf( + val apiParams = mutableMapOf( "prefs" to prefs, ) - val headers = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { @@ -587,8 +587,8 @@ class Teams : Service { return client.call( "PUT", apiPath, - headers, - params, + apiHeaders, + apiParams, responseType = classOf(), converter, ) From 048b7b7fadbbf648b99c0eaeb2883f4878f7a227 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Fri, 1 Sep 2023 17:29:12 +0000 Subject: [PATCH 053/118] chore: update sdks for appwrite 1.4.x --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 31b2006..ff0bb69 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![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.4.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.4.1-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) From abf96e39fe76734fe2277ab61b168e6be708ba25 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 7 Sep 2023 21:24:24 +0000 Subject: [PATCH 054/118] chore: bug fixes for Apwrite 1.4.2 --- README.md | 2 +- docs/examples/java/teams/create-membership.md | 1 - docs/examples/kotlin/teams/create-membership.md | 1 - library/src/main/java/io/appwrite/services/Teams.kt | 4 ++-- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ff0bb69..0a917d0 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![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.4.1-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.4.2-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) diff --git a/docs/examples/java/teams/create-membership.md b/docs/examples/java/teams/create-membership.md index 6c8b383..6073f5b 100644 --- a/docs/examples/java/teams/create-membership.md +++ b/docs/examples/java/teams/create-membership.md @@ -11,7 +11,6 @@ Teams teams = new Teams(client); teams.createMembership( "[TEAM_ID]", listOf(), - "https://example.com", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/kotlin/teams/create-membership.md b/docs/examples/kotlin/teams/create-membership.md index afc9336..4d1de49 100644 --- a/docs/examples/kotlin/teams/create-membership.md +++ b/docs/examples/kotlin/teams/create-membership.md @@ -10,5 +10,4 @@ val teams = Teams(client) val response = teams.createMembership( teamId = "[TEAM_ID]", roles = listOf(), - url = "https://example.com", ) diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 8cec2d4..4d48b33 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -315,10 +315,10 @@ class Teams : Service { * * @param teamId Team ID. * @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 email Email of the new team member. * @param userId ID of the user to be added to a team. * @param phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @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] */ @@ -326,10 +326,10 @@ class Teams : Service { suspend fun createMembership( teamId: String, roles: List, - url: String, email: String? = null, userId: String? = null, phone: String? = null, + url: String? = null, name: String? = null, ): io.appwrite.models.Membership { val apiPath = "/teams/{teamId}/memberships" From 12ac5124a20d830178ce091c44ed576bb659b3e0 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 7 Sep 2023 21:34:38 +0000 Subject: [PATCH 055/118] chore: updates for appwrite 1.4.2 --- README.md | 4 ++-- library/src/main/java/io/appwrite/Client.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0a917d0..5fdf795 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:3.0.1") +implementation("io.appwrite:sdk-for-android:3.0.2") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 3.0.1 + 3.0.2 ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index d0e546a..b69cbec 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 "3.0.1", + "x-sdk-version" to "3.0.2", "x-appwrite-response-format" to "1.4.0" ) config = mutableMapOf() From bfefd97dcbcaed2463925d96a2d2ba2a1054d874 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 7 Sep 2023 21:51:25 +0000 Subject: [PATCH 056/118] chore: updates for appwrite 1.4.2 --- README.md | 4 ++-- library/src/main/java/io/appwrite/Client.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5fdf795..16c3d84 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:3.0.2") +implementation("io.appwrite:sdk-for-android:4.0.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 3.0.2 + 4.0.0 ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index b69cbec..c6235ef 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 "3.0.2", + "x-sdk-version" to "4.0.0", "x-appwrite-response-format" to "1.4.0" ) config = mutableMapOf() From a9c3550195463cd1be0999563c18746c80dfec71 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 16 Nov 2023 16:54:56 +1300 Subject: [PATCH 057/118] Fix between query output --- README.md | 6 +- library/src/main/java/io/appwrite/Client.kt | 2 +- library/src/main/java/io/appwrite/Query.kt | 6 +- .../main/java/io/appwrite/enums/Browser.kt | 20 ++ .../main/java/io/appwrite/enums/CreditCard.kt | 22 ++ .../src/main/java/io/appwrite/enums/Flag.kt | 200 ++++++++++++++++++ .../java/io/appwrite/enums/ImageFormat.kt | 11 + .../java/io/appwrite/enums/ImageGravity.kt | 15 ++ .../src/main/java/io/appwrite/enums/Method.kt | 12 ++ .../main/java/io/appwrite/enums/Provider.kt | 44 ++++ .../main/java/io/appwrite/models/Document.kt | 2 +- .../src/main/java/io/appwrite/models/File.kt | 2 +- .../main/java/io/appwrite/services/Account.kt | 106 +++++----- .../main/java/io/appwrite/services/Avatars.kt | 18 +- .../java/io/appwrite/services/Databases.kt | 30 +-- .../java/io/appwrite/services/Functions.kt | 6 +- .../main/java/io/appwrite/services/Graphql.kt | 4 +- .../main/java/io/appwrite/services/Locale.kt | 14 +- .../main/java/io/appwrite/services/Storage.kt | 38 ++-- .../main/java/io/appwrite/services/Teams.kt | 52 ++--- 20 files changed, 467 insertions(+), 143 deletions(-) create mode 100644 library/src/main/java/io/appwrite/enums/Browser.kt create mode 100644 library/src/main/java/io/appwrite/enums/CreditCard.kt create mode 100644 library/src/main/java/io/appwrite/enums/Flag.kt create mode 100644 library/src/main/java/io/appwrite/enums/ImageFormat.kt create mode 100644 library/src/main/java/io/appwrite/enums/ImageGravity.kt create mode 100644 library/src/main/java/io/appwrite/enums/Method.kt create mode 100644 library/src/main/java/io/appwrite/enums/Provider.kt diff --git a/README.md b/README.md index 16c3d84..e5d5922 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![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.4.2-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.4.12-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) @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:4.0.0") +implementation("io.appwrite:sdk-for-android:4.0.1") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 4.0.0 + 4.0.1 ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index c6235ef..94f82b6 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 "4.0.0", + "x-sdk-version" to "4.0.1", "x-appwrite-response-format" to "1.4.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/Query.kt b/library/src/main/java/io/appwrite/Query.kt index ad1f3ed..7957865 100644 --- a/library/src/main/java/io/appwrite/Query.kt +++ b/library/src/main/java/io/appwrite/Query.kt @@ -20,11 +20,11 @@ class Query { fun isNotNull(attribute: String) = "isNotNull(\"${attribute}\")" - fun between(attribute: String, start: Int, end: Int) = Query.addQuery(attribute, "between", listOf(start, end)) + fun between(attribute: String, start: Int, end: Int) = "between(\"${attribute}\", ${start}, ${end})" - fun between(attribute: String, start: Double, end: Double) = Query.addQuery(attribute, "between", listOf(start, end)) + fun between(attribute: String, start: Double, end: Double) = "between(\"${attribute}\", ${start}, ${end})" - fun between(attribute: String, start: String, end: String) = Query.addQuery(attribute, "between", listOf(start, end)) + fun between(attribute: String, start: String, end: String) = "between(\"${attribute}\", \"${start}\", \"${end}\")" fun startsWith(attribute: String, value: String) = Query.addQuery(attribute, "startsWith", value) diff --git a/library/src/main/java/io/appwrite/enums/Browser.kt b/library/src/main/java/io/appwrite/enums/Browser.kt new file mode 100644 index 0000000..99f598e --- /dev/null +++ b/library/src/main/java/io/appwrite/enums/Browser.kt @@ -0,0 +1,20 @@ +package io.appwrite.enums + +enum class Browser(val value: String) { + AVANT_BROWSER("aa"), + ANDROID_WEB_VIEW_BETA("an"), + GOOGLE_CHROME("ch"), + GOOGLE_CHROMEI_OS("ci"), + GOOGLE_CHROME_MOBILE("cm"), + CHROMIUM("cr"), + MOZILLA_FIREFOX("ff"), + SAFARI("sf"), + MOBILE_SAFARI("mf"), + MICROSOFT_EDGE("ps"), + MICROSOFT_EDGEI_OS("oi"), + OPERA_MINI("om"), + OPERA("op"), + OPERA_NEXT("on"); + + override fun toString() = value +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/CreditCard.kt b/library/src/main/java/io/appwrite/enums/CreditCard.kt new file mode 100644 index 0000000..e99519b --- /dev/null +++ b/library/src/main/java/io/appwrite/enums/CreditCard.kt @@ -0,0 +1,22 @@ +package io.appwrite.enums + +enum class CreditCard(val value: String) { + AMERICAN_EXPRESS("amex"), + ARGENCARD("argencard"), + CABAL("cabal"), + CONSOSUD("censosud"), + DINERS_CLUB("diners"), + DISCOVER("discover"), + ELO("elo"), + HIPERCARD("hipercard"), + JCB("jcb"), + MASTERCARD("mastercard"), + NARANJA("naranja"), + TARJETA_SHOPPING("targeta-shopping"), + UNION_CHINA_PAY("union-china-pay"), + VISA("visa"), + MIR("mir"), + MAESTRO("maestro"); + + override fun toString() = value +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/Flag.kt b/library/src/main/java/io/appwrite/enums/Flag.kt new file mode 100644 index 0000000..4fcdd88 --- /dev/null +++ b/library/src/main/java/io/appwrite/enums/Flag.kt @@ -0,0 +1,200 @@ +package io.appwrite.enums + +enum class Flag(val value: String) { + AFGHANISTAN("af"), + ANGOLA("ao"), + ALBANIA("al"), + ANDORRA("ad"), + UNITED_ARAB_EMIRATES("ae"), + ARGENTINA("ar"), + ARMENIA("am"), + ANTIGUAAND_BARBUDA("ag"), + AUSTRALIA("au"), + AUSTRIA("at"), + AZERBAIJAN("az"), + BURUNDI("bi"), + BELGIUM("be"), + BENIN("bj"), + BURKINA_FASO("bf"), + BANGLADESH("bd"), + BULGARIA("bg"), + BAHRAIN("bh"), + BAHAMAS("bs"), + BOSNIAAND_HERZEGOVINA("ba"), + BELARUS("by"), + BELIZE("bz"), + BOLIVIA("bo"), + BRAZIL("br"), + BARBADOS("bb"), + BRUNEI_DARUSSALAM("bn"), + BHUTAN("bt"), + BOTSWANA("bw"), + CENTRAL_AFRICAN_REPUBLIC("cf"), + CANADA("ca"), + SWITZERLAND("ch"), + CHILE("cl"), + CHINA("cn"), + CTED_IVOIRE("ci"), + CAMEROON("cm"), + DEMOCRATIC_REPUBLICOFTHE_CONGO("cd"), + REPUBLICOFTHE_CONGO("cg"), + COLOMBIA("co"), + COMOROS("km"), + CAPE_VERDE("cv"), + COSTA_RICA("cr"), + CUBA("cu"), + CYPRUS("cy"), + CZECH_REPUBLIC("cz"), + GERMANY("de"), + DJIBOUTI("dj"), + DOMINICA("dm"), + DENMARK("dk"), + DOMINICAN_REPUBLIC("do"), + ALGERIA("dz"), + ECUADOR("ec"), + EGYPT("eg"), + ERITREA("er"), + SPAIN("es"), + ESTONIA("ee"), + ETHIOPIA("et"), + FINLAND("fi"), + FIJI("fj"), + FRANCE("fr"), + MICRONESIA_FEDERATED_STATESOF("fm"), + GABON("ga"), + UNITED_KINGDOM("gb"), + GEORGIA("ge"), + GHANA("gh"), + GUINEA("gn"), + GAMBIA("gm"), + GUINEA_BISSAU("gw"), + EQUATORIAL_GUINEA("gq"), + GREECE("gr"), + GRENADA("gd"), + GUATEMALA("gt"), + GUYANA("gy"), + HONDURAS("hn"), + CROATIA("hr"), + HAITI("ht"), + HUNGARY("hu"), + INDONESIA("id"), + INDIA("in"), + IRELAND("ie"), + IRAN_ISLAMIC_REPUBLICOF("ir"), + IRAQ("iq"), + ICELAND("is"), + ISRAEL("il"), + ITALY("it"), + JAMAICA("jm"), + JORDAN("jo"), + JAPAN("jp"), + KAZAKHSTAN("kz"), + KENYA("ke"), + KYRGYZSTAN("kg"), + CAMBODIA("kh"), + KIRIBATI("ki"), + SAINT_KITTSAND_NEVIS("kn"), + SOUTH_KOREA("kr"), + KUWAIT("kw"), + LAO_PEOPLES_DEMOCRATIC_REPUBLIC("la"), + LEBANON("lb"), + LIBERIA("lr"), + LIBYA("ly"), + SAINT_LUCIA("lc"), + LIECHTENSTEIN("li"), + SRI_LANKA("lk"), + LESOTHO("ls"), + LITHUANIA("lt"), + LUXEMBOURG("lu"), + LATVIA("lv"), + MOROCCO("ma"), + MONACO("mc"), + MOLDOVA("md"), + MADAGASCAR("mg"), + MALDIVES("mv"), + MEXICO("mx"), + MARSHALL_ISLANDS("mh"), + NORTH_MACEDONIA("mk"), + MALI("ml"), + MALTA("mt"), + MYANMAR("mm"), + MONTENEGRO("me"), + MONGOLIA("mn"), + MOZAMBIQUE("mz"), + MAURITANIA("mr"), + MAURITIUS("mu"), + MALAWI("mw"), + MALAYSIA("my"), + NAMIBIA("na"), + NIGER("ne"), + NIGERIA("ng"), + NICARAGUA("ni"), + NETHERLANDS("nl"), + NORWAY("no"), + NEPAL("np"), + NAURU("nr"), + NEW_ZEALAND("nz"), + OMAN("om"), + PAKISTAN("pk"), + PANAMA("pa"), + PERU("pe"), + PHILIPPINES("ph"), + PALAU("pw"), + PAPUA_NEW_GUINEA("pg"), + POLAND("pl"), + NORTH_KOREA("kp"), + PORTUGAL("pt"), + PARAGUAY("py"), + QATAR("qa"), + ROMANIA("ro"), + RUSSIA("ru"), + RWANDA("rw"), + SAUDI_ARABIA("sa"), + SUDAN("sd"), + SENEGAL("sn"), + SINGAPORE("sg"), + SOLOMON_ISLANDS("sb"), + SIERRA_LEONE("sl"), + EL_SALVADOR("sv"), + SAN_MARINO("sm"), + SOMALIA("so"), + SERBIA("rs"), + SOUTH_SUDAN("ss"), + SAO_TOMEAND_PRINCIPE("st"), + SURINAME("sr"), + SLOVAKIA("sk"), + SLOVENIA("si"), + SWEDEN("se"), + ESWATINI("sz"), + SEYCHELLES("sc"), + SYRIA("sy"), + CHAD("td"), + TOGO("tg"), + THAILAND("th"), + TAJIKISTAN("tj"), + TURKMENISTAN("tm"), + TIMOR_LESTE("tl"), + TONGA("to"), + TRINIDADAND_TOBAGO("tt"), + TUNISIA("tn"), + TURKEY("tr"), + TUVALU("tv"), + TANZANIA("tz"), + UGANDA("ug"), + UKRAINE("ua"), + URUGUAY("uy"), + UNITED_STATES("us"), + UZBEKISTAN("uz"), + VATICAN_CITY("va"), + SAINT_VINCENTANDTHE_GRENADINES("vc"), + VENEZUELA("ve"), + VIETNAM("vn"), + VANUATU("vu"), + SAMOA("ws"), + YEMEN("ye"), + SOUTH_AFRICA("za"), + ZAMBIA("zm"), + ZIMBABWE("zw"); + + override fun toString() = value +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/ImageFormat.kt b/library/src/main/java/io/appwrite/enums/ImageFormat.kt new file mode 100644 index 0000000..6a4c422 --- /dev/null +++ b/library/src/main/java/io/appwrite/enums/ImageFormat.kt @@ -0,0 +1,11 @@ +package io.appwrite.enums + +enum class ImageFormat(val value: String) { + JPG("jpg"), + JPEG("jpeg"), + GIF("gif"), + PNG("png"), + WEBP("webp"); + + override fun toString() = value +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/ImageGravity.kt b/library/src/main/java/io/appwrite/enums/ImageGravity.kt new file mode 100644 index 0000000..a8fa441 --- /dev/null +++ b/library/src/main/java/io/appwrite/enums/ImageGravity.kt @@ -0,0 +1,15 @@ +package io.appwrite.enums + +enum class ImageGravity(val value: String) { + CENTER("center"), + TOPLEFT("top-left"), + TOP("top"), + TOPRIGHT("top-right"), + LEFT("left"), + RIGHT("right"), + BOTTOMLEFT("bottom-left"), + BOTTOM("bottom"), + BOTTOMRIGHT("bottom-right"); + + override fun toString() = value +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/Method.kt b/library/src/main/java/io/appwrite/enums/Method.kt new file mode 100644 index 0000000..a483270 --- /dev/null +++ b/library/src/main/java/io/appwrite/enums/Method.kt @@ -0,0 +1,12 @@ +package io.appwrite.enums + +enum class Method(val value: String) { + GET("GET"), + POST("POST"), + PUT("PUT"), + PATCH("PATCH"), + DELETE("DELETE"), + OPTIONS("OPTIONS"); + + override fun toString() = value +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/Provider.kt b/library/src/main/java/io/appwrite/enums/Provider.kt new file mode 100644 index 0000000..472f0d4 --- /dev/null +++ b/library/src/main/java/io/appwrite/enums/Provider.kt @@ -0,0 +1,44 @@ +package io.appwrite.enums + +enum class Provider(val value: String) { + AMAZON("amazon"), + APPLE("apple"), + AUTH0("auth0"), + AUTHENTIK("authentik"), + AUTODESK("autodesk"), + BITBUCKET("bitbucket"), + BITLY("bitly"), + BOX("box"), + DAILYMOTION("dailymotion"), + DISCORD("discord"), + DISQUS("disqus"), + DROPBOX("dropbox"), + ETSY("etsy"), + FACEBOOK("facebook"), + GITHUB("github"), + GITLAB("gitlab"), + GOOGLE("google"), + LINKEDIN("linkedin"), + MICROSOFT("microsoft"), + NOTION("notion"), + OIDC("oidc"), + OKTA("okta"), + PAYPAL("paypal"), + PAYPAL_SANDBOX("paypalSandbox"), + PODIO("podio"), + SALESFORCE("salesforce"), + SLACK("slack"), + SPOTIFY("spotify"), + STRIPE("stripe"), + TRADESHIFT("tradeshift"), + TRADESHIFT_BOX("tradeshiftBox"), + TWITCH("twitch"), + WORDPRESS("wordpress"), + YAHOO("yahoo"), + YAMMER("yammer"), + YANDEX("yandex"), + ZOOM("zoom"), + MOCK("mock"); + + override fun toString() = value +} \ 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 27830d4..5a7d371 100644 --- a/library/src/main/java/io/appwrite/models/Document.kt +++ b/library/src/main/java/io/appwrite/models/Document.kt @@ -38,7 +38,7 @@ data class Document( val updatedAt: String, /** - * Document permissions. [Learn more about permissions](/docs/permissions). + * Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). */ @SerializedName("\$permissions") val permissions: List, diff --git a/library/src/main/java/io/appwrite/models/File.kt b/library/src/main/java/io/appwrite/models/File.kt index bd35d42..5c2b731 100644 --- a/library/src/main/java/io/appwrite/models/File.kt +++ b/library/src/main/java/io/appwrite/models/File.kt @@ -32,7 +32,7 @@ data class File( val updatedAt: String, /** - * File permissions. [Learn more about permissions](/docs/permissions). + * File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). */ @SerializedName("\$permissions") val permissions: List, diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 863ad27..3c9cca1 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -20,7 +20,7 @@ class Account : Service { public constructor (client: Client) : super(client) { } /** - * Get Account + * Get account * * Get the currently logged in user. * @@ -50,7 +50,7 @@ class Account : Service { } /** - * Get Account + * Get account * * Get the currently logged in user. * @@ -63,9 +63,9 @@ class Account : Service { ) /** - * Create Account + * 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](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). * * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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. @@ -106,9 +106,9 @@ class Account : Service { } /** - * Create Account + * 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](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). * * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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. @@ -132,7 +132,7 @@ class Account : Service { ) /** - * Update Email + * 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. * @@ -168,7 +168,7 @@ class Account : Service { } /** - * Update Email + * 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. * @@ -280,7 +280,7 @@ class Account : Service { /** - * List Logs + * List logs * * Get the list of latest security activity logs for the currently logged in user. Each log returns user IP address, location and date and time of log. * @@ -314,7 +314,7 @@ class Account : Service { /** - * Update Name + * Update name * * Update currently logged in user account name. * @@ -347,7 +347,7 @@ class Account : Service { } /** - * Update Name + * Update name * * Update currently logged in user account name. * @@ -363,7 +363,7 @@ class Account : Service { ) /** - * Update Password + * 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. * @@ -400,7 +400,7 @@ class Account : Service { } /** - * Update Password + * 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. * @@ -420,9 +420,9 @@ class Account : Service { ) /** - * Update Phone + * 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. + * 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](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) 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. @@ -456,9 +456,9 @@ class Account : Service { } /** - * Update Phone + * 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. + * 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](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) 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. @@ -475,7 +475,7 @@ class Account : Service { ) /** - * Get Account Preferences + * Get account preferences * * Get the preferences as a key-value object for the currently logged in user. * @@ -505,7 +505,7 @@ class Account : Service { } /** - * Get Account Preferences + * Get account preferences * * Get the preferences as a key-value object for the currently logged in user. * @@ -518,7 +518,7 @@ class Account : Service { ) /** - * Update Preferences + * 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. * @@ -551,7 +551,7 @@ class Account : Service { } /** - * Update Preferences + * 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. * @@ -567,9 +567,9 @@ class Account : Service { ) /** - * Create Password Recovery + * 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](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) 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. @@ -603,9 +603,9 @@ class Account : Service { /** - * Create Password Recovery (confirmation) + * 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](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) 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. @@ -645,7 +645,7 @@ class Account : Service { /** - * List Sessions + * List sessions * * Get the list of active sessions across different devices for the currently logged in user. * @@ -675,7 +675,7 @@ class Account : Service { /** - * Delete Sessions + * Delete sessions * * Delete all sessions from the user account and remove any sessions cookies from the end client. * @@ -701,9 +701,9 @@ class Account : Service { /** - * Create Anonymous Session + * 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](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail) or create an [OAuth2 session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session). * * @return [io.appwrite.models.Session] */ @@ -731,9 +731,9 @@ class Account : Service { /** - * Create Email Session + * 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.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](/docs/authentication-security#limits). + * Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * @param email User email. * @param password User password. Must be at least 8 chars. @@ -767,9 +767,9 @@ class Account : Service { /** - * Create Magic URL session + * Create magic URL session * - * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [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-security#limits). + * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [PUT /account/sessions/magic-url](https://appwrite.io/docs/references/cloud/client-web/account#updateMagicURLSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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. @@ -807,9 +807,9 @@ class Account : Service { /** - * Create Magic URL session (confirmation) + * 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](https://appwrite.io/docs/references/cloud/client-web/account#createMagicURLSession) 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. @@ -843,9 +843,9 @@ class Account : Service { /** - * Create OAuth2 Session + * 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-security#limits). + * 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](https://appwrite.io/docs/authentication-security#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, oidc, 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's 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. @@ -915,9 +915,9 @@ class Account : Service { /** - * Create Phone session + * 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.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](/docs/authentication-security#limits). + * 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](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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. @@ -951,9 +951,9 @@ class Account : Service { /** - * Create Phone Session (confirmation) + * 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](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneSession) endpoint and the **secret** received via SMS to successfully update and confirm the phone session. * * @param userId User ID. * @param secret Valid verification token. @@ -987,7 +987,7 @@ class Account : Service { /** - * Get Session + * 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. * @@ -1020,7 +1020,7 @@ class Account : Service { /** - * Update OAuth 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. * @@ -1053,9 +1053,9 @@ class Account : Service { /** - * Delete Session + * Delete session * - * Logout the user. Use 'current' as the session ID to logout on this device, use a session ID to logout on another device. If you're looking to logout the user on all devices, use [Delete Sessions](/docs/client/account#accountDeleteSessions) instead. + * Logout the user. Use 'current' as the session ID to logout on this device, use a session ID to logout on another device. If you're looking to logout the user on all devices, use [Delete Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) instead. * * @param sessionId Session ID. Use the string 'current' to delete the current device session. * @return [Any] @@ -1082,7 +1082,7 @@ class Account : Service { /** - * Update 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. * @@ -1112,7 +1112,7 @@ class Account : Service { } /** - * Update 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. * @@ -1125,9 +1125,9 @@ class Account : Service { ) /** - * Create Email Verification + * 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](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). 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] @@ -1158,7 +1158,7 @@ class Account : Service { /** - * Create Email Verification (confirmation) + * 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. * @@ -1194,9 +1194,9 @@ class Account : Service { /** - * Create Phone Verification + * 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](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone) endpoint. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification). The verification code sent to the user's phone number is valid for 15 minutes. * * @return [io.appwrite.models.Token] */ @@ -1224,7 +1224,7 @@ class Account : Service { /** - * Create Phone Verification (confirmation) + * 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. * diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt index 4ee7c4b..27b7cde 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -18,9 +18,9 @@ class Avatars : Service { public constructor (client: Client) : super(client) { } /** - * Get Browser Icon + * 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](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) 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. @@ -54,7 +54,7 @@ class Avatars : Service { /** - * Get Credit Card Icon + * 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. * @@ -90,7 +90,7 @@ class Avatars : Service { /** - * Get Favicon + * Get favicon * * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote website URL. * @@ -116,9 +116,9 @@ class Avatars : Service { /** - * Get Country Flag + * 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](https://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. @@ -152,7 +152,7 @@ class Avatars : Service { /** - * Get Image from URL + * 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. * @@ -185,7 +185,7 @@ class Avatars : Service { /** - * Get User Initials + * 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. * @@ -221,7 +221,7 @@ class Avatars : Service { /** - * Get QR Code + * 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. * diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index fcc9f74..4329b35 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -16,7 +16,7 @@ class Databases : Service { public constructor (client: Client) : super(client) { } /** - * List Documents + * 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. * @@ -56,7 +56,7 @@ class Databases : Service { } /** - * List Documents + * 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. * @@ -79,15 +79,15 @@ class Databases : Service { ) /** - * Create Document + * 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](https://appwrite.io/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 a custom ID or generate a random ID with `ID.unique()`. 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, only the current user is granted all permissions. [Learn more about permissions](/docs/permissions). + * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ @JvmOverloads @@ -125,15 +125,15 @@ class Databases : Service { } /** - * Create Document + * 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](https://appwrite.io/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 a custom ID or generate a random ID with `ID.unique()`. 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, only the current user is granted all permissions. [Learn more about permissions](/docs/permissions). + * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ @JvmOverloads @@ -154,7 +154,7 @@ class Databases : Service { ) /** - * Get Document + * Get document * * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. * @@ -197,7 +197,7 @@ class Databases : Service { } /** - * Get Document + * Get document * * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. * @@ -223,7 +223,7 @@ class Databases : Service { ) /** - * Update Document + * Update document * * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. * @@ -231,7 +231,7 @@ class Databases : Service { * @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). + * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ @JvmOverloads @@ -269,7 +269,7 @@ class Databases : Service { } /** - * Update Document + * Update document * * Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated. * @@ -277,7 +277,7 @@ class Databases : Service { * @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). + * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ @JvmOverloads @@ -298,7 +298,7 @@ class Databases : Service { ) /** - * Delete Document + * Delete document * * Delete a document by its unique ID. * diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index 6b13e67..257a130 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -16,7 +16,7 @@ class Functions : Service { public constructor (client: Client) : super(client) { } /** - * List Executions + * List executions * * Get a list of all the current user function execution logs. You can use the query params to filter your results. * @@ -56,7 +56,7 @@ class Functions : Service { /** - * Create Execution + * 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. * @@ -105,7 +105,7 @@ class Functions : Service { /** - * Get Execution + * Get execution * * Get a function execution log by its unique ID. * diff --git a/library/src/main/java/io/appwrite/services/Graphql.kt b/library/src/main/java/io/appwrite/services/Graphql.kt index dfe884a..3a925d5 100644 --- a/library/src/main/java/io/appwrite/services/Graphql.kt +++ b/library/src/main/java/io/appwrite/services/Graphql.kt @@ -16,7 +16,7 @@ class Graphql : Service { public constructor (client: Client) : super(client) { } /** - * GraphQL Endpoint + * GraphQL endpoint * * Execute a GraphQL mutation. * @@ -50,7 +50,7 @@ class Graphql : Service { /** - * GraphQL Endpoint + * GraphQL endpoint * * Execute a GraphQL mutation. * diff --git a/library/src/main/java/io/appwrite/services/Locale.kt b/library/src/main/java/io/appwrite/services/Locale.kt index 3c3c418..510f451 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -16,7 +16,7 @@ class Locale : Service { public constructor (client: Client) : super(client) { } /** - * Get User Locale + * 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)) * @@ -76,7 +76,7 @@ class Locale : Service { /** - * List Continents + * List continents * * List of all continents. You can use the locale header to get the data in a supported language. * @@ -106,7 +106,7 @@ class Locale : Service { /** - * List Countries + * List countries * * List of all countries. You can use the locale header to get the data in a supported language. * @@ -136,7 +136,7 @@ class Locale : Service { /** - * List EU Countries + * 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. * @@ -166,7 +166,7 @@ class Locale : Service { /** - * List Countries Phone Codes + * List countries phone codes * * List of all countries phone codes. You can use the locale header to get the data in a supported language. * @@ -196,7 +196,7 @@ class Locale : Service { /** - * List Currencies + * 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. * @@ -226,7 +226,7 @@ class Locale : Service { /** - * List Languages + * List languages * * List of all languages classified by ISO 639-1 including 2-letter code, name in English, and name in the respective language. * diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index 4d61bbb..2b49f56 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -18,11 +18,11 @@ class Storage : Service { public constructor (client: Client) : super(client) { } /** - * List Files + * List files * * 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 bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/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/queries). 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] @@ -58,14 +58,14 @@ class Storage : Service { /** - * Create File + * 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](https://appwrite.io/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 bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). * @param fileId File ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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. Appwrite SDKs provide helpers to handle file input. [Learn about file input](/docs/storage#file-input). - * @param permissions An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](/docs/permissions). + * @param file Binary file. Appwrite SDKs provide helpers to handle file input. [Learn about file input](https://appwrite.io/docs/storage#file-input). + * @param permissions An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.File] */ @JvmOverloads @@ -106,11 +106,11 @@ class Storage : Service { /** - * Get File + * Get file * * 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 bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). * @param fileId File ID. * @return [io.appwrite.models.File] */ @@ -142,14 +142,14 @@ class Storage : Service { /** - * Update File + * Update file * * 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 bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). * @param fileId File unique ID. * @param name Name of the file - * @param permissions An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions). + * @param permissions An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.File] */ @JvmOverloads @@ -189,7 +189,7 @@ class Storage : Service { * * 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 bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). * @param fileId File ID. * @return [Any] */ @@ -217,11 +217,11 @@ class Storage : Service { /** - * Get File for Download + * 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. * - * @param bucketId Storage bucket ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket). + * @param bucketId Storage bucket ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). * @param fileId File ID. * @return [ByteArray] */ @@ -246,11 +246,11 @@ class Storage : Service { /** - * Get File Preview + * 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. * - * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket). + * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). * @param fileId File ID * @param width Resize preview image width, Pass an integer between 0 to 4000. * @param height Resize preview image height, Pass an integer between 0 to 4000. @@ -309,11 +309,11 @@ class Storage : Service { /** - * Get File for View + * 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. * - * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket). + * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). * @param fileId File ID. * @return [ByteArray] */ diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 4d48b33..7f303ab 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -16,7 +16,7 @@ class Teams : Service { public constructor (client: Client) : super(client) { } /** - * List Teams + * 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. * @@ -53,7 +53,7 @@ class Teams : Service { } /** - * List Teams + * 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. * @@ -73,13 +73,13 @@ class Teams : Service { ) /** - * Create Team + * 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. * * @param teamId Team ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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. + * @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](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. * @return [io.appwrite.models.Team] */ @JvmOverloads @@ -113,13 +113,13 @@ class Teams : Service { } /** - * Create Team + * 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. * * @param teamId Team ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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. + * @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](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. * @return [io.appwrite.models.Team] */ @JvmOverloads @@ -136,7 +136,7 @@ class Teams : Service { ) /** - * Get Team + * Get team * * Get a team by its ID. All team members have read access for this resource. * @@ -169,7 +169,7 @@ class Teams : Service { } /** - * Get Team + * Get team * * Get a team by its ID. All team members have read access for this resource. * @@ -185,7 +185,7 @@ class Teams : Service { ) /** - * Update Name + * Update name * * Update the team's name by its unique ID. * @@ -221,7 +221,7 @@ class Teams : Service { } /** - * Update Name + * Update name * * Update the team's name by its unique ID. * @@ -240,7 +240,7 @@ class Teams : Service { ) /** - * Delete Team + * Delete team * * Delete a team using its ID. Only team members with the owner role can delete the team. * @@ -269,7 +269,7 @@ class Teams : Service { /** - * List Team Memberships + * 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. * @@ -309,12 +309,12 @@ class Teams : Service { /** - * Create Team Membership + * Create team membership * - * Invite a new member to join your team. Provide an ID for existing users, or invite unregistered users using an email or phone number. If initiated from a Client SDK, Appwrite will send an email or sms with a link to join the team to the invited user, and an account will be created for them if one doesn't exist. If initiated from a Server SDK, the new member will be added automatically to the team.You only need to provide one of a user ID, email, or phone number. Appwrite will prioritize accepting the user ID > email > phone number if you provide more than one of these parameters.Use the `url` parameter to redirect the user from the invitation email to your app. After 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) Appwrite will accept the only redirect URLs under the domains you have added as a platform on the Appwrite Console. + * Invite a new member to join your team. Provide an ID for existing users, or invite unregistered users using an email or phone number. If initiated from a Client SDK, Appwrite will send an email or sms with a link to join the team to the invited user, and an account will be created for them if one doesn't exist. If initiated from a Server SDK, the new member will be added automatically to the team.You only need to provide one of a user ID, email, or phone number. Appwrite will prioritize accepting the user ID > email > phone number if you provide more than one of these parameters.Use the `url` parameter to redirect the user from the invitation email to your app. After the user is redirected, use the [Update Team Membership Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) 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) Appwrite will accept the only redirect URLs under the domains you have added as a platform on the Appwrite Console. * * @param teamId Team ID. - * @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 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](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. * @param email Email of the new team member. * @param userId ID of the user to be added to a team. * @param phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. @@ -361,7 +361,7 @@ class Teams : Service { /** - * Get Team Membership + * Get team membership * * Get a team member by the membership unique id. All team members have read access for this resource. * @@ -397,9 +397,9 @@ class Teams : Service { /** - * Update Membership + * Update membership * - * 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](https://appwrite.io/docs/permissions). * * @param teamId Team ID. * @param membershipId Membership ID. @@ -436,7 +436,7 @@ class Teams : Service { /** - * Delete Team Membership + * 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. * @@ -468,7 +468,7 @@ class Teams : Service { /** - * Update Team Membership Status + * 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. * @@ -510,9 +510,9 @@ class Teams : Service { /** - * Get Team Preferences + * Get team preferences * - * Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in [user preferences](/docs/client/account#accountGetPrefs). + * Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in [user preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). * * @param teamId Team ID. * @return [io.appwrite.models.Preferences] @@ -543,9 +543,9 @@ class Teams : Service { } /** - * Get Team Preferences + * Get team preferences * - * Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in [user preferences](/docs/client/account#accountGetPrefs). + * Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in [user preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). * * @param teamId Team ID. * @return [io.appwrite.models.Preferences] @@ -559,7 +559,7 @@ class Teams : Service { ) /** - * Update Preferences + * Update preferences * * Update the team's preferences by its unique ID. The object you pass is stored as is and replaces any previous value. The maximum allowed prefs size is 64kB and throws an error if exceeded. * @@ -595,7 +595,7 @@ class Teams : Service { } /** - * Update Preferences + * Update preferences * * Update the team's preferences by its unique ID. The object you pass is stored as is and replaces any previous value. The maximum allowed prefs size is 64kB and throws an error if exceeded. * From 312f026b41b8d4e74688ba82ff3174ee2f26a710 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 16 Nov 2023 17:09:12 +1300 Subject: [PATCH 058/118] Fix between query output --- .../main/java/io/appwrite/enums/Browser.kt | 20 -- .../main/java/io/appwrite/enums/CreditCard.kt | 22 -- .../src/main/java/io/appwrite/enums/Flag.kt | 200 ------------------ .../java/io/appwrite/enums/ImageFormat.kt | 11 - .../java/io/appwrite/enums/ImageGravity.kt | 15 -- .../src/main/java/io/appwrite/enums/Method.kt | 12 -- .../main/java/io/appwrite/enums/Provider.kt | 44 ---- 7 files changed, 324 deletions(-) delete mode 100644 library/src/main/java/io/appwrite/enums/Browser.kt delete mode 100644 library/src/main/java/io/appwrite/enums/CreditCard.kt delete mode 100644 library/src/main/java/io/appwrite/enums/Flag.kt delete mode 100644 library/src/main/java/io/appwrite/enums/ImageFormat.kt delete mode 100644 library/src/main/java/io/appwrite/enums/ImageGravity.kt delete mode 100644 library/src/main/java/io/appwrite/enums/Method.kt delete mode 100644 library/src/main/java/io/appwrite/enums/Provider.kt diff --git a/library/src/main/java/io/appwrite/enums/Browser.kt b/library/src/main/java/io/appwrite/enums/Browser.kt deleted file mode 100644 index 99f598e..0000000 --- a/library/src/main/java/io/appwrite/enums/Browser.kt +++ /dev/null @@ -1,20 +0,0 @@ -package io.appwrite.enums - -enum class Browser(val value: String) { - AVANT_BROWSER("aa"), - ANDROID_WEB_VIEW_BETA("an"), - GOOGLE_CHROME("ch"), - GOOGLE_CHROMEI_OS("ci"), - GOOGLE_CHROME_MOBILE("cm"), - CHROMIUM("cr"), - MOZILLA_FIREFOX("ff"), - SAFARI("sf"), - MOBILE_SAFARI("mf"), - MICROSOFT_EDGE("ps"), - MICROSOFT_EDGEI_OS("oi"), - OPERA_MINI("om"), - OPERA("op"), - OPERA_NEXT("on"); - - override fun toString() = value -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/CreditCard.kt b/library/src/main/java/io/appwrite/enums/CreditCard.kt deleted file mode 100644 index e99519b..0000000 --- a/library/src/main/java/io/appwrite/enums/CreditCard.kt +++ /dev/null @@ -1,22 +0,0 @@ -package io.appwrite.enums - -enum class CreditCard(val value: String) { - AMERICAN_EXPRESS("amex"), - ARGENCARD("argencard"), - CABAL("cabal"), - CONSOSUD("censosud"), - DINERS_CLUB("diners"), - DISCOVER("discover"), - ELO("elo"), - HIPERCARD("hipercard"), - JCB("jcb"), - MASTERCARD("mastercard"), - NARANJA("naranja"), - TARJETA_SHOPPING("targeta-shopping"), - UNION_CHINA_PAY("union-china-pay"), - VISA("visa"), - MIR("mir"), - MAESTRO("maestro"); - - override fun toString() = value -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/Flag.kt b/library/src/main/java/io/appwrite/enums/Flag.kt deleted file mode 100644 index 4fcdd88..0000000 --- a/library/src/main/java/io/appwrite/enums/Flag.kt +++ /dev/null @@ -1,200 +0,0 @@ -package io.appwrite.enums - -enum class Flag(val value: String) { - AFGHANISTAN("af"), - ANGOLA("ao"), - ALBANIA("al"), - ANDORRA("ad"), - UNITED_ARAB_EMIRATES("ae"), - ARGENTINA("ar"), - ARMENIA("am"), - ANTIGUAAND_BARBUDA("ag"), - AUSTRALIA("au"), - AUSTRIA("at"), - AZERBAIJAN("az"), - BURUNDI("bi"), - BELGIUM("be"), - BENIN("bj"), - BURKINA_FASO("bf"), - BANGLADESH("bd"), - BULGARIA("bg"), - BAHRAIN("bh"), - BAHAMAS("bs"), - BOSNIAAND_HERZEGOVINA("ba"), - BELARUS("by"), - BELIZE("bz"), - BOLIVIA("bo"), - BRAZIL("br"), - BARBADOS("bb"), - BRUNEI_DARUSSALAM("bn"), - BHUTAN("bt"), - BOTSWANA("bw"), - CENTRAL_AFRICAN_REPUBLIC("cf"), - CANADA("ca"), - SWITZERLAND("ch"), - CHILE("cl"), - CHINA("cn"), - CTED_IVOIRE("ci"), - CAMEROON("cm"), - DEMOCRATIC_REPUBLICOFTHE_CONGO("cd"), - REPUBLICOFTHE_CONGO("cg"), - COLOMBIA("co"), - COMOROS("km"), - CAPE_VERDE("cv"), - COSTA_RICA("cr"), - CUBA("cu"), - CYPRUS("cy"), - CZECH_REPUBLIC("cz"), - GERMANY("de"), - DJIBOUTI("dj"), - DOMINICA("dm"), - DENMARK("dk"), - DOMINICAN_REPUBLIC("do"), - ALGERIA("dz"), - ECUADOR("ec"), - EGYPT("eg"), - ERITREA("er"), - SPAIN("es"), - ESTONIA("ee"), - ETHIOPIA("et"), - FINLAND("fi"), - FIJI("fj"), - FRANCE("fr"), - MICRONESIA_FEDERATED_STATESOF("fm"), - GABON("ga"), - UNITED_KINGDOM("gb"), - GEORGIA("ge"), - GHANA("gh"), - GUINEA("gn"), - GAMBIA("gm"), - GUINEA_BISSAU("gw"), - EQUATORIAL_GUINEA("gq"), - GREECE("gr"), - GRENADA("gd"), - GUATEMALA("gt"), - GUYANA("gy"), - HONDURAS("hn"), - CROATIA("hr"), - HAITI("ht"), - HUNGARY("hu"), - INDONESIA("id"), - INDIA("in"), - IRELAND("ie"), - IRAN_ISLAMIC_REPUBLICOF("ir"), - IRAQ("iq"), - ICELAND("is"), - ISRAEL("il"), - ITALY("it"), - JAMAICA("jm"), - JORDAN("jo"), - JAPAN("jp"), - KAZAKHSTAN("kz"), - KENYA("ke"), - KYRGYZSTAN("kg"), - CAMBODIA("kh"), - KIRIBATI("ki"), - SAINT_KITTSAND_NEVIS("kn"), - SOUTH_KOREA("kr"), - KUWAIT("kw"), - LAO_PEOPLES_DEMOCRATIC_REPUBLIC("la"), - LEBANON("lb"), - LIBERIA("lr"), - LIBYA("ly"), - SAINT_LUCIA("lc"), - LIECHTENSTEIN("li"), - SRI_LANKA("lk"), - LESOTHO("ls"), - LITHUANIA("lt"), - LUXEMBOURG("lu"), - LATVIA("lv"), - MOROCCO("ma"), - MONACO("mc"), - MOLDOVA("md"), - MADAGASCAR("mg"), - MALDIVES("mv"), - MEXICO("mx"), - MARSHALL_ISLANDS("mh"), - NORTH_MACEDONIA("mk"), - MALI("ml"), - MALTA("mt"), - MYANMAR("mm"), - MONTENEGRO("me"), - MONGOLIA("mn"), - MOZAMBIQUE("mz"), - MAURITANIA("mr"), - MAURITIUS("mu"), - MALAWI("mw"), - MALAYSIA("my"), - NAMIBIA("na"), - NIGER("ne"), - NIGERIA("ng"), - NICARAGUA("ni"), - NETHERLANDS("nl"), - NORWAY("no"), - NEPAL("np"), - NAURU("nr"), - NEW_ZEALAND("nz"), - OMAN("om"), - PAKISTAN("pk"), - PANAMA("pa"), - PERU("pe"), - PHILIPPINES("ph"), - PALAU("pw"), - PAPUA_NEW_GUINEA("pg"), - POLAND("pl"), - NORTH_KOREA("kp"), - PORTUGAL("pt"), - PARAGUAY("py"), - QATAR("qa"), - ROMANIA("ro"), - RUSSIA("ru"), - RWANDA("rw"), - SAUDI_ARABIA("sa"), - SUDAN("sd"), - SENEGAL("sn"), - SINGAPORE("sg"), - SOLOMON_ISLANDS("sb"), - SIERRA_LEONE("sl"), - EL_SALVADOR("sv"), - SAN_MARINO("sm"), - SOMALIA("so"), - SERBIA("rs"), - SOUTH_SUDAN("ss"), - SAO_TOMEAND_PRINCIPE("st"), - SURINAME("sr"), - SLOVAKIA("sk"), - SLOVENIA("si"), - SWEDEN("se"), - ESWATINI("sz"), - SEYCHELLES("sc"), - SYRIA("sy"), - CHAD("td"), - TOGO("tg"), - THAILAND("th"), - TAJIKISTAN("tj"), - TURKMENISTAN("tm"), - TIMOR_LESTE("tl"), - TONGA("to"), - TRINIDADAND_TOBAGO("tt"), - TUNISIA("tn"), - TURKEY("tr"), - TUVALU("tv"), - TANZANIA("tz"), - UGANDA("ug"), - UKRAINE("ua"), - URUGUAY("uy"), - UNITED_STATES("us"), - UZBEKISTAN("uz"), - VATICAN_CITY("va"), - SAINT_VINCENTANDTHE_GRENADINES("vc"), - VENEZUELA("ve"), - VIETNAM("vn"), - VANUATU("vu"), - SAMOA("ws"), - YEMEN("ye"), - SOUTH_AFRICA("za"), - ZAMBIA("zm"), - ZIMBABWE("zw"); - - override fun toString() = value -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/ImageFormat.kt b/library/src/main/java/io/appwrite/enums/ImageFormat.kt deleted file mode 100644 index 6a4c422..0000000 --- a/library/src/main/java/io/appwrite/enums/ImageFormat.kt +++ /dev/null @@ -1,11 +0,0 @@ -package io.appwrite.enums - -enum class ImageFormat(val value: String) { - JPG("jpg"), - JPEG("jpeg"), - GIF("gif"), - PNG("png"), - WEBP("webp"); - - override fun toString() = value -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/ImageGravity.kt b/library/src/main/java/io/appwrite/enums/ImageGravity.kt deleted file mode 100644 index a8fa441..0000000 --- a/library/src/main/java/io/appwrite/enums/ImageGravity.kt +++ /dev/null @@ -1,15 +0,0 @@ -package io.appwrite.enums - -enum class ImageGravity(val value: String) { - CENTER("center"), - TOPLEFT("top-left"), - TOP("top"), - TOPRIGHT("top-right"), - LEFT("left"), - RIGHT("right"), - BOTTOMLEFT("bottom-left"), - BOTTOM("bottom"), - BOTTOMRIGHT("bottom-right"); - - override fun toString() = value -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/Method.kt b/library/src/main/java/io/appwrite/enums/Method.kt deleted file mode 100644 index a483270..0000000 --- a/library/src/main/java/io/appwrite/enums/Method.kt +++ /dev/null @@ -1,12 +0,0 @@ -package io.appwrite.enums - -enum class Method(val value: String) { - GET("GET"), - POST("POST"), - PUT("PUT"), - PATCH("PATCH"), - DELETE("DELETE"), - OPTIONS("OPTIONS"); - - override fun toString() = value -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/Provider.kt b/library/src/main/java/io/appwrite/enums/Provider.kt deleted file mode 100644 index 472f0d4..0000000 --- a/library/src/main/java/io/appwrite/enums/Provider.kt +++ /dev/null @@ -1,44 +0,0 @@ -package io.appwrite.enums - -enum class Provider(val value: String) { - AMAZON("amazon"), - APPLE("apple"), - AUTH0("auth0"), - AUTHENTIK("authentik"), - AUTODESK("autodesk"), - BITBUCKET("bitbucket"), - BITLY("bitly"), - BOX("box"), - DAILYMOTION("dailymotion"), - DISCORD("discord"), - DISQUS("disqus"), - DROPBOX("dropbox"), - ETSY("etsy"), - FACEBOOK("facebook"), - GITHUB("github"), - GITLAB("gitlab"), - GOOGLE("google"), - LINKEDIN("linkedin"), - MICROSOFT("microsoft"), - NOTION("notion"), - OIDC("oidc"), - OKTA("okta"), - PAYPAL("paypal"), - PAYPAL_SANDBOX("paypalSandbox"), - PODIO("podio"), - SALESFORCE("salesforce"), - SLACK("slack"), - SPOTIFY("spotify"), - STRIPE("stripe"), - TRADESHIFT("tradeshift"), - TRADESHIFT_BOX("tradeshiftBox"), - TWITCH("twitch"), - WORDPRESS("wordpress"), - YAHOO("yahoo"), - YAMMER("yammer"), - YANDEX("yandex"), - ZOOM("zoom"), - MOCK("mock"); - - override fun toString() = value -} \ No newline at end of file From 2766e15eabe58532e4529f9231ebbb99bdb1998f Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 5 Feb 2024 23:39:43 +1300 Subject: [PATCH 059/118] Release candidate for 1.5.x --- LICENSE.md | 2 +- README.md | 8 +- build.gradle | 11 +- .../java/account/add-authenticator.md | 22 + .../java/account/create-anonymous-session.md | 2 +- .../examples/java/account/create-challenge.md | 22 + .../account/create-email-password-session.md | 22 + ...u-r-l-session.md => create-email-token.md} | 4 +- docs/examples/java/account/create-j-w-t.md | 2 +- ...session.md => create-magic-u-r-l-token.md} | 6 +- .../java/account/create-o-auth2session.md | 5 +- ...phone-session.md => create-phone-token.md} | 6 +- .../java/account/create-phone-verification.md | 2 +- .../java/account/create-push-target.md | 22 + docs/examples/java/account/create-recovery.md | 4 +- ...ate-phone-session.md => create-session.md} | 6 +- .../java/account/create-verification.md | 4 +- docs/examples/java/account/create.md | 2 +- .../java/account/delete-authenticator.md | 23 + docs/examples/java/account/delete-identity.md | 4 +- .../java/account/delete-push-target.md | 21 + docs/examples/java/account/delete-session.md | 4 +- docs/examples/java/account/delete-sessions.md | 2 +- docs/examples/java/account/get-prefs.md | 2 +- docs/examples/java/account/get-session.md | 4 +- docs/examples/java/account/get.md | 2 +- docs/examples/java/account/list-factors.md | 18 + docs/examples/java/account/list-identities.md | 2 +- docs/examples/java/account/list-logs.md | 2 +- docs/examples/java/account/list-sessions.md | 2 +- .../examples/java/account/update-challenge.md | 22 + docs/examples/java/account/update-email.md | 4 +- docs/examples/java/account/update-m-f-a.md | 21 + .../account/update-magic-u-r-l-session.md | 4 +- docs/examples/java/account/update-name.md | 4 +- docs/examples/java/account/update-password.md | 2 +- .../java/account/update-phone-verification.md | 4 +- docs/examples/java/account/update-phone.md | 4 +- docs/examples/java/account/update-prefs.md | 4 +- .../java/account/update-push-target.md | 22 + docs/examples/java/account/update-recovery.md | 5 +- docs/examples/java/account/update-session.md | 4 +- docs/examples/java/account/update-status.md | 2 +- .../java/account/update-verification.md | 4 +- .../java/account/verify-authenticator.md | 23 + docs/examples/java/avatars/get-browser.md | 5 +- docs/examples/java/avatars/get-credit-card.md | 5 +- docs/examples/java/avatars/get-favicon.md | 4 +- docs/examples/java/avatars/get-flag.md | 5 +- docs/examples/java/avatars/get-image.md | 2 +- docs/examples/java/avatars/get-initials.md | 2 +- docs/examples/java/avatars/get-q-r.md | 2 +- .../java/databases/create-document.md | 2 +- .../java/databases/delete-document.md | 4 +- docs/examples/java/databases/get-document.md | 2 +- .../examples/java/databases/list-documents.md | 2 +- .../java/databases/update-document.md | 2 +- .../java/functions/create-execution.md | 2 +- docs/examples/java/functions/get-execution.md | 4 +- .../java/functions/list-executions.md | 2 +- docs/examples/java/graphql/mutation.md | 4 +- docs/examples/java/graphql/query.md | 4 +- docs/examples/java/locale/get.md | 2 +- docs/examples/java/locale/list-codes.md | 2 +- docs/examples/java/locale/list-continents.md | 2 +- .../java/locale/list-countries-e-u.md | 2 +- .../java/locale/list-countries-phones.md | 2 +- docs/examples/java/locale/list-countries.md | 2 +- docs/examples/java/locale/list-currencies.md | 2 +- docs/examples/java/locale/list-languages.md | 2 +- .../java/messaging/create-subscriber.md | 23 + .../java/messaging/delete-subscriber.md | 22 + docs/examples/java/storage/create-file.md | 2 +- docs/examples/java/storage/delete-file.md | 4 +- .../java/storage/get-file-download.md | 4 +- .../examples/java/storage/get-file-preview.md | 2 +- docs/examples/java/storage/get-file-view.md | 4 +- docs/examples/java/storage/get-file.md | 4 +- docs/examples/java/storage/list-files.md | 2 +- docs/examples/java/storage/update-file.md | 2 +- docs/examples/java/teams/create-membership.md | 2 +- docs/examples/java/teams/create.md | 2 +- docs/examples/java/teams/delete-membership.md | 4 +- docs/examples/java/teams/delete.md | 4 +- docs/examples/java/teams/get-membership.md | 4 +- docs/examples/java/teams/get-prefs.md | 4 +- docs/examples/java/teams/get.md | 4 +- docs/examples/java/teams/list-memberships.md | 2 +- docs/examples/java/teams/list.md | 2 +- .../java/teams/update-membership-status.md | 4 +- docs/examples/java/teams/update-membership.md | 4 +- docs/examples/java/teams/update-name.md | 4 +- docs/examples/java/teams/update-prefs.md | 4 +- .../java/users/delete-authenticator.md | 24 + docs/examples/java/users/list-providers.md | 21 + .../kotlin/account/add-authenticator.md | 14 + .../account/create-anonymous-session.md | 1 + .../kotlin/account/create-challenge.md | 14 + .../account/create-email-password-session.md | 14 + ...u-r-l-session.md => create-email-token.md} | 5 +- docs/examples/kotlin/account/create-j-w-t.md | 1 + ...session.md => create-magic-u-r-l-token.md} | 7 +- .../kotlin/account/create-o-auth2session.md | 6 +- .../kotlin/account/create-phone-token.md | 14 + .../account/create-phone-verification.md | 1 + .../kotlin/account/create-push-target.md | 14 + .../kotlin/account/create-recovery.md | 5 +- .../examples/kotlin/account/create-session.md | 14 + .../kotlin/account/create-verification.md | 5 +- docs/examples/kotlin/account/create.md | 3 +- .../kotlin/account/delete-authenticator.md | 15 + .../kotlin/account/delete-identity.md | 5 +- .../kotlin/account/delete-push-target.md | 13 + .../examples/kotlin/account/delete-session.md | 5 +- .../kotlin/account/delete-sessions.md | 1 + docs/examples/kotlin/account/get-prefs.md | 1 + docs/examples/kotlin/account/get-session.md | 5 +- docs/examples/kotlin/account/get.md | 1 + ...pdate-phone-session.md => list-factors.md} | 6 +- .../kotlin/account/list-identities.md | 3 +- docs/examples/kotlin/account/list-logs.md | 3 +- docs/examples/kotlin/account/list-sessions.md | 1 + .../kotlin/account/update-challenge.md | 14 + docs/examples/kotlin/account/update-email.md | 5 +- ...reate-phone-session.md => update-m-f-a.md} | 8 +- .../account/update-magic-u-r-l-session.md | 5 +- docs/examples/kotlin/account/update-name.md | 5 +- .../kotlin/account/update-password.md | 3 +- .../account/update-phone-verification.md | 5 +- docs/examples/kotlin/account/update-phone.md | 5 +- docs/examples/kotlin/account/update-prefs.md | 5 +- .../kotlin/account/update-push-target.md | 14 + .../kotlin/account/update-recovery.md | 6 +- .../examples/kotlin/account/update-session.md | 5 +- docs/examples/kotlin/account/update-status.md | 1 + .../kotlin/account/update-verification.md | 5 +- .../kotlin/account/verify-authenticator.md | 15 + docs/examples/kotlin/avatars/get-browser.md | 8 +- .../kotlin/avatars/get-credit-card.md | 8 +- docs/examples/kotlin/avatars/get-favicon.md | 7 +- docs/examples/kotlin/avatars/get-flag.md | 8 +- docs/examples/kotlin/avatars/get-image.md | 5 +- docs/examples/kotlin/avatars/get-initials.md | 5 +- docs/examples/kotlin/avatars/get-q-r.md | 5 +- .../kotlin/databases/create-document.md | 3 +- .../kotlin/databases/delete-document.md | 5 +- .../examples/kotlin/databases/get-document.md | 3 +- .../kotlin/databases/list-documents.md | 3 +- .../kotlin/databases/update-document.md | 3 +- .../kotlin/functions/create-execution.md | 3 +- .../kotlin/functions/get-execution.md | 5 +- .../kotlin/functions/list-executions.md | 3 +- docs/examples/kotlin/graphql/mutation.md | 5 +- docs/examples/kotlin/graphql/query.md | 5 +- docs/examples/kotlin/locale/get.md | 1 + docs/examples/kotlin/locale/list-codes.md | 1 + .../examples/kotlin/locale/list-continents.md | 1 + .../kotlin/locale/list-countries-e-u.md | 1 + .../kotlin/locale/list-countries-phones.md | 1 + docs/examples/kotlin/locale/list-countries.md | 1 + .../examples/kotlin/locale/list-currencies.md | 1 + docs/examples/kotlin/locale/list-languages.md | 1 + .../kotlin/messaging/create-subscriber.md | 15 + .../kotlin/messaging/delete-subscriber.md | 14 + docs/examples/kotlin/storage/create-file.md | 3 +- docs/examples/kotlin/storage/delete-file.md | 5 +- .../kotlin/storage/get-file-download.md | 7 +- .../kotlin/storage/get-file-preview.md | 5 +- docs/examples/kotlin/storage/get-file-view.md | 7 +- docs/examples/kotlin/storage/get-file.md | 5 +- docs/examples/kotlin/storage/list-files.md | 3 +- docs/examples/kotlin/storage/update-file.md | 3 +- .../kotlin/teams/create-membership.md | 3 +- docs/examples/kotlin/teams/create.md | 3 +- .../kotlin/teams/delete-membership.md | 5 +- docs/examples/kotlin/teams/delete.md | 5 +- docs/examples/kotlin/teams/get-membership.md | 5 +- docs/examples/kotlin/teams/get-prefs.md | 5 +- docs/examples/kotlin/teams/get.md | 5 +- .../examples/kotlin/teams/list-memberships.md | 3 +- docs/examples/kotlin/teams/list.md | 3 +- .../kotlin/teams/update-membership-status.md | 5 +- .../kotlin/teams/update-membership.md | 5 +- docs/examples/kotlin/teams/update-name.md | 5 +- docs/examples/kotlin/teams/update-prefs.md | 5 +- .../kotlin/users/delete-authenticator.md | 16 + docs/examples/kotlin/users/list-providers.md | 13 + example-java/.gitignore | 1 - example-java/build.gradle | 39 - example-java/src/main/AndroidManifest.xml | 21 - .../appwrite/example_java/MainActivity.java | 34 - .../res/drawable/ic_launcher_background.xml | 170 ----- .../res/drawable/ic_launcher_foreground.xml | 30 - .../src/main/res/layout/activity_main.xml | 18 - .../res/mipmap-anydpi-v26/ic_launcher.xml | 5 - .../mipmap-anydpi-v26/ic_launcher_round.xml | 5 - example-java/src/main/res/values/colors.xml | 10 - example-java/src/main/res/values/strings.xml | 3 - example-java/src/main/res/values/themes.xml | 16 - example/build.gradle | 31 +- example/src/main/AndroidManifest.xml | 13 +- .../android/ui/accounts/AccountsFragment.kt | 16 +- .../android/ui/accounts/AccountsViewModel.kt | 17 +- .../java/io/appwrite/android/utils/Client.kt | 11 +- .../src/main/res/layout/fragment_account.xml | 1 + gradle/wrapper/gradle-wrapper.properties | 2 +- library/build.gradle | 48 +- library/src/main/AndroidManifest.xml | 7 +- library/src/main/java/io/appwrite/Client.kt | 84 ++- .../java/io/appwrite/NotificationHandler.kt | 410 +++++++++++ library/src/main/java/io/appwrite/Query.kt | 79 +- .../appwrite/cookies/ListenableCookieJar.kt | 119 +++ .../cookies/stores/InMemoryCookieStore.kt | 13 +- .../stores/SharedPreferencesCookieStore.kt | 10 +- .../io/appwrite/enums/AuthenticatorFactor.kt | 7 + .../appwrite/enums/AuthenticatorProvider.kt | 7 + .../main/java/io/appwrite/enums/Browser.kt | 20 + .../main/java/io/appwrite/enums/CreditCard.kt | 22 + .../java/io/appwrite/enums/ExecutionMethod.kt | 12 + .../src/main/java/io/appwrite/enums/Flag.kt | 200 +++++ .../java/io/appwrite/enums/ImageFormat.kt | 11 + .../java/io/appwrite/enums/ImageGravity.kt | 15 + .../java/io/appwrite/enums/OAuthProvider.kt | 45 ++ .../appwrite/extensions/ActivityExtensions.kt | 46 ++ .../extensions/MessagingExtensions.kt | 14 + .../io/appwrite/extensions/TypeExtensions.kt | 1 + .../java/io/appwrite/models/Membership.kt | 8 + .../java/io/appwrite/models/MfaChallenge.kt | 54 ++ .../java/io/appwrite/models/MfaProvider.kt | 46 ++ .../java/io/appwrite/models/MfaProviders.kt | 46 ++ .../java/io/appwrite/models/Notification.kt | 12 + .../main/java/io/appwrite/models/Session.kt | 16 + .../java/io/appwrite/models/Subscriber.kt | 94 +++ .../main/java/io/appwrite/models/Target.kt | 86 +++ .../src/main/java/io/appwrite/models/Token.kt | 8 + .../src/main/java/io/appwrite/models/User.kt | 30 + .../main/java/io/appwrite/services/Account.kt | 688 +++++++++++++++--- .../main/java/io/appwrite/services/Avatars.kt | 17 +- .../java/io/appwrite/services/Databases.kt | 13 +- .../java/io/appwrite/services/Functions.kt | 10 +- .../main/java/io/appwrite/services/Graphql.kt | 5 +- .../main/java/io/appwrite/services/Locale.kt | 13 +- .../java/io/appwrite/services/Messaging.kt | 89 +++ .../java/io/appwrite/services/Realtime.kt | 2 +- .../main/java/io/appwrite/services/Storage.kt | 13 +- .../main/java/io/appwrite/services/Teams.kt | 20 +- .../main/java/io/appwrite/services/Users.kt | 113 +++ scripts/publish-module.gradle | 3 +- settings.gradle | 3 +- 249 files changed, 3232 insertions(+), 887 deletions(-) create mode 100644 docs/examples/java/account/add-authenticator.md create mode 100644 docs/examples/java/account/create-challenge.md create mode 100644 docs/examples/java/account/create-email-password-session.md rename docs/examples/java/account/{create-magic-u-r-l-session.md => create-email-token.md} (94%) rename docs/examples/java/account/{create-email-session.md => create-magic-u-r-l-token.md} (91%) rename docs/examples/java/account/{create-phone-session.md => create-phone-token.md} (91%) create mode 100644 docs/examples/java/account/create-push-target.md rename docs/examples/java/account/{update-phone-session.md => create-session.md} (92%) create mode 100644 docs/examples/java/account/delete-authenticator.md create mode 100644 docs/examples/java/account/delete-push-target.md create mode 100644 docs/examples/java/account/list-factors.md create mode 100644 docs/examples/java/account/update-challenge.md create mode 100644 docs/examples/java/account/update-m-f-a.md create mode 100644 docs/examples/java/account/update-push-target.md create mode 100644 docs/examples/java/account/verify-authenticator.md create mode 100644 docs/examples/java/messaging/create-subscriber.md create mode 100644 docs/examples/java/messaging/delete-subscriber.md create mode 100644 docs/examples/java/users/delete-authenticator.md create mode 100644 docs/examples/java/users/list-providers.md create mode 100644 docs/examples/kotlin/account/add-authenticator.md create mode 100644 docs/examples/kotlin/account/create-challenge.md create mode 100644 docs/examples/kotlin/account/create-email-password-session.md rename docs/examples/kotlin/account/{create-magic-u-r-l-session.md => create-email-token.md} (77%) rename docs/examples/kotlin/account/{create-email-session.md => create-magic-u-r-l-token.md} (70%) create mode 100644 docs/examples/kotlin/account/create-phone-token.md create mode 100644 docs/examples/kotlin/account/create-push-target.md create mode 100644 docs/examples/kotlin/account/create-session.md create mode 100644 docs/examples/kotlin/account/delete-authenticator.md create mode 100644 docs/examples/kotlin/account/delete-push-target.md rename docs/examples/kotlin/account/{update-phone-session.md => list-factors.md} (72%) create mode 100644 docs/examples/kotlin/account/update-challenge.md rename docs/examples/kotlin/account/{create-phone-session.md => update-m-f-a.md} (71%) create mode 100644 docs/examples/kotlin/account/update-push-target.md create mode 100644 docs/examples/kotlin/account/verify-authenticator.md create mode 100644 docs/examples/kotlin/messaging/create-subscriber.md create mode 100644 docs/examples/kotlin/messaging/delete-subscriber.md create mode 100644 docs/examples/kotlin/users/delete-authenticator.md create mode 100644 docs/examples/kotlin/users/list-providers.md delete mode 100644 example-java/.gitignore delete mode 100644 example-java/build.gradle delete mode 100644 example-java/src/main/AndroidManifest.xml delete mode 100644 example-java/src/main/java/io/appwrite/example_java/MainActivity.java delete mode 100644 example-java/src/main/res/drawable/ic_launcher_background.xml delete mode 100644 example-java/src/main/res/drawable/ic_launcher_foreground.xml delete mode 100644 example-java/src/main/res/layout/activity_main.xml delete mode 100644 example-java/src/main/res/mipmap-anydpi-v26/ic_launcher.xml delete mode 100644 example-java/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml delete mode 100644 example-java/src/main/res/values/colors.xml delete mode 100644 example-java/src/main/res/values/strings.xml delete mode 100644 example-java/src/main/res/values/themes.xml create mode 100644 library/src/main/java/io/appwrite/NotificationHandler.kt create mode 100644 library/src/main/java/io/appwrite/cookies/ListenableCookieJar.kt create mode 100644 library/src/main/java/io/appwrite/enums/AuthenticatorFactor.kt create mode 100644 library/src/main/java/io/appwrite/enums/AuthenticatorProvider.kt create mode 100644 library/src/main/java/io/appwrite/enums/Browser.kt create mode 100644 library/src/main/java/io/appwrite/enums/CreditCard.kt create mode 100644 library/src/main/java/io/appwrite/enums/ExecutionMethod.kt create mode 100644 library/src/main/java/io/appwrite/enums/Flag.kt create mode 100644 library/src/main/java/io/appwrite/enums/ImageFormat.kt create mode 100644 library/src/main/java/io/appwrite/enums/ImageGravity.kt create mode 100644 library/src/main/java/io/appwrite/enums/OAuthProvider.kt create mode 100644 library/src/main/java/io/appwrite/extensions/ActivityExtensions.kt create mode 100644 library/src/main/java/io/appwrite/extensions/MessagingExtensions.kt create mode 100644 library/src/main/java/io/appwrite/models/MfaChallenge.kt create mode 100644 library/src/main/java/io/appwrite/models/MfaProvider.kt create mode 100644 library/src/main/java/io/appwrite/models/MfaProviders.kt create mode 100644 library/src/main/java/io/appwrite/models/Notification.kt create mode 100644 library/src/main/java/io/appwrite/models/Subscriber.kt create mode 100644 library/src/main/java/io/appwrite/models/Target.kt create mode 100644 library/src/main/java/io/appwrite/services/Messaging.kt create mode 100644 library/src/main/java/io/appwrite/services/Users.kt diff --git a/LICENSE.md b/LICENSE.md index 47cfdfb..5479bb8 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2023 Appwrite (https://appwrite.io) and individual contributors. +Copyright (c) 2024 Appwrite (https://appwrite.io) and individual contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/README.md b/README.md index e5d5922..054a54c 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.4.12-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.4.13-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 1.4.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).** +**This SDK is compatible with Appwrite server version 1.5.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-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:4.0.1") +implementation("io.appwrite:sdk-for-android:5.0.0-rc.1") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 4.0.1 + 5.0.0-rc.1 ``` diff --git a/build.gradle b/build.gradle index f2080e6..0b0c86c 100644 --- a/build.gradle +++ b/build.gradle @@ -2,20 +2,19 @@ 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.8.0" + ext.kotlin_version = "1.9.10" + version System.getenv("SDK_VERSION") + repositories { maven { url "https://plugins.gradle.org/m2/" } google() mavenCentral() } dependencies { - classpath "com.android.tools.build:gradle:4.2.2" + classpath "com.android.tools.build:gradle:8.2.2" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath 'io.github.gradle-nexus:publish-plugin:1.1.0' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files + classpath "io.github.gradle-nexus:publish-plugin:1.3.0" } } diff --git a/docs/examples/java/account/add-authenticator.md b/docs/examples/java/account/add-authenticator.md new file mode 100644 index 0000000..35935a4 --- /dev/null +++ b/docs/examples/java/account/add-authenticator.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; +import io.appwrite.enums.AuthenticatorFactor; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.addAuthenticator( + AuthenticatorFactor.TOTP, + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file diff --git a/docs/examples/java/account/create-anonymous-session.md b/docs/examples/java/account/create-anonymous-session.md index 59c7630..46ae275 100644 --- a/docs/examples/java/account/create-anonymous-session.md +++ b/docs/examples/java/account/create-anonymous-session.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.createAnonymousSession(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/account/create-challenge.md b/docs/examples/java/account/create-challenge.md new file mode 100644 index 0000000..5080f10 --- /dev/null +++ b/docs/examples/java/account/create-challenge.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; +import io.appwrite.enums.AuthenticatorProvider; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.createChallenge( + AuthenticatorProvider.TOTP, + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file diff --git a/docs/examples/java/account/create-email-password-session.md b/docs/examples/java/account/create-email-password-session.md new file mode 100644 index 0000000..e3cd353 --- /dev/null +++ b/docs/examples/java/account/create-email-password-session.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.createEmailPasswordSession( + "email@example.com", + "password", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file diff --git a/docs/examples/java/account/create-magic-u-r-l-session.md b/docs/examples/java/account/create-email-token.md similarity index 94% rename from docs/examples/java/account/create-magic-u-r-l-session.md rename to docs/examples/java/account/create-email-token.md index 0ed43dc..f032eb6 100644 --- a/docs/examples/java/account/create-magic-u-r-l-session.md +++ b/docs/examples/java/account/create-email-token.md @@ -8,7 +8,7 @@ Client client = new Client(context) Account account = new Account(client); -account.createMagicURLSession( +account.createEmailToken( "[USER_ID]", "email@example.com", new CoroutineCallback<>((result, error) -> { @@ -19,4 +19,4 @@ account.createMagicURLSession( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/create-j-w-t.md b/docs/examples/java/account/create-j-w-t.md index c312386..13e6e49 100644 --- a/docs/examples/java/account/create-j-w-t.md +++ b/docs/examples/java/account/create-j-w-t.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.createJWT(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/account/create-email-session.md b/docs/examples/java/account/create-magic-u-r-l-token.md similarity index 91% rename from docs/examples/java/account/create-email-session.md rename to docs/examples/java/account/create-magic-u-r-l-token.md index e3e6fdd..48a8b9b 100644 --- a/docs/examples/java/account/create-email-session.md +++ b/docs/examples/java/account/create-magic-u-r-l-token.md @@ -8,9 +8,9 @@ Client client = new Client(context) Account account = new Account(client); -account.createEmailSession( +account.createMagicURLToken( + "[USER_ID]", "email@example.com", - "password" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.createEmailSession( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/create-o-auth2session.md b/docs/examples/java/account/create-o-auth2session.md index cb9386a..1389673 100644 --- a/docs/examples/java/account/create-o-auth2session.md +++ b/docs/examples/java/account/create-o-auth2session.md @@ -1,6 +1,7 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; +import io.appwrite.enums.OAuthProvider; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -9,7 +10,7 @@ Client client = new Client(context) Account account = new Account(client); account.createOAuth2Session( - "amazon", + OAuthProvider.AMAZON, new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +19,4 @@ account.createOAuth2Session( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/create-phone-session.md b/docs/examples/java/account/create-phone-token.md similarity index 91% rename from docs/examples/java/account/create-phone-session.md rename to docs/examples/java/account/create-phone-token.md index df5bc86..a839e81 100644 --- a/docs/examples/java/account/create-phone-session.md +++ b/docs/examples/java/account/create-phone-token.md @@ -8,9 +8,9 @@ Client client = new Client(context) Account account = new Account(client); -account.createPhoneSession( +account.createPhoneToken( "[USER_ID]", - "+12065550100" + "+12065550100", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.createPhoneSession( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/create-phone-verification.md b/docs/examples/java/account/create-phone-verification.md index 1545d0f..ef14ce8 100644 --- a/docs/examples/java/account/create-phone-verification.md +++ b/docs/examples/java/account/create-phone-verification.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.createPhoneVerification(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/account/create-push-target.md b/docs/examples/java/account/create-push-target.md new file mode 100644 index 0000000..18a5e76 --- /dev/null +++ b/docs/examples/java/account/create-push-target.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.createPushTarget( + "[TARGET_ID]", + "[IDENTIFIER]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file diff --git a/docs/examples/java/account/create-recovery.md b/docs/examples/java/account/create-recovery.md index 5e8584f..f167af2 100644 --- a/docs/examples/java/account/create-recovery.md +++ b/docs/examples/java/account/create-recovery.md @@ -10,7 +10,7 @@ Account account = new Account(client); account.createRecovery( "email@example.com", - "https://example.com" + "https://example.com", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.createRecovery( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/update-phone-session.md b/docs/examples/java/account/create-session.md similarity index 92% rename from docs/examples/java/account/update-phone-session.md rename to docs/examples/java/account/create-session.md index 589e4ff..d853209 100644 --- a/docs/examples/java/account/update-phone-session.md +++ b/docs/examples/java/account/create-session.md @@ -8,9 +8,9 @@ Client client = new Client(context) Account account = new Account(client); -account.updatePhoneSession( +account.createSession( "[USER_ID]", - "[SECRET]" + "[SECRET]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.updatePhoneSession( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/create-verification.md b/docs/examples/java/account/create-verification.md index fcea98f..eb7a537 100644 --- a/docs/examples/java/account/create-verification.md +++ b/docs/examples/java/account/create-verification.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.createVerification( - "https://example.com" + "https://example.com", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ account.createVerification( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/create.md b/docs/examples/java/account/create.md index e08731f..a16d2c7 100644 --- a/docs/examples/java/account/create.md +++ b/docs/examples/java/account/create.md @@ -20,4 +20,4 @@ account.create( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/delete-authenticator.md b/docs/examples/java/account/delete-authenticator.md new file mode 100644 index 0000000..d7e4196 --- /dev/null +++ b/docs/examples/java/account/delete-authenticator.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; +import io.appwrite.enums.AuthenticatorProvider; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.deleteAuthenticator( + AuthenticatorProvider.TOTP, + "[OTP]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file diff --git a/docs/examples/java/account/delete-identity.md b/docs/examples/java/account/delete-identity.md index 0d92d04..f33c29a 100644 --- a/docs/examples/java/account/delete-identity.md +++ b/docs/examples/java/account/delete-identity.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.deleteIdentity( - "[IDENTITY_ID]" + "[IDENTITY_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ account.deleteIdentity( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/delete-push-target.md b/docs/examples/java/account/delete-push-target.md new file mode 100644 index 0000000..77b21d6 --- /dev/null +++ b/docs/examples/java/account/delete-push-target.md @@ -0,0 +1,21 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.deletePushTarget( + "[TARGET_ID]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file diff --git a/docs/examples/java/account/delete-session.md b/docs/examples/java/account/delete-session.md index 28009d0..2b8d228 100644 --- a/docs/examples/java/account/delete-session.md +++ b/docs/examples/java/account/delete-session.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.deleteSession( - "[SESSION_ID]" + "[SESSION_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ account.deleteSession( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/delete-sessions.md b/docs/examples/java/account/delete-sessions.md index 6bdc840..147523e 100644 --- a/docs/examples/java/account/delete-sessions.md +++ b/docs/examples/java/account/delete-sessions.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.deleteSessions(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/account/get-prefs.md b/docs/examples/java/account/get-prefs.md index 9911ad3..bfa3c1a 100644 --- a/docs/examples/java/account/get-prefs.md +++ b/docs/examples/java/account/get-prefs.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.getPrefs(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/account/get-session.md b/docs/examples/java/account/get-session.md index fecb543..dd9c89c 100644 --- a/docs/examples/java/account/get-session.md +++ b/docs/examples/java/account/get-session.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.getSession( - "[SESSION_ID]" + "[SESSION_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ account.getSession( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/get.md b/docs/examples/java/account/get.md index 2e5f40a..9006cb8 100644 --- a/docs/examples/java/account/get.md +++ b/docs/examples/java/account/get.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.get(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/account/list-factors.md b/docs/examples/java/account/list-factors.md new file mode 100644 index 0000000..e2d92b5 --- /dev/null +++ b/docs/examples/java/account/list-factors.md @@ -0,0 +1,18 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.listFactors(new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/account/list-identities.md b/docs/examples/java/account/list-identities.md index d1f6a48..08d4c19 100644 --- a/docs/examples/java/account/list-identities.md +++ b/docs/examples/java/account/list-identities.md @@ -17,4 +17,4 @@ account.listIdentities( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/list-logs.md b/docs/examples/java/account/list-logs.md index d2ce790..f4c39fb 100644 --- a/docs/examples/java/account/list-logs.md +++ b/docs/examples/java/account/list-logs.md @@ -17,4 +17,4 @@ account.listLogs( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/list-sessions.md b/docs/examples/java/account/list-sessions.md index 7fd587e..9e70f0d 100644 --- a/docs/examples/java/account/list-sessions.md +++ b/docs/examples/java/account/list-sessions.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.listSessions(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/account/update-challenge.md b/docs/examples/java/account/update-challenge.md new file mode 100644 index 0000000..d972a14 --- /dev/null +++ b/docs/examples/java/account/update-challenge.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.updateChallenge( + "[CHALLENGE_ID]", + "[OTP]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file diff --git a/docs/examples/java/account/update-email.md b/docs/examples/java/account/update-email.md index 8034ada..a7cb414 100644 --- a/docs/examples/java/account/update-email.md +++ b/docs/examples/java/account/update-email.md @@ -10,7 +10,7 @@ Account account = new Account(client); account.updateEmail( "email@example.com", - "password" + "password", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.updateEmail( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/update-m-f-a.md b/docs/examples/java/account/update-m-f-a.md new file mode 100644 index 0000000..16f6973 --- /dev/null +++ b/docs/examples/java/account/update-m-f-a.md @@ -0,0 +1,21 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.updateMFA( + false, + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file 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 0f8f2b3..f46422b 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 @@ -10,7 +10,7 @@ Account account = new Account(client); account.updateMagicURLSession( "[USER_ID]", - "[SECRET]" + "[SECRET]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.updateMagicURLSession( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/update-name.md b/docs/examples/java/account/update-name.md index 5940f93..8b27389 100644 --- a/docs/examples/java/account/update-name.md +++ b/docs/examples/java/account/update-name.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.updateName( - "[NAME]" + "[NAME]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ account.updateName( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/update-password.md b/docs/examples/java/account/update-password.md index d942632..430ab7e 100644 --- a/docs/examples/java/account/update-password.md +++ b/docs/examples/java/account/update-password.md @@ -18,4 +18,4 @@ account.updatePassword( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/update-phone-verification.md b/docs/examples/java/account/update-phone-verification.md index 81785f9..7d66fd9 100644 --- a/docs/examples/java/account/update-phone-verification.md +++ b/docs/examples/java/account/update-phone-verification.md @@ -10,7 +10,7 @@ Account account = new Account(client); account.updatePhoneVerification( "[USER_ID]", - "[SECRET]" + "[SECRET]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.updatePhoneVerification( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/update-phone.md b/docs/examples/java/account/update-phone.md index a8572f9..c958911 100644 --- a/docs/examples/java/account/update-phone.md +++ b/docs/examples/java/account/update-phone.md @@ -10,7 +10,7 @@ Account account = new Account(client); account.updatePhone( "+12065550100", - "password" + "password", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.updatePhone( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/update-prefs.md b/docs/examples/java/account/update-prefs.md index ffd5ef0..5d2e75d 100644 --- a/docs/examples/java/account/update-prefs.md +++ b/docs/examples/java/account/update-prefs.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.updatePrefs( - mapOf( "a" to "b" ) + mapOf( "a" to "b" ), new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ account.updatePrefs( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/update-push-target.md b/docs/examples/java/account/update-push-target.md new file mode 100644 index 0000000..10efbad --- /dev/null +++ b/docs/examples/java/account/update-push-target.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.updatePushTarget( + "[TARGET_ID]", + "[IDENTIFIER]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file diff --git a/docs/examples/java/account/update-recovery.md b/docs/examples/java/account/update-recovery.md index 7b0f392..313eaa5 100644 --- a/docs/examples/java/account/update-recovery.md +++ b/docs/examples/java/account/update-recovery.md @@ -11,8 +11,7 @@ Account account = new Account(client); account.updateRecovery( "[USER_ID]", "[SECRET]", - "password", - "password" + "", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -21,4 +20,4 @@ account.updateRecovery( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/update-session.md b/docs/examples/java/account/update-session.md index 27b8f00..66eda54 100644 --- a/docs/examples/java/account/update-session.md +++ b/docs/examples/java/account/update-session.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.updateSession( - "[SESSION_ID]" + "[SESSION_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ account.updateSession( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/update-status.md b/docs/examples/java/account/update-status.md index 1e18ded..61cb944 100644 --- a/docs/examples/java/account/update-status.md +++ b/docs/examples/java/account/update-status.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.updateStatus(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/account/update-verification.md b/docs/examples/java/account/update-verification.md index d852dbf..9beb1bd 100644 --- a/docs/examples/java/account/update-verification.md +++ b/docs/examples/java/account/update-verification.md @@ -10,7 +10,7 @@ Account account = new Account(client); account.updateVerification( "[USER_ID]", - "[SECRET]" + "[SECRET]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.updateVerification( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/verify-authenticator.md b/docs/examples/java/account/verify-authenticator.md new file mode 100644 index 0000000..7a99ffc --- /dev/null +++ b/docs/examples/java/account/verify-authenticator.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; +import io.appwrite.enums.AuthenticatorFactor; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.verifyAuthenticator( + AuthenticatorFactor.TOTP, + "[OTP]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file diff --git a/docs/examples/java/avatars/get-browser.md b/docs/examples/java/avatars/get-browser.md index f072110..0652a47 100644 --- a/docs/examples/java/avatars/get-browser.md +++ b/docs/examples/java/avatars/get-browser.md @@ -1,6 +1,7 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Avatars; +import io.appwrite.enums.Browser; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -9,7 +10,7 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); avatars.getBrowser( - "aa", + Browser.AVANT_BROWSER, new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +19,4 @@ avatars.getBrowser( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/avatars/get-credit-card.md b/docs/examples/java/avatars/get-credit-card.md index 0a73312..0f0541a 100644 --- a/docs/examples/java/avatars/get-credit-card.md +++ b/docs/examples/java/avatars/get-credit-card.md @@ -1,6 +1,7 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Avatars; +import io.appwrite.enums.CreditCard; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -9,7 +10,7 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); avatars.getCreditCard( - "amex", + CreditCard.AMERICAN_EXPRESS, new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +19,4 @@ avatars.getCreditCard( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/avatars/get-favicon.md b/docs/examples/java/avatars/get-favicon.md index e0c1cb6..cef5b08 100644 --- a/docs/examples/java/avatars/get-favicon.md +++ b/docs/examples/java/avatars/get-favicon.md @@ -9,7 +9,7 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); avatars.getFavicon( - "https://example.com" + "https://example.com", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ avatars.getFavicon( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/avatars/get-flag.md b/docs/examples/java/avatars/get-flag.md index a5f4790..c931336 100644 --- a/docs/examples/java/avatars/get-flag.md +++ b/docs/examples/java/avatars/get-flag.md @@ -1,6 +1,7 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Avatars; +import io.appwrite.enums.Flag; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -9,7 +10,7 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); avatars.getFlag( - "af", + Flag.AFGHANISTAN, new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +19,4 @@ avatars.getFlag( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/avatars/get-image.md b/docs/examples/java/avatars/get-image.md index cdc8ac7..8ae4df1 100644 --- a/docs/examples/java/avatars/get-image.md +++ b/docs/examples/java/avatars/get-image.md @@ -18,4 +18,4 @@ avatars.getImage( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/avatars/get-initials.md b/docs/examples/java/avatars/get-initials.md index c02490c..36757c4 100644 --- a/docs/examples/java/avatars/get-initials.md +++ b/docs/examples/java/avatars/get-initials.md @@ -17,4 +17,4 @@ avatars.getInitials( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/avatars/get-q-r.md b/docs/examples/java/avatars/get-q-r.md index 2532f20..4894433 100644 --- a/docs/examples/java/avatars/get-q-r.md +++ b/docs/examples/java/avatars/get-q-r.md @@ -18,4 +18,4 @@ avatars.getQR( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index 715e4cd..c26a142 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -21,4 +21,4 @@ databases.createDocument( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/databases/delete-document.md b/docs/examples/java/databases/delete-document.md index 1387f48..d59266b 100644 --- a/docs/examples/java/databases/delete-document.md +++ b/docs/examples/java/databases/delete-document.md @@ -11,7 +11,7 @@ Databases databases = new Databases(client); databases.deleteDocument( "[DATABASE_ID]", "[COLLECTION_ID]", - "[DOCUMENT_ID]" + "[DOCUMENT_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -20,4 +20,4 @@ databases.deleteDocument( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/databases/get-document.md b/docs/examples/java/databases/get-document.md index b1a7161..a63836e 100644 --- a/docs/examples/java/databases/get-document.md +++ b/docs/examples/java/databases/get-document.md @@ -20,4 +20,4 @@ databases.getDocument( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/databases/list-documents.md b/docs/examples/java/databases/list-documents.md index 62dc2c7..6f577ef 100644 --- a/docs/examples/java/databases/list-documents.md +++ b/docs/examples/java/databases/list-documents.md @@ -19,4 +19,4 @@ databases.listDocuments( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/databases/update-document.md b/docs/examples/java/databases/update-document.md index d1ed59d..ae4d539 100644 --- a/docs/examples/java/databases/update-document.md +++ b/docs/examples/java/databases/update-document.md @@ -20,4 +20,4 @@ databases.updateDocument( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/functions/create-execution.md b/docs/examples/java/functions/create-execution.md index 3cce1c3..985d502 100644 --- a/docs/examples/java/functions/create-execution.md +++ b/docs/examples/java/functions/create-execution.md @@ -18,4 +18,4 @@ functions.createExecution( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/functions/get-execution.md b/docs/examples/java/functions/get-execution.md index 459d743..c066540 100644 --- a/docs/examples/java/functions/get-execution.md +++ b/docs/examples/java/functions/get-execution.md @@ -10,7 +10,7 @@ Functions functions = new Functions(client); functions.getExecution( "[FUNCTION_ID]", - "[EXECUTION_ID]" + "[EXECUTION_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ functions.getExecution( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/functions/list-executions.md b/docs/examples/java/functions/list-executions.md index c1f982b..53f45ca 100644 --- a/docs/examples/java/functions/list-executions.md +++ b/docs/examples/java/functions/list-executions.md @@ -18,4 +18,4 @@ functions.listExecutions( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/graphql/mutation.md b/docs/examples/java/graphql/mutation.md index 262e513..5d140d6 100644 --- a/docs/examples/java/graphql/mutation.md +++ b/docs/examples/java/graphql/mutation.md @@ -9,7 +9,7 @@ Client client = new Client(context) Graphql graphql = new Graphql(client); graphql.mutation( - mapOf( "a" to "b" ) + mapOf( "a" to "b" ), new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ graphql.mutation( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/graphql/query.md b/docs/examples/java/graphql/query.md index 4291b47..de693fa 100644 --- a/docs/examples/java/graphql/query.md +++ b/docs/examples/java/graphql/query.md @@ -9,7 +9,7 @@ Client client = new Client(context) Graphql graphql = new Graphql(client); graphql.query( - mapOf( "a" to "b" ) + mapOf( "a" to "b" ), new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ graphql.query( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/locale/get.md b/docs/examples/java/locale/get.md index 4d14be6..cc37896 100644 --- a/docs/examples/java/locale/get.md +++ b/docs/examples/java/locale/get.md @@ -9,7 +9,7 @@ Client client = new Client(context) Locale locale = new Locale(client); locale.get(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/locale/list-codes.md b/docs/examples/java/locale/list-codes.md index 599070e..3fbdf85 100644 --- a/docs/examples/java/locale/list-codes.md +++ b/docs/examples/java/locale/list-codes.md @@ -9,7 +9,7 @@ Client client = new Client(context) Locale locale = new Locale(client); locale.listCodes(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/locale/list-continents.md b/docs/examples/java/locale/list-continents.md index 6abe97a..296eade 100644 --- a/docs/examples/java/locale/list-continents.md +++ b/docs/examples/java/locale/list-continents.md @@ -9,7 +9,7 @@ Client client = new Client(context) Locale locale = new Locale(client); locale.listContinents(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/locale/list-countries-e-u.md b/docs/examples/java/locale/list-countries-e-u.md index 3c5ca3a..f674ac5 100644 --- a/docs/examples/java/locale/list-countries-e-u.md +++ b/docs/examples/java/locale/list-countries-e-u.md @@ -9,7 +9,7 @@ Client client = new Client(context) Locale locale = new Locale(client); locale.listCountriesEU(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/locale/list-countries-phones.md b/docs/examples/java/locale/list-countries-phones.md index 81ef94d..6280cbb 100644 --- a/docs/examples/java/locale/list-countries-phones.md +++ b/docs/examples/java/locale/list-countries-phones.md @@ -9,7 +9,7 @@ Client client = new Client(context) Locale locale = new Locale(client); locale.listCountriesPhones(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/locale/list-countries.md b/docs/examples/java/locale/list-countries.md index dc0d5f5..eab9ae2 100644 --- a/docs/examples/java/locale/list-countries.md +++ b/docs/examples/java/locale/list-countries.md @@ -9,7 +9,7 @@ Client client = new Client(context) Locale locale = new Locale(client); locale.listCountries(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/locale/list-currencies.md b/docs/examples/java/locale/list-currencies.md index 7a327b3..662e025 100644 --- a/docs/examples/java/locale/list-currencies.md +++ b/docs/examples/java/locale/list-currencies.md @@ -9,7 +9,7 @@ Client client = new Client(context) Locale locale = new Locale(client); locale.listCurrencies(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/locale/list-languages.md b/docs/examples/java/locale/list-languages.md index 0688614..dd68bf2 100644 --- a/docs/examples/java/locale/list-languages.md +++ b/docs/examples/java/locale/list-languages.md @@ -9,7 +9,7 @@ Client client = new Client(context) Locale locale = new Locale(client); locale.listLanguages(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/messaging/create-subscriber.md b/docs/examples/java/messaging/create-subscriber.md new file mode 100644 index 0000000..d071008 --- /dev/null +++ b/docs/examples/java/messaging/create-subscriber.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Messaging; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Messaging messaging = new Messaging(client); + +messaging.createSubscriber( + "[TOPIC_ID]", + "[SUBSCRIBER_ID]", + "[TARGET_ID]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file diff --git a/docs/examples/java/messaging/delete-subscriber.md b/docs/examples/java/messaging/delete-subscriber.md new file mode 100644 index 0000000..a1d5686 --- /dev/null +++ b/docs/examples/java/messaging/delete-subscriber.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Messaging; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Messaging messaging = new Messaging(client); + +messaging.deleteSubscriber( + "[TOPIC_ID]", + "[SUBSCRIBER_ID]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file diff --git a/docs/examples/java/storage/create-file.md b/docs/examples/java/storage/create-file.md index 732b302..b99312b 100644 --- a/docs/examples/java/storage/create-file.md +++ b/docs/examples/java/storage/create-file.md @@ -21,4 +21,4 @@ storage.createFile( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/storage/delete-file.md b/docs/examples/java/storage/delete-file.md index 69a0f0f..9ac7f2e 100644 --- a/docs/examples/java/storage/delete-file.md +++ b/docs/examples/java/storage/delete-file.md @@ -10,7 +10,7 @@ Storage storage = new Storage(client); storage.deleteFile( "[BUCKET_ID]", - "[FILE_ID]" + "[FILE_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ storage.deleteFile( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/storage/get-file-download.md b/docs/examples/java/storage/get-file-download.md index 2ab30dc..7428cc0 100644 --- a/docs/examples/java/storage/get-file-download.md +++ b/docs/examples/java/storage/get-file-download.md @@ -10,7 +10,7 @@ Storage storage = new Storage(client); storage.getFileDownload( "[BUCKET_ID]", - "[FILE_ID]" + "[FILE_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ storage.getFileDownload( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/storage/get-file-preview.md b/docs/examples/java/storage/get-file-preview.md index 483f2fc..6de0abf 100644 --- a/docs/examples/java/storage/get-file-preview.md +++ b/docs/examples/java/storage/get-file-preview.md @@ -19,4 +19,4 @@ storage.getFilePreview( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/storage/get-file-view.md b/docs/examples/java/storage/get-file-view.md index 5614b69..3c0392d 100644 --- a/docs/examples/java/storage/get-file-view.md +++ b/docs/examples/java/storage/get-file-view.md @@ -10,7 +10,7 @@ Storage storage = new Storage(client); storage.getFileView( "[BUCKET_ID]", - "[FILE_ID]" + "[FILE_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ storage.getFileView( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/storage/get-file.md b/docs/examples/java/storage/get-file.md index 4ae0de0..c425758 100644 --- a/docs/examples/java/storage/get-file.md +++ b/docs/examples/java/storage/get-file.md @@ -10,7 +10,7 @@ Storage storage = new Storage(client); storage.getFile( "[BUCKET_ID]", - "[FILE_ID]" + "[FILE_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ storage.getFile( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/storage/list-files.md b/docs/examples/java/storage/list-files.md index dedfb6c..b6d38aa 100644 --- a/docs/examples/java/storage/list-files.md +++ b/docs/examples/java/storage/list-files.md @@ -18,4 +18,4 @@ storage.listFiles( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/storage/update-file.md b/docs/examples/java/storage/update-file.md index 9b4dd92..6aae427 100644 --- a/docs/examples/java/storage/update-file.md +++ b/docs/examples/java/storage/update-file.md @@ -19,4 +19,4 @@ storage.updateFile( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/create-membership.md b/docs/examples/java/teams/create-membership.md index 6073f5b..3091164 100644 --- a/docs/examples/java/teams/create-membership.md +++ b/docs/examples/java/teams/create-membership.md @@ -19,4 +19,4 @@ teams.createMembership( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/create.md b/docs/examples/java/teams/create.md index 263fa57..aa7f567 100644 --- a/docs/examples/java/teams/create.md +++ b/docs/examples/java/teams/create.md @@ -19,4 +19,4 @@ teams.create( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/delete-membership.md b/docs/examples/java/teams/delete-membership.md index 40f28f0..3837fad 100644 --- a/docs/examples/java/teams/delete-membership.md +++ b/docs/examples/java/teams/delete-membership.md @@ -10,7 +10,7 @@ Teams teams = new Teams(client); teams.deleteMembership( "[TEAM_ID]", - "[MEMBERSHIP_ID]" + "[MEMBERSHIP_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ teams.deleteMembership( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/delete.md b/docs/examples/java/teams/delete.md index 5b4c378..75355ae 100644 --- a/docs/examples/java/teams/delete.md +++ b/docs/examples/java/teams/delete.md @@ -9,7 +9,7 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.delete( - "[TEAM_ID]" + "[TEAM_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ teams.delete( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/get-membership.md b/docs/examples/java/teams/get-membership.md index f2f1d99..0ba9c87 100644 --- a/docs/examples/java/teams/get-membership.md +++ b/docs/examples/java/teams/get-membership.md @@ -10,7 +10,7 @@ Teams teams = new Teams(client); teams.getMembership( "[TEAM_ID]", - "[MEMBERSHIP_ID]" + "[MEMBERSHIP_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ teams.getMembership( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/get-prefs.md b/docs/examples/java/teams/get-prefs.md index 6963cb4..e93b482 100644 --- a/docs/examples/java/teams/get-prefs.md +++ b/docs/examples/java/teams/get-prefs.md @@ -9,7 +9,7 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.getPrefs( - "[TEAM_ID]" + "[TEAM_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ teams.getPrefs( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/get.md b/docs/examples/java/teams/get.md index 549af20..f5406a2 100644 --- a/docs/examples/java/teams/get.md +++ b/docs/examples/java/teams/get.md @@ -9,7 +9,7 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.get( - "[TEAM_ID]" + "[TEAM_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ teams.get( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/list-memberships.md b/docs/examples/java/teams/list-memberships.md index 3da4e33..b61b0d0 100644 --- a/docs/examples/java/teams/list-memberships.md +++ b/docs/examples/java/teams/list-memberships.md @@ -18,4 +18,4 @@ teams.listMemberships( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/list.md b/docs/examples/java/teams/list.md index b20ad4a..2f21813 100644 --- a/docs/examples/java/teams/list.md +++ b/docs/examples/java/teams/list.md @@ -17,4 +17,4 @@ teams.list( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/update-membership-status.md b/docs/examples/java/teams/update-membership-status.md index 499251f..33bd869 100644 --- a/docs/examples/java/teams/update-membership-status.md +++ b/docs/examples/java/teams/update-membership-status.md @@ -12,7 +12,7 @@ teams.updateMembershipStatus( "[TEAM_ID]", "[MEMBERSHIP_ID]", "[USER_ID]", - "[SECRET]" + "[SECRET]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -21,4 +21,4 @@ teams.updateMembershipStatus( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/update-membership.md b/docs/examples/java/teams/update-membership.md index 6cb3346..48efbe3 100644 --- a/docs/examples/java/teams/update-membership.md +++ b/docs/examples/java/teams/update-membership.md @@ -11,7 +11,7 @@ Teams teams = new Teams(client); teams.updateMembership( "[TEAM_ID]", "[MEMBERSHIP_ID]", - listOf() + listOf(), new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -20,4 +20,4 @@ teams.updateMembership( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/update-name.md b/docs/examples/java/teams/update-name.md index 170ee59..a84ba84 100644 --- a/docs/examples/java/teams/update-name.md +++ b/docs/examples/java/teams/update-name.md @@ -10,7 +10,7 @@ Teams teams = new Teams(client); teams.updateName( "[TEAM_ID]", - "[NAME]" + "[NAME]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ teams.updateName( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/update-prefs.md b/docs/examples/java/teams/update-prefs.md index a19ad82..874f976 100644 --- a/docs/examples/java/teams/update-prefs.md +++ b/docs/examples/java/teams/update-prefs.md @@ -10,7 +10,7 @@ Teams teams = new Teams(client); teams.updatePrefs( "[TEAM_ID]", - mapOf( "a" to "b" ) + mapOf( "a" to "b" ), new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ teams.updatePrefs( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/users/delete-authenticator.md b/docs/examples/java/users/delete-authenticator.md new file mode 100644 index 0000000..2de3df7 --- /dev/null +++ b/docs/examples/java/users/delete-authenticator.md @@ -0,0 +1,24 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Users; +import io.appwrite.enums.AuthenticatorProvider; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Users users = new Users(client); + +users.deleteAuthenticator( + "[USER_ID]", + AuthenticatorProvider.TOTP, + "[OTP]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file diff --git a/docs/examples/java/users/list-providers.md b/docs/examples/java/users/list-providers.md new file mode 100644 index 0000000..ca2f27d --- /dev/null +++ b/docs/examples/java/users/list-providers.md @@ -0,0 +1,21 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Users; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Users users = new Users(client); + +users.listProviders( + "[USER_ID]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file diff --git a/docs/examples/kotlin/account/add-authenticator.md b/docs/examples/kotlin/account/add-authenticator.md new file mode 100644 index 0000000..adb0cf9 --- /dev/null +++ b/docs/examples/kotlin/account/add-authenticator.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account +import io.appwrite.enums.AuthenticatorFactor + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val response = account.addAuthenticator( + factor = AuthenticatorFactor.TOTP, +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-anonymous-session.md b/docs/examples/kotlin/account/create-anonymous-session.md index cdcf401..6d1e632 100644 --- a/docs/examples/kotlin/account/create-anonymous-session.md +++ b/docs/examples/kotlin/account/create-anonymous-session.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) diff --git a/docs/examples/kotlin/account/create-challenge.md b/docs/examples/kotlin/account/create-challenge.md new file mode 100644 index 0000000..d1b0df9 --- /dev/null +++ b/docs/examples/kotlin/account/create-challenge.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account +import io.appwrite.enums.AuthenticatorProvider + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val response = account.createChallenge( + provider = AuthenticatorProvider.TOTP, +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-email-password-session.md b/docs/examples/kotlin/account/create-email-password-session.md new file mode 100644 index 0000000..016e73b --- /dev/null +++ b/docs/examples/kotlin/account/create-email-password-session.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val response = account.createEmailPasswordSession( + email = "email@example.com", + password = "password", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-magic-u-r-l-session.md b/docs/examples/kotlin/account/create-email-token.md similarity index 77% rename from docs/examples/kotlin/account/create-magic-u-r-l-session.md rename to docs/examples/kotlin/account/create-email-token.md index 51368b5..6165707 100644 --- a/docs/examples/kotlin/account/create-magic-u-r-l-session.md +++ b/docs/examples/kotlin/account/create-email-token.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -7,7 +8,7 @@ val client = Client(context) val account = Account(client) -val response = account.createMagicURLSession( +val response = account.createEmailToken( userId = "[USER_ID]", email = "email@example.com", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-j-w-t.md b/docs/examples/kotlin/account/create-j-w-t.md index 35e7a6f..c3131e6 100644 --- a/docs/examples/kotlin/account/create-j-w-t.md +++ b/docs/examples/kotlin/account/create-j-w-t.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) diff --git a/docs/examples/kotlin/account/create-email-session.md b/docs/examples/kotlin/account/create-magic-u-r-l-token.md similarity index 70% rename from docs/examples/kotlin/account/create-email-session.md rename to docs/examples/kotlin/account/create-magic-u-r-l-token.md index ab8d581..9d02c96 100644 --- a/docs/examples/kotlin/account/create-email-session.md +++ b/docs/examples/kotlin/account/create-magic-u-r-l-token.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -7,7 +8,7 @@ val client = Client(context) val account = Account(client) -val response = account.createEmailSession( +val response = account.createMagicURLToken( + userId = "[USER_ID]", email = "email@example.com", - password = "password" -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-o-auth2session.md b/docs/examples/kotlin/account/create-o-auth2session.md index 395bfad..ac01fe5 100644 --- a/docs/examples/kotlin/account/create-o-auth2session.md +++ b/docs/examples/kotlin/account/create-o-auth2session.md @@ -1,5 +1,7 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account +import io.appwrite.enums.OAuthProvider val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -8,5 +10,5 @@ val client = Client(context) val account = Account(client) account.createOAuth2Session( - provider = "amazon", -) + provider = OAuthProvider.AMAZON, +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-phone-token.md b/docs/examples/kotlin/account/create-phone-token.md new file mode 100644 index 0000000..abb46c5 --- /dev/null +++ b/docs/examples/kotlin/account/create-phone-token.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val response = account.createPhoneToken( + userId = "[USER_ID]", + phone = "+12065550100", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-phone-verification.md b/docs/examples/kotlin/account/create-phone-verification.md index 12fb9f7..3fb5064 100644 --- a/docs/examples/kotlin/account/create-phone-verification.md +++ b/docs/examples/kotlin/account/create-phone-verification.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) diff --git a/docs/examples/kotlin/account/create-push-target.md b/docs/examples/kotlin/account/create-push-target.md new file mode 100644 index 0000000..30c4d39 --- /dev/null +++ b/docs/examples/kotlin/account/create-push-target.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val response = account.createPushTarget( + targetId = "[TARGET_ID]", + identifier = "[IDENTIFIER]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-recovery.md b/docs/examples/kotlin/account/create-recovery.md index 7d73a67..f678fcf 100644 --- a/docs/examples/kotlin/account/create-recovery.md +++ b/docs/examples/kotlin/account/create-recovery.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -9,5 +10,5 @@ val account = Account(client) val response = account.createRecovery( email = "email@example.com", - url = "https://example.com" -) + url = "https://example.com", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-session.md b/docs/examples/kotlin/account/create-session.md new file mode 100644 index 0000000..ceb7726 --- /dev/null +++ b/docs/examples/kotlin/account/create-session.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val response = account.createSession( + userId = "[USER_ID]", + secret = "[SECRET]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-verification.md b/docs/examples/kotlin/account/create-verification.md index b3dc43a..1832348 100644 --- a/docs/examples/kotlin/account/create-verification.md +++ b/docs/examples/kotlin/account/create-verification.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -8,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.createVerification( - url = "https://example.com" -) + url = "https://example.com", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create.md b/docs/examples/kotlin/account/create.md index c72ae90..8022955 100644 --- a/docs/examples/kotlin/account/create.md +++ b/docs/examples/kotlin/account/create.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -11,4 +12,4 @@ val response = account.create( userId = "[USER_ID]", email = "email@example.com", password = "", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-authenticator.md b/docs/examples/kotlin/account/delete-authenticator.md new file mode 100644 index 0000000..beb63f1 --- /dev/null +++ b/docs/examples/kotlin/account/delete-authenticator.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account +import io.appwrite.enums.AuthenticatorProvider + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val response = account.deleteAuthenticator( + provider = AuthenticatorProvider.TOTP, + otp = "[OTP]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-identity.md b/docs/examples/kotlin/account/delete-identity.md index 440333e..cbf6913 100644 --- a/docs/examples/kotlin/account/delete-identity.md +++ b/docs/examples/kotlin/account/delete-identity.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -8,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.deleteIdentity( - identityId = "[IDENTITY_ID]" -) + identityId = "[IDENTITY_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-push-target.md b/docs/examples/kotlin/account/delete-push-target.md new file mode 100644 index 0000000..ea79749 --- /dev/null +++ b/docs/examples/kotlin/account/delete-push-target.md @@ -0,0 +1,13 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val response = account.deletePushTarget( + targetId = "[TARGET_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-session.md b/docs/examples/kotlin/account/delete-session.md index a98a286..615f218 100644 --- a/docs/examples/kotlin/account/delete-session.md +++ b/docs/examples/kotlin/account/delete-session.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -8,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.deleteSession( - sessionId = "[SESSION_ID]" -) + sessionId = "[SESSION_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-sessions.md b/docs/examples/kotlin/account/delete-sessions.md index c9afbf1..db8e00d 100644 --- a/docs/examples/kotlin/account/delete-sessions.md +++ b/docs/examples/kotlin/account/delete-sessions.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) diff --git a/docs/examples/kotlin/account/get-prefs.md b/docs/examples/kotlin/account/get-prefs.md index bd3f81a..0112f8b 100644 --- a/docs/examples/kotlin/account/get-prefs.md +++ b/docs/examples/kotlin/account/get-prefs.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) diff --git a/docs/examples/kotlin/account/get-session.md b/docs/examples/kotlin/account/get-session.md index d6d6c72..1b15d5b 100644 --- a/docs/examples/kotlin/account/get-session.md +++ b/docs/examples/kotlin/account/get-session.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -8,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.getSession( - sessionId = "[SESSION_ID]" -) + sessionId = "[SESSION_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/get.md b/docs/examples/kotlin/account/get.md index 4c8f0be..6c08a1c 100644 --- a/docs/examples/kotlin/account/get.md +++ b/docs/examples/kotlin/account/get.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) diff --git a/docs/examples/kotlin/account/update-phone-session.md b/docs/examples/kotlin/account/list-factors.md similarity index 72% rename from docs/examples/kotlin/account/update-phone-session.md rename to docs/examples/kotlin/account/list-factors.md index d3b02e0..e30f652 100644 --- a/docs/examples/kotlin/account/update-phone-session.md +++ b/docs/examples/kotlin/account/list-factors.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -7,7 +8,4 @@ val client = Client(context) val account = Account(client) -val response = account.updatePhoneSession( - userId = "[USER_ID]", - secret = "[SECRET]" -) +val response = account.listFactors() diff --git a/docs/examples/kotlin/account/list-identities.md b/docs/examples/kotlin/account/list-identities.md index 3292b35..d87409c 100644 --- a/docs/examples/kotlin/account/list-identities.md +++ b/docs/examples/kotlin/account/list-identities.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -8,4 +9,4 @@ val client = Client(context) val account = Account(client) val response = account.listIdentities( -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/list-logs.md b/docs/examples/kotlin/account/list-logs.md index eb337ca..f4ce74f 100644 --- a/docs/examples/kotlin/account/list-logs.md +++ b/docs/examples/kotlin/account/list-logs.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -8,4 +9,4 @@ val client = Client(context) val account = Account(client) val response = account.listLogs( -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/list-sessions.md b/docs/examples/kotlin/account/list-sessions.md index cd9f63b..2c692b8 100644 --- a/docs/examples/kotlin/account/list-sessions.md +++ b/docs/examples/kotlin/account/list-sessions.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) diff --git a/docs/examples/kotlin/account/update-challenge.md b/docs/examples/kotlin/account/update-challenge.md new file mode 100644 index 0000000..23718d2 --- /dev/null +++ b/docs/examples/kotlin/account/update-challenge.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val response = account.updateChallenge( + challengeId = "[CHALLENGE_ID]", + otp = "[OTP]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-email.md b/docs/examples/kotlin/account/update-email.md index 85a0242..6b3655a 100644 --- a/docs/examples/kotlin/account/update-email.md +++ b/docs/examples/kotlin/account/update-email.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -9,5 +10,5 @@ val account = Account(client) val response = account.updateEmail( email = "email@example.com", - password = "password" -) + password = "password", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-phone-session.md b/docs/examples/kotlin/account/update-m-f-a.md similarity index 71% rename from docs/examples/kotlin/account/create-phone-session.md rename to docs/examples/kotlin/account/update-m-f-a.md index eed6f7a..1bd3fd2 100644 --- a/docs/examples/kotlin/account/create-phone-session.md +++ b/docs/examples/kotlin/account/update-m-f-a.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -7,7 +8,6 @@ val client = Client(context) val account = Account(client) -val response = account.createPhoneSession( - userId = "[USER_ID]", - phone = "+12065550100" -) +val response = account.updateMFA( + mfa = false, +) \ No newline at end of file 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 c7286ba..1f77281 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,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -9,5 +10,5 @@ val account = Account(client) val response = account.updateMagicURLSession( userId = "[USER_ID]", - secret = "[SECRET]" -) + secret = "[SECRET]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-name.md b/docs/examples/kotlin/account/update-name.md index 574f493..5d18e1f 100644 --- a/docs/examples/kotlin/account/update-name.md +++ b/docs/examples/kotlin/account/update-name.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -8,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.updateName( - name = "[NAME]" -) + name = "[NAME]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-password.md b/docs/examples/kotlin/account/update-password.md index c5338b8..45e9556 100644 --- a/docs/examples/kotlin/account/update-password.md +++ b/docs/examples/kotlin/account/update-password.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -9,4 +10,4 @@ val account = Account(client) val response = account.updatePassword( password = "", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-phone-verification.md b/docs/examples/kotlin/account/update-phone-verification.md index 0314f74..c4c0e84 100644 --- a/docs/examples/kotlin/account/update-phone-verification.md +++ b/docs/examples/kotlin/account/update-phone-verification.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -9,5 +10,5 @@ val account = Account(client) val response = account.updatePhoneVerification( userId = "[USER_ID]", - secret = "[SECRET]" -) + secret = "[SECRET]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-phone.md b/docs/examples/kotlin/account/update-phone.md index 76eb8aa..d86e628 100644 --- a/docs/examples/kotlin/account/update-phone.md +++ b/docs/examples/kotlin/account/update-phone.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -9,5 +10,5 @@ val account = Account(client) val response = account.updatePhone( phone = "+12065550100", - password = "password" -) + password = "password", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-prefs.md b/docs/examples/kotlin/account/update-prefs.md index f16e40b..58d5cd0 100644 --- a/docs/examples/kotlin/account/update-prefs.md +++ b/docs/examples/kotlin/account/update-prefs.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -8,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.updatePrefs( - prefs = mapOf( "a" to "b" ) -) + prefs = mapOf( "a" to "b" ), +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-push-target.md b/docs/examples/kotlin/account/update-push-target.md new file mode 100644 index 0000000..ff1e3a1 --- /dev/null +++ b/docs/examples/kotlin/account/update-push-target.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val response = account.updatePushTarget( + targetId = "[TARGET_ID]", + identifier = "[IDENTIFIER]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-recovery.md b/docs/examples/kotlin/account/update-recovery.md index 9682899..6b7a6d0 100644 --- a/docs/examples/kotlin/account/update-recovery.md +++ b/docs/examples/kotlin/account/update-recovery.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -10,6 +11,5 @@ val account = Account(client) val response = account.updateRecovery( userId = "[USER_ID]", secret = "[SECRET]", - password = "password", - passwordAgain = "password" -) + password = "", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-session.md b/docs/examples/kotlin/account/update-session.md index e9e83d0..1257334 100644 --- a/docs/examples/kotlin/account/update-session.md +++ b/docs/examples/kotlin/account/update-session.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -8,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.updateSession( - sessionId = "[SESSION_ID]" -) + sessionId = "[SESSION_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-status.md b/docs/examples/kotlin/account/update-status.md index f7789ea..e822de9 100644 --- a/docs/examples/kotlin/account/update-status.md +++ b/docs/examples/kotlin/account/update-status.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) diff --git a/docs/examples/kotlin/account/update-verification.md b/docs/examples/kotlin/account/update-verification.md index af800c1..0dcd75b 100644 --- a/docs/examples/kotlin/account/update-verification.md +++ b/docs/examples/kotlin/account/update-verification.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -9,5 +10,5 @@ val account = Account(client) val response = account.updateVerification( userId = "[USER_ID]", - secret = "[SECRET]" -) + secret = "[SECRET]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/verify-authenticator.md b/docs/examples/kotlin/account/verify-authenticator.md new file mode 100644 index 0000000..65144f7 --- /dev/null +++ b/docs/examples/kotlin/account/verify-authenticator.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account +import io.appwrite.enums.AuthenticatorFactor + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val response = account.verifyAuthenticator( + factor = AuthenticatorFactor.TOTP, + otp = "[OTP]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-browser.md b/docs/examples/kotlin/avatars/get-browser.md index b1b2d08..ab7c749 100644 --- a/docs/examples/kotlin/avatars/get-browser.md +++ b/docs/examples/kotlin/avatars/get-browser.md @@ -1,5 +1,7 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars +import io.appwrite.enums.Browser val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -7,6 +9,6 @@ val client = Client(context) val avatars = Avatars(client) -val result = avatars.getBrowser( - code = "aa", -) +val result =avatars.getBrowser( + code = Browser.AVANT_BROWSER, +) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-credit-card.md b/docs/examples/kotlin/avatars/get-credit-card.md index 411e05a..758f70d 100644 --- a/docs/examples/kotlin/avatars/get-credit-card.md +++ b/docs/examples/kotlin/avatars/get-credit-card.md @@ -1,5 +1,7 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars +import io.appwrite.enums.CreditCard val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -7,6 +9,6 @@ val client = Client(context) val avatars = Avatars(client) -val result = avatars.getCreditCard( - code = "amex", -) +val result =avatars.getCreditCard( + code = CreditCard.AMERICAN_EXPRESS, +) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-favicon.md b/docs/examples/kotlin/avatars/get-favicon.md index 1a4b217..1bb1372 100644 --- a/docs/examples/kotlin/avatars/get-favicon.md +++ b/docs/examples/kotlin/avatars/get-favicon.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars val client = Client(context) @@ -7,6 +8,6 @@ val client = Client(context) val avatars = Avatars(client) -val result = avatars.getFavicon( - url = "https://example.com" -) +val result =avatars.getFavicon( + url = "https://example.com", +) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-flag.md b/docs/examples/kotlin/avatars/get-flag.md index 5c882d6..142f626 100644 --- a/docs/examples/kotlin/avatars/get-flag.md +++ b/docs/examples/kotlin/avatars/get-flag.md @@ -1,5 +1,7 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars +import io.appwrite.enums.Flag val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -7,6 +9,6 @@ val client = Client(context) val avatars = Avatars(client) -val result = avatars.getFlag( - code = "af", -) +val result =avatars.getFlag( + code = Flag.AFGHANISTAN, +) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-image.md b/docs/examples/kotlin/avatars/get-image.md index 20d8dff..c1ccd96 100644 --- a/docs/examples/kotlin/avatars/get-image.md +++ b/docs/examples/kotlin/avatars/get-image.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars val client = Client(context) @@ -7,6 +8,6 @@ val client = Client(context) val avatars = Avatars(client) -val result = avatars.getImage( +val result =avatars.getImage( url = "https://example.com", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-initials.md b/docs/examples/kotlin/avatars/get-initials.md index 70ef9b2..62c69c8 100644 --- a/docs/examples/kotlin/avatars/get-initials.md +++ b/docs/examples/kotlin/avatars/get-initials.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars val client = Client(context) @@ -7,5 +8,5 @@ val client = Client(context) val avatars = Avatars(client) -val result = avatars.getInitials( -) +val result =avatars.getInitials( +) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-q-r.md b/docs/examples/kotlin/avatars/get-q-r.md index 92b17e1..85de6d3 100644 --- a/docs/examples/kotlin/avatars/get-q-r.md +++ b/docs/examples/kotlin/avatars/get-q-r.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars val client = Client(context) @@ -7,6 +8,6 @@ val client = Client(context) val avatars = Avatars(client) -val result = avatars.getQR( +val result =avatars.getQR( text = "[TEXT]", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index d7f1991..bc5445a 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Databases val client = Client(context) @@ -12,4 +13,4 @@ val response = databases.createDocument( collectionId = "[COLLECTION_ID]", documentId = "[DOCUMENT_ID]", data = mapOf( "a" to "b" ), -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/delete-document.md b/docs/examples/kotlin/databases/delete-document.md index c5bf2a2..d24db61 100644 --- a/docs/examples/kotlin/databases/delete-document.md +++ b/docs/examples/kotlin/databases/delete-document.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Databases val client = Client(context) @@ -10,5 +11,5 @@ val databases = Databases(client) val response = databases.deleteDocument( databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", - documentId = "[DOCUMENT_ID]" -) + documentId = "[DOCUMENT_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/get-document.md b/docs/examples/kotlin/databases/get-document.md index abdee36..328b801 100644 --- a/docs/examples/kotlin/databases/get-document.md +++ b/docs/examples/kotlin/databases/get-document.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Databases val client = Client(context) @@ -11,4 +12,4 @@ val response = databases.getDocument( databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", documentId = "[DOCUMENT_ID]", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/list-documents.md b/docs/examples/kotlin/databases/list-documents.md index f97d878..b5511d6 100644 --- a/docs/examples/kotlin/databases/list-documents.md +++ b/docs/examples/kotlin/databases/list-documents.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Databases val client = Client(context) @@ -10,4 +11,4 @@ val databases = Databases(client) val response = databases.listDocuments( databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/update-document.md b/docs/examples/kotlin/databases/update-document.md index 3820b89..e2d989e 100644 --- a/docs/examples/kotlin/databases/update-document.md +++ b/docs/examples/kotlin/databases/update-document.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Databases val client = Client(context) @@ -11,4 +12,4 @@ val response = databases.updateDocument( databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", documentId = "[DOCUMENT_ID]", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/create-execution.md b/docs/examples/kotlin/functions/create-execution.md index 77d4587..96dad59 100644 --- a/docs/examples/kotlin/functions/create-execution.md +++ b/docs/examples/kotlin/functions/create-execution.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Functions val client = Client(context) @@ -9,4 +10,4 @@ val functions = Functions(client) val response = functions.createExecution( functionId = "[FUNCTION_ID]", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/get-execution.md b/docs/examples/kotlin/functions/get-execution.md index b576686..e366f4b 100644 --- a/docs/examples/kotlin/functions/get-execution.md +++ b/docs/examples/kotlin/functions/get-execution.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Functions val client = Client(context) @@ -9,5 +10,5 @@ val functions = Functions(client) val response = functions.getExecution( functionId = "[FUNCTION_ID]", - executionId = "[EXECUTION_ID]" -) + executionId = "[EXECUTION_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/list-executions.md b/docs/examples/kotlin/functions/list-executions.md index 14b613f..ba2ff2d 100644 --- a/docs/examples/kotlin/functions/list-executions.md +++ b/docs/examples/kotlin/functions/list-executions.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Functions val client = Client(context) @@ -9,4 +10,4 @@ val functions = Functions(client) val response = functions.listExecutions( functionId = "[FUNCTION_ID]", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/graphql/mutation.md b/docs/examples/kotlin/graphql/mutation.md index dc37a3e..eee3f82 100644 --- a/docs/examples/kotlin/graphql/mutation.md +++ b/docs/examples/kotlin/graphql/mutation.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Graphql val client = Client(context) @@ -8,5 +9,5 @@ val client = Client(context) val graphql = Graphql(client) val response = graphql.mutation( - query = mapOf( "a" to "b" ) -) + query = mapOf( "a" to "b" ), +) \ No newline at end of file diff --git a/docs/examples/kotlin/graphql/query.md b/docs/examples/kotlin/graphql/query.md index d821070..1337d36 100644 --- a/docs/examples/kotlin/graphql/query.md +++ b/docs/examples/kotlin/graphql/query.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Graphql val client = Client(context) @@ -8,5 +9,5 @@ val client = Client(context) val graphql = Graphql(client) val response = graphql.query( - query = mapOf( "a" to "b" ) -) + query = mapOf( "a" to "b" ), +) \ No newline at end of file diff --git a/docs/examples/kotlin/locale/get.md b/docs/examples/kotlin/locale/get.md index a2044c7..ec7f625 100644 --- a/docs/examples/kotlin/locale/get.md +++ b/docs/examples/kotlin/locale/get.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) diff --git a/docs/examples/kotlin/locale/list-codes.md b/docs/examples/kotlin/locale/list-codes.md index b4e949b..e81e106 100644 --- a/docs/examples/kotlin/locale/list-codes.md +++ b/docs/examples/kotlin/locale/list-codes.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) diff --git a/docs/examples/kotlin/locale/list-continents.md b/docs/examples/kotlin/locale/list-continents.md index 610747e..0255e65 100644 --- a/docs/examples/kotlin/locale/list-continents.md +++ b/docs/examples/kotlin/locale/list-continents.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) diff --git a/docs/examples/kotlin/locale/list-countries-e-u.md b/docs/examples/kotlin/locale/list-countries-e-u.md index fa5483f..4cf60d9 100644 --- a/docs/examples/kotlin/locale/list-countries-e-u.md +++ b/docs/examples/kotlin/locale/list-countries-e-u.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) diff --git a/docs/examples/kotlin/locale/list-countries-phones.md b/docs/examples/kotlin/locale/list-countries-phones.md index 6aba463..1f8f75b 100644 --- a/docs/examples/kotlin/locale/list-countries-phones.md +++ b/docs/examples/kotlin/locale/list-countries-phones.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) diff --git a/docs/examples/kotlin/locale/list-countries.md b/docs/examples/kotlin/locale/list-countries.md index c58456b..f221fc6 100644 --- a/docs/examples/kotlin/locale/list-countries.md +++ b/docs/examples/kotlin/locale/list-countries.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) diff --git a/docs/examples/kotlin/locale/list-currencies.md b/docs/examples/kotlin/locale/list-currencies.md index 2cf0644..6e5ab0d 100644 --- a/docs/examples/kotlin/locale/list-currencies.md +++ b/docs/examples/kotlin/locale/list-currencies.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) diff --git a/docs/examples/kotlin/locale/list-languages.md b/docs/examples/kotlin/locale/list-languages.md index afc00b1..97a9eb7 100644 --- a/docs/examples/kotlin/locale/list-languages.md +++ b/docs/examples/kotlin/locale/list-languages.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) diff --git a/docs/examples/kotlin/messaging/create-subscriber.md b/docs/examples/kotlin/messaging/create-subscriber.md new file mode 100644 index 0000000..1da3ed3 --- /dev/null +++ b/docs/examples/kotlin/messaging/create-subscriber.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Messaging + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val messaging = Messaging(client) + +val response = messaging.createSubscriber( + topicId = "[TOPIC_ID]", + subscriberId = "[SUBSCRIBER_ID]", + targetId = "[TARGET_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/messaging/delete-subscriber.md b/docs/examples/kotlin/messaging/delete-subscriber.md new file mode 100644 index 0000000..0096de3 --- /dev/null +++ b/docs/examples/kotlin/messaging/delete-subscriber.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Messaging + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val messaging = Messaging(client) + +val response = messaging.deleteSubscriber( + topicId = "[TOPIC_ID]", + subscriberId = "[SUBSCRIBER_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/create-file.md b/docs/examples/kotlin/storage/create-file.md index 7bb79ac..19eae0f 100644 --- a/docs/examples/kotlin/storage/create-file.md +++ b/docs/examples/kotlin/storage/create-file.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.models.InputFile import io.appwrite.services.Storage @@ -12,4 +13,4 @@ val response = storage.createFile( bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]", file = InputFile.fromPath("file.png"), -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/delete-file.md b/docs/examples/kotlin/storage/delete-file.md index 9430d7e..c64e8dc 100644 --- a/docs/examples/kotlin/storage/delete-file.md +++ b/docs/examples/kotlin/storage/delete-file.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) @@ -9,5 +10,5 @@ val storage = Storage(client) val response = storage.deleteFile( bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]" -) + fileId = "[FILE_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file-download.md b/docs/examples/kotlin/storage/get-file-download.md index 85bd22c..07ebcc0 100644 --- a/docs/examples/kotlin/storage/get-file-download.md +++ b/docs/examples/kotlin/storage/get-file-download.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) @@ -7,7 +8,7 @@ val client = Client(context) val storage = Storage(client) -val result = storage.getFileDownload( +val result =storage.getFileDownload( bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]" -) + fileId = "[FILE_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file-preview.md b/docs/examples/kotlin/storage/get-file-preview.md index c5bbdef..b5995ae 100644 --- a/docs/examples/kotlin/storage/get-file-preview.md +++ b/docs/examples/kotlin/storage/get-file-preview.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) @@ -7,7 +8,7 @@ val client = Client(context) val storage = Storage(client) -val result = storage.getFilePreview( +val result =storage.getFilePreview( bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file-view.md b/docs/examples/kotlin/storage/get-file-view.md index 7e7589c..82b55c2 100644 --- a/docs/examples/kotlin/storage/get-file-view.md +++ b/docs/examples/kotlin/storage/get-file-view.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) @@ -7,7 +8,7 @@ val client = Client(context) val storage = Storage(client) -val result = storage.getFileView( +val result =storage.getFileView( bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]" -) + fileId = "[FILE_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file.md b/docs/examples/kotlin/storage/get-file.md index 8fb6e24..9c1abd4 100644 --- a/docs/examples/kotlin/storage/get-file.md +++ b/docs/examples/kotlin/storage/get-file.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) @@ -9,5 +10,5 @@ val storage = Storage(client) val response = storage.getFile( bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]" -) + fileId = "[FILE_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/list-files.md b/docs/examples/kotlin/storage/list-files.md index 191a3cc..575a8b9 100644 --- a/docs/examples/kotlin/storage/list-files.md +++ b/docs/examples/kotlin/storage/list-files.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) @@ -9,4 +10,4 @@ val storage = Storage(client) val response = storage.listFiles( bucketId = "[BUCKET_ID]", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/update-file.md b/docs/examples/kotlin/storage/update-file.md index 005270f..75585fa 100644 --- a/docs/examples/kotlin/storage/update-file.md +++ b/docs/examples/kotlin/storage/update-file.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) @@ -10,4 +11,4 @@ val storage = Storage(client) val response = storage.updateFile( bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/create-membership.md b/docs/examples/kotlin/teams/create-membership.md index 4d1de49..231a991 100644 --- a/docs/examples/kotlin/teams/create-membership.md +++ b/docs/examples/kotlin/teams/create-membership.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -10,4 +11,4 @@ val teams = Teams(client) val response = teams.createMembership( teamId = "[TEAM_ID]", roles = listOf(), -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/create.md b/docs/examples/kotlin/teams/create.md index 5e70bd8..dd1125c 100644 --- a/docs/examples/kotlin/teams/create.md +++ b/docs/examples/kotlin/teams/create.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -10,4 +11,4 @@ val teams = Teams(client) val response = teams.create( teamId = "[TEAM_ID]", name = "[NAME]", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/delete-membership.md b/docs/examples/kotlin/teams/delete-membership.md index 04ef5d3..3f165a7 100644 --- a/docs/examples/kotlin/teams/delete-membership.md +++ b/docs/examples/kotlin/teams/delete-membership.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -9,5 +10,5 @@ val teams = Teams(client) val response = teams.deleteMembership( teamId = "[TEAM_ID]", - membershipId = "[MEMBERSHIP_ID]" -) + membershipId = "[MEMBERSHIP_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/delete.md b/docs/examples/kotlin/teams/delete.md index 7d58960..756e91f 100644 --- a/docs/examples/kotlin/teams/delete.md +++ b/docs/examples/kotlin/teams/delete.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -8,5 +9,5 @@ val client = Client(context) val teams = Teams(client) val response = teams.delete( - teamId = "[TEAM_ID]" -) + teamId = "[TEAM_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/get-membership.md b/docs/examples/kotlin/teams/get-membership.md index 653bd52..7c5d286 100644 --- a/docs/examples/kotlin/teams/get-membership.md +++ b/docs/examples/kotlin/teams/get-membership.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -9,5 +10,5 @@ val teams = Teams(client) val response = teams.getMembership( teamId = "[TEAM_ID]", - membershipId = "[MEMBERSHIP_ID]" -) + membershipId = "[MEMBERSHIP_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/get-prefs.md b/docs/examples/kotlin/teams/get-prefs.md index bfd8f75..2953dcf 100644 --- a/docs/examples/kotlin/teams/get-prefs.md +++ b/docs/examples/kotlin/teams/get-prefs.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -8,5 +9,5 @@ val client = Client(context) val teams = Teams(client) val response = teams.getPrefs( - teamId = "[TEAM_ID]" -) + teamId = "[TEAM_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/get.md b/docs/examples/kotlin/teams/get.md index 72aea07..63cdd05 100644 --- a/docs/examples/kotlin/teams/get.md +++ b/docs/examples/kotlin/teams/get.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -8,5 +9,5 @@ val client = Client(context) val teams = Teams(client) val response = teams.get( - teamId = "[TEAM_ID]" -) + teamId = "[TEAM_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/list-memberships.md b/docs/examples/kotlin/teams/list-memberships.md index 53bd6f3..c82fa52 100644 --- a/docs/examples/kotlin/teams/list-memberships.md +++ b/docs/examples/kotlin/teams/list-memberships.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -9,4 +10,4 @@ val teams = Teams(client) val response = teams.listMemberships( teamId = "[TEAM_ID]", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/list.md b/docs/examples/kotlin/teams/list.md index 57c5fe8..f0f4af2 100644 --- a/docs/examples/kotlin/teams/list.md +++ b/docs/examples/kotlin/teams/list.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -8,4 +9,4 @@ val client = Client(context) val teams = Teams(client) val response = teams.list( -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-membership-status.md b/docs/examples/kotlin/teams/update-membership-status.md index 33de006..50f04a2 100644 --- a/docs/examples/kotlin/teams/update-membership-status.md +++ b/docs/examples/kotlin/teams/update-membership-status.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -11,5 +12,5 @@ val response = teams.updateMembershipStatus( teamId = "[TEAM_ID]", membershipId = "[MEMBERSHIP_ID]", userId = "[USER_ID]", - secret = "[SECRET]" -) + secret = "[SECRET]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-membership.md b/docs/examples/kotlin/teams/update-membership.md index 40005ed..9990cc4 100644 --- a/docs/examples/kotlin/teams/update-membership.md +++ b/docs/examples/kotlin/teams/update-membership.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -10,5 +11,5 @@ val teams = Teams(client) val response = teams.updateMembership( teamId = "[TEAM_ID]", membershipId = "[MEMBERSHIP_ID]", - roles = listOf() -) + roles = listOf(), +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-name.md b/docs/examples/kotlin/teams/update-name.md index 59c6812..1332fe1 100644 --- a/docs/examples/kotlin/teams/update-name.md +++ b/docs/examples/kotlin/teams/update-name.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -9,5 +10,5 @@ val teams = Teams(client) val response = teams.updateName( teamId = "[TEAM_ID]", - name = "[NAME]" -) + name = "[NAME]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-prefs.md b/docs/examples/kotlin/teams/update-prefs.md index 6a89ac7..5f77c6c 100644 --- a/docs/examples/kotlin/teams/update-prefs.md +++ b/docs/examples/kotlin/teams/update-prefs.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -9,5 +10,5 @@ val teams = Teams(client) val response = teams.updatePrefs( teamId = "[TEAM_ID]", - prefs = mapOf( "a" to "b" ) -) + prefs = mapOf( "a" to "b" ), +) \ No newline at end of file diff --git a/docs/examples/kotlin/users/delete-authenticator.md b/docs/examples/kotlin/users/delete-authenticator.md new file mode 100644 index 0000000..9c36173 --- /dev/null +++ b/docs/examples/kotlin/users/delete-authenticator.md @@ -0,0 +1,16 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Users +import io.appwrite.enums.AuthenticatorProvider + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val users = Users(client) + +val response = users.deleteAuthenticator( + userId = "[USER_ID]", + provider = AuthenticatorProvider.TOTP, + otp = "[OTP]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/users/list-providers.md b/docs/examples/kotlin/users/list-providers.md new file mode 100644 index 0000000..008cf93 --- /dev/null +++ b/docs/examples/kotlin/users/list-providers.md @@ -0,0 +1,13 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Users + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val users = Users(client) + +val response = users.listProviders( + userId = "[USER_ID]", +) \ No newline at end of file diff --git a/example-java/.gitignore b/example-java/.gitignore deleted file mode 100644 index 42afabf..0000000 --- a/example-java/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build \ No newline at end of file diff --git a/example-java/build.gradle b/example-java/build.gradle deleted file mode 100644 index 774d3ba..0000000 --- a/example-java/build.gradle +++ /dev/null @@ -1,39 +0,0 @@ -plugins { - id 'com.android.application' -} - -android { - compileSdkVersion 33 - - defaultConfig { - applicationId "io.appwrite.example_java" - minSdkVersion 23 - targetSdkVersion 33 - versionCode 1 - versionName "1.0" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } -} - -dependencies { - implementation project(path: ':library') - - implementation 'androidx.appcompat:appcompat:1.6.0' - implementation 'com.google.android.material:material:1.8.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' -} \ No newline at end of file diff --git a/example-java/src/main/AndroidManifest.xml b/example-java/src/main/AndroidManifest.xml deleted file mode 100644 index 0276c9c..0000000 --- a/example-java/src/main/AndroidManifest.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file 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 deleted file mode 100644 index 04f46b3..0000000 --- a/example-java/src/main/java/io/appwrite/example_java/MainActivity.java +++ /dev/null @@ -1,34 +0,0 @@ -package io.appwrite.example_java; - -import android.os.Bundle; -import android.util.Log; - -import androidx.appcompat.app.AppCompatActivity; - -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -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://demo.appwrite.io/v1") - .setProject("6070749e6acd4"); - - Account account = new Account(client); - - 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-java/src/main/res/drawable/ic_launcher_background.xml b/example-java/src/main/res/drawable/ic_launcher_background.xml deleted file mode 100644 index 07d5da9..0000000 --- a/example-java/src/main/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example-java/src/main/res/drawable/ic_launcher_foreground.xml b/example-java/src/main/res/drawable/ic_launcher_foreground.xml deleted file mode 100644 index 2b068d1..0000000 --- a/example-java/src/main/res/drawable/ic_launcher_foreground.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/example-java/src/main/res/layout/activity_main.xml b/example-java/src/main/res/layout/activity_main.xml deleted file mode 100644 index 4fc2444..0000000 --- a/example-java/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/example-java/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/example-java/src/main/res/mipmap-anydpi-v26/ic_launcher.xml deleted file mode 100644 index eca70cf..0000000 --- a/example-java/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/example-java/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/example-java/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml deleted file mode 100644 index eca70cf..0000000 --- a/example-java/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/example-java/src/main/res/values/colors.xml b/example-java/src/main/res/values/colors.xml deleted file mode 100644 index f8c6127..0000000 --- a/example-java/src/main/res/values/colors.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - #FFBB86FC - #FF6200EE - #FF3700B3 - #FF03DAC5 - #FF018786 - #FF000000 - #FFFFFFFF - \ No newline at end of file diff --git a/example-java/src/main/res/values/strings.xml b/example-java/src/main/res/values/strings.xml deleted file mode 100644 index 71e50b3..0000000 --- a/example-java/src/main/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - Example Java - \ No newline at end of file diff --git a/example-java/src/main/res/values/themes.xml b/example-java/src/main/res/values/themes.xml deleted file mode 100644 index dde245d..0000000 --- a/example-java/src/main/res/values/themes.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - \ No newline at end of file diff --git a/example/build.gradle b/example/build.gradle index 62a34ed..e57d59b 100644 --- a/example/build.gradle +++ b/example/build.gradle @@ -1,15 +1,18 @@ plugins { id 'com.android.application' id 'kotlin-android' + id 'kotlin-kapt' } android { - compileSdkVersion 33 + namespace "io.appwrite.android" + + compileSdkVersion 34 defaultConfig { applicationId "io.appwrite.android" minSdkVersion 21 - targetSdkVersion 33 + targetSdkVersion 34 versionCode 1 versionName "1.0" @@ -39,19 +42,19 @@ dependencies { implementation project(path: ':library') implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.core:core-ktx:1.9.0' - implementation 'androidx.appcompat:appcompat:1.6.0' - implementation 'com.google.android.material:material:1.8.0' + implementation 'androidx.core:core-ktx:1.12.0' + implementation 'androidx.appcompat:appcompat:1.6.1' + implementation 'com.google.android.material:material:1.11.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3' - implementation "androidx.fragment:fragment-ktx:1.5.5" - implementation 'androidx.navigation:navigation-ui-ktx:2.5.3' - implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1' - implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1' - implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3' - implementation 'androidx.navigation:navigation-ui-ktx:2.5.3' - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1" + implementation 'androidx.navigation:navigation-fragment-ktx:2.7.6' + implementation "androidx.fragment:fragment-ktx:1.6.2" + implementation 'androidx.navigation:navigation-ui-ktx:2.7.6' + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.7.0' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0' + implementation 'androidx.navigation:navigation-fragment-ktx:2.7.6' + implementation 'androidx.navigation:navigation-ui-ktx:2.7.6' + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1" testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' diff --git a/example/src/main/AndroidManifest.xml b/example/src/main/AndroidManifest.xml index e3c2421..5c2e7b0 100644 --- a/example/src/main/AndroidManifest.xml +++ b/example/src/main/AndroidManifest.xml @@ -3,12 +3,14 @@ package="io.appwrite.android"> + android:theme="@style/Theme.AppwriteAndroidSDK" + android:usesCleartextTraffic="true"> + @@ -24,6 +26,13 @@ + + + + + + + \ No newline at end of file diff --git a/example/src/main/java/io/appwrite/android/ui/accounts/AccountsFragment.kt b/example/src/main/java/io/appwrite/android/ui/accounts/AccountsFragment.kt index a31cced..7e590d5 100644 --- a/example/src/main/java/io/appwrite/android/ui/accounts/AccountsFragment.kt +++ b/example/src/main/java/io/appwrite/android/ui/accounts/AccountsFragment.kt @@ -34,34 +34,30 @@ class AccountsFragment : Fragment() { binding.login.setOnClickListener{ viewModel.onLogin(binding.email.text, binding.password.text) } - binding.signup.setOnClickListener{ viewModel.onSignup(binding.email.text, binding.password.text, binding.name.text) } - binding.getUser.setOnClickListener{ viewModel.getUser() } - binding.oAuth.setOnClickListener{ viewModel.oAuthLogin(activity as ComponentActivity) } - binding.logout.setOnClickListener{ viewModel.logout() } - viewModel.error.observe(viewLifecycleOwner, Observer { event -> - event?.getContentIfNotHandled()?.let { // Only proceed if the event has never been handled - Toast.makeText(requireContext(), it.message , Toast.LENGTH_SHORT).show() + viewModel.error.observe(viewLifecycleOwner) { event -> + event?.getContentIfNotHandled()?.let { + Toast.makeText(requireContext(), it.message, Toast.LENGTH_SHORT).show() } - }) + } - viewModel.response.observe(viewLifecycleOwner, Observer { event -> + viewModel.response.observe(viewLifecycleOwner) { event -> event?.getContentIfNotHandled()?.let { binding.responseTV.setText(it) } - }) + } return binding.root } 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 ede86d3..0e558f1 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 @@ -3,8 +3,10 @@ package io.appwrite.android.ui.accounts import android.text.Editable import androidx.activity.ComponentActivity import androidx.lifecycle.* +import io.appwrite.ID import io.appwrite.android.utils.Client.client import io.appwrite.android.utils.Event +import io.appwrite.enums.OAuthProvider import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.toJson import io.appwrite.services.Account @@ -29,7 +31,10 @@ class AccountsViewModel : ViewModel() { fun onLogin(email: Editable, password: Editable) { viewModelScope.launch { try { - val session = accountService.createEmailSession(email.toString(), password.toString()) + val session = accountService.createEmailPasswordSession( + email.toString(), + password.toString() + ) _response.postValue(Event(session.toJson())) } catch (e: AppwriteException) { _error.postValue(Event(e)) @@ -41,8 +46,12 @@ class AccountsViewModel : ViewModel() { fun onSignup(email: Editable, password: Editable, name: Editable) { viewModelScope.launch { try { - val user = - accountService.create(email.toString(), password.toString(), name.toString()) + val user = accountService.create( + ID.unique(), + email.toString(), + password.toString(), + name.toString() + ) _response.postValue(Event(user.toJson())) } catch (e: AppwriteException) { _error.postValue(Event(e)) @@ -56,7 +65,7 @@ class AccountsViewModel : ViewModel() { try { accountService.createOAuth2Session( activity, - "facebook", + OAuthProvider.FACEBOOK, "appwrite-callback-6070749e6acd4://demo.appwrite.io/auth/oauth2/success", "appwrite-callback-6070749e6acd4://demo.appwrite.io/auth/oauth2/failure" ) diff --git a/example/src/main/java/io/appwrite/android/utils/Client.kt b/example/src/main/java/io/appwrite/android/utils/Client.kt index 66ce681..027b718 100644 --- a/example/src/main/java/io/appwrite/android/utils/Client.kt +++ b/example/src/main/java/io/appwrite/android/utils/Client.kt @@ -8,13 +8,8 @@ object Client { fun create(context: Context) { client = Client(context) - .setEndpoint("https://demo.appwrite.io/v1") - .setProject("6070749e6acd4") - - /* Useful when testing locally */ -// client = Client(context) -// .setEndpoint("https://192.168.1.35/v1") -// .setProject("60bdbc911784e") -// .setSelfSigned(true) + .setEndpoint("http://192.168.4.24/v1") + .setProject("65a8e2b4632c04b1f5da") + .setSelfSigned(true) } } \ No newline at end of file diff --git a/example/src/main/res/layout/fragment_account.xml b/example/src/main/res/layout/fragment_account.xml index 2fb34c9..4173be1 100644 --- a/example/src/main/res/layout/fragment_account.xml +++ b/example/src/main/res/layout/fragment_account.xml @@ -57,6 +57,7 @@ android:layout_height="wrap_content" android:layout_marginTop="16dp" android:hint="name" + android:text="Tester" android:inputType="text" app:layout_constraintStart_toStartOf="@id/password" app:layout_constraintTop_toBottomOf="@id/password" /> diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 85e684f..ebd754f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Tue Jun 01 15:55:54 IST 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/library/build.gradle b/library/build.gradle index baa5b1e..b361708 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -22,11 +22,17 @@ ext { version PUBLISH_VERSION android { - compileSdkVersion(33) + namespace PUBLISH_GROUP_ID + + compileSdkVersion(34) + + buildFeatures { + buildConfig true + } defaultConfig { minSdkVersion(21) - targetSdkVersion(33) + targetSdkVersion(34) versionCode = 1 versionName = "1.0" buildConfigField "String", "SDK_VERSION", "\"${PUBLISH_VERSION}\"" @@ -43,10 +49,6 @@ android { ) } } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - } kotlinOptions { jvmTarget = "1.8" } @@ -54,27 +56,31 @@ android { dependencies { implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version") - api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1") - api("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1") + api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1") + api("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1") - api(platform("com.squareup.okhttp3:okhttp-bom:4.10.0")) + api(platform("com.squareup.okhttp3:okhttp-bom:4.12.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.9.0") + implementation("com.google.code.gson:gson:2.10.1") + + api(platform("com.google.firebase:firebase-bom:32.7.0")) + api("com.google.firebase:firebase-messaging") - implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.5.1") - implementation("androidx.lifecycle:lifecycle-common-java8:2.5.1") - implementation("androidx.appcompat:appcompat:1.6.0") - implementation("androidx.fragment:fragment-ktx:1.5.5") - implementation("androidx.activity:activity-ktx:1.6.1") - implementation("androidx.browser:browser:1.4.0") + implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0") + implementation("androidx.lifecycle:lifecycle-common-java8:2.7.0") + implementation("androidx.appcompat:appcompat:1.6.1") + implementation("androidx.fragment:fragment-ktx:1.6.2") + implementation("androidx.activity:activity-ktx:1.8.2") + implementation("androidx.browser:browser:1.7.0") + implementation("androidx.core:core-ktx:1.12.0") - testImplementation 'junit:junit:4.13.2' - testImplementation "androidx.test.ext:junit-ktx:1.1.5" - testImplementation "androidx.test:core-ktx:1.5.0" - testImplementation "org.robolectric:robolectric:4.5.1" - testApi("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.1") + testImplementation("junit:junit:4.13.2") + testImplementation("androidx.test.ext:junit-ktx:1.1.5") + testImplementation("androidx.test:core-ktx:1.5.0") + testImplementation("org.robolectric:robolectric:4.5.1") + testApi("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.1") } apply from: "${rootProject.projectDir}/scripts/publish-module.gradle" \ No newline at end of file diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml index b0ab63a..899321d 100644 --- a/library/src/main/AndroidManifest.xml +++ b/library/src/main/AndroidManifest.xml @@ -1,8 +1,7 @@ - + - + + \ 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 94f82b6..eeda5ce 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -1,13 +1,13 @@ package io.appwrite import android.content.Context +import android.content.Intent import android.content.pm.PackageManager import com.google.gson.GsonBuilder import com.google.gson.reflect.TypeToken -import io.appwrite.appwrite.BuildConfig +import io.appwrite.cookies.ListenableCookieJar import io.appwrite.cookies.stores.SharedPreferencesCookieStore import io.appwrite.exceptions.AppwriteException -import io.appwrite.extensions.fromJson import io.appwrite.json.PreciseNumberAdapter import io.appwrite.models.InputFile import io.appwrite.models.UploadProgress @@ -30,7 +30,6 @@ import java.net.CookieManager import java.net.CookiePolicy import java.security.SecureRandom import java.security.cert.X509Certificate -import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLContext import javax.net.ssl.SSLSocketFactory import javax.net.ssl.TrustManager @@ -40,13 +39,15 @@ import kotlin.coroutines.resume class Client @JvmOverloads constructor( context: Context, - var endPoint: String = "https://HOSTNAME/v1", - var endPointRealtime: String? = null, + var endpoint: String = "https://HOSTNAME/v1", + var endpointRealtime: String? = null, private var selfSigned: Boolean = false ) : CoroutineScope { companion object { - const val CHUNK_SIZE = 5*1024*1024; // 5MB + internal const val CHUNK_SIZE = 5*1024*1024; // 5MB + internal const val GLOBAL_PREFS = "io.appwrite" + internal const val COOKIE_PREFS = "myCookie" } override val coroutineContext: CoroutineContext @@ -59,16 +60,16 @@ class Client @JvmOverloads constructor( PreciseNumberAdapter() ).create() - lateinit var http: OkHttpClient + internal lateinit var http: OkHttpClient - private val headers: MutableMap + internal val headers: MutableMap val config: MutableMap - private val cookieJar = CookieManager( - SharedPreferencesCookieStore(context, "myCookie"), + internal val cookieJar = ListenableCookieJar(CookieManager( + SharedPreferencesCookieStore(context.getSharedPreferences(COOKIE_PREFS, Context.MODE_PRIVATE)), CookiePolicy.ACCEPT_ALL - ) + )) private val appVersion by lazy { try { @@ -88,12 +89,18 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "4.0.1", + "x-sdk-version" to "5.0.0-rc.1", "x-appwrite-response-format" to "1.4.0" ) config = mutableMapOf() setSelfSigned(selfSigned) + + NotificationHandler.client = this + + context.startService(Intent(context, NotificationHandler::class.java).apply { + action = NotificationHandler.ACTION_CLIENT_INIT + }) } /** @@ -139,6 +146,21 @@ class Client @JvmOverloads constructor( return this } + /** + * Set Session + * + * The user session to authenticate with + * + * @param {string} session + * + * @return this + */ + fun setSession(value: String): Client { + config["session"] = value + addHeader("x-appwrite-session", value) + return this + } + /** * Set self Signed * @@ -151,7 +173,7 @@ class Client @JvmOverloads constructor( val builder = OkHttpClient() .newBuilder() - .cookieJar(JavaNetCookieJar(cookieJar)) + .cookieJar(cookieJar) if (!selfSigned) { http = builder.build() @@ -181,7 +203,7 @@ class Client @JvmOverloads constructor( // Create an ssl socket factory with our all-trusting manager val sslSocketFactory: SSLSocketFactory = sslContext.socketFactory builder.sslSocketFactory(sslSocketFactory, trustAllCerts[0] as X509TrustManager) - builder.hostnameVerifier(HostnameVerifier { _, _ -> true }) + builder.hostnameVerifier { _, _ -> true } http = builder.build() } catch (e: Exception) { @@ -198,11 +220,11 @@ class Client @JvmOverloads constructor( * * @return this */ - fun setEndpoint(endPoint: String): Client { - this.endPoint = endPoint + fun setEndpoint(endpoint: String): Client { + this.endpoint = endpoint - if (this.endPointRealtime == null && endPoint.startsWith("http")) { - this.endPointRealtime = endPoint.replaceFirst("http", "ws") + if (this.endpointRealtime == null && endpoint.startsWith("http")) { + this.endpointRealtime = endpoint.replaceFirst("http", "ws") } return this @@ -215,8 +237,20 @@ class Client @JvmOverloads constructor( * * @return this */ - fun setEndpointRealtime(endPoint: String): Client { - this.endPointRealtime = endPoint + fun setEndpointRealtime(endpoint: String): Client { + this.endpointRealtime = endpoint + return this + } + + /** + * Set push provider ID + * + * @param endpoint + * + * @return this + */ + fun setPushProviderId(providerId: String): Client { + NotificationHandler.providerId = providerId return this } @@ -258,7 +292,7 @@ class Client @JvmOverloads constructor( .addAll(headers.toHeaders()) .build() - val httpBuilder = (endPoint + path).toHttpUrl().newBuilder() + val httpBuilder = (endpoint + path).toHttpUrl().newBuilder() if ("GET" == method) { filteredParams.forEach { @@ -436,14 +470,14 @@ class Client @JvmOverloads constructor( ) offset += CHUNK_SIZE - headers["x-appwrite-id"] = result!!["\$id"].toString() + headers["x-appwrite-id"] = result["\$id"].toString() onProgress?.invoke( UploadProgress( - id = result!!["\$id"].toString(), + id = result["\$id"].toString(), progress = offset.coerceAtMost(size).toDouble() / size * 100, sizeUploaded = offset.coerceAtMost(size), - chunksTotal = result!!["chunksTotal"].toString().toInt(), - chunksUploaded = result!!["chunksUploaded"].toString().toInt(), + chunksTotal = result["chunksTotal"].toString().toInt(), + chunksUploaded = result["chunksUploaded"].toString().toInt(), ) ) } diff --git a/library/src/main/java/io/appwrite/NotificationHandler.kt b/library/src/main/java/io/appwrite/NotificationHandler.kt new file mode 100644 index 0000000..db007b8 --- /dev/null +++ b/library/src/main/java/io/appwrite/NotificationHandler.kt @@ -0,0 +1,410 @@ +package io.appwrite + +import android.Manifest +import android.app.NotificationChannel +import android.app.NotificationManager +import android.app.PendingIntent +import android.content.Context +import android.content.Intent +import android.content.SharedPreferences +import android.content.pm.PackageManager +import android.os.Build +import android.util.Log +import androidx.annotation.RequiresApi +import androidx.core.app.NotificationCompat +import com.google.android.gms.tasks.OnCompleteListener +import com.google.firebase.messaging.FirebaseMessaging +import com.google.firebase.messaging.FirebaseMessagingService +import com.google.firebase.messaging.RemoteMessage +import io.appwrite.cookies.CookieListener +import io.appwrite.exceptions.AppwriteException +import io.appwrite.extensions.fromJson +import io.appwrite.extensions.onNotificationReceived +import io.appwrite.extensions.toJson +import io.appwrite.models.Notification +import io.appwrite.models.Target +import io.appwrite.models.User +import io.appwrite.services.Account +import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.suspendCancellableCoroutine +import kotlinx.coroutines.sync.Mutex +import kotlinx.coroutines.sync.withLock +import okhttp3.Cookie +import okhttp3.Headers +import okhttp3.MediaType.Companion.toMediaType +import okhttp3.OkHttpClient +import okhttp3.Request +import okhttp3.RequestBody +import okhttp3.RequestBody.Companion.toRequestBody +import okhttp3.internal.cookieToString +import java.io.IOException +import kotlin.properties.Delegates + +class NotificationHandler : FirebaseMessagingService() { + + companion object { + internal const val ACTION_CLIENT_INIT = "io.appwrite.ACTION_CLIENT_INIT" + internal const val LISTENER_KEY = "io.appwrite.NotificationHandler" + + internal val httpClient = OkHttpClient() + + internal var client: Client? = null + internal var account: Account? = null + internal var providerId: String? = null + + internal var cookieListener: CookieListener? = null + + /** + * Should notifications be automatically displayed if the app is in the foreground + */ + var displayForeground = true + + /** + * The icon to display in the notification + */ + var displayIcon by Delegates.notNull() + + /** + * Should the notification be automatically canceled when the user clicks on it + */ + var autoCancel = false + + /** + * The intent to fire when the user clicks on the notification + */ + var contentIntent: PendingIntent? = null + + /** + * The channel id to use for the notification + */ + @RequiresApi(Build.VERSION_CODES.N) + var channelId = "io.appwrite.notifications" + + /** + * The channel name to use for the notification + */ + @RequiresApi(Build.VERSION_CODES.N) + var channelName = "All Notifications" + + /** + * The channel description to use for the notification + */ + @RequiresApi(Build.VERSION_CODES.N) + var channelDescription = "All notifications" + + /** + * The channel importance to use for the notification + */ + @RequiresApi(Build.VERSION_CODES.N) + var channelImportance = NotificationManager.IMPORTANCE_DEFAULT + } + + private lateinit var mutex: Mutex + + private lateinit var globalPrefs: SharedPreferences + + private var existingCookies: List = listOf() + private var newCookies: List = listOf() + + override fun getStartCommandIntent(originalIntent: Intent?): Intent { + if (originalIntent?.action == ACTION_CLIENT_INIT) { + return originalIntent + } + + return super.getStartCommandIntent(originalIntent) + } + + override fun handleIntent(intent: Intent?) { + if (intent?.action == ACTION_CLIENT_INIT) { + onClientInit() + return + } + + super.handleIntent(intent) + } + + override fun onCreate() { + super.onCreate() + + globalPrefs = applicationContext.getSharedPreferences( + Client.GLOBAL_PREFS, Context.MODE_PRIVATE + ) + + displayIcon = resources.getIdentifier( + "ic_launcher_foreground", "drawable", packageName + ) + + mutex = Mutex() + + if (cookieListener == null) { + cookieListener = { existing, new -> + FirebaseMessaging.getInstance().token.addOnCompleteListener(OnCompleteListener { task -> + if (!task.isSuccessful) { + Log.w(javaClass.name, "Fetching FCM registration token failed", task.exception) + return@OnCompleteListener + } + + val token = task.result + if (token.isNullOrEmpty()) { + return@OnCompleteListener + } + + existingCookies = existing + newCookies = new + + onNewToken(token) + }) + } + } + + if (client != null) { + client?.cookieJar?.onSave(LISTENER_KEY, cookieListener!!) + } + } + + override fun onNewToken(token: String) { + runBlocking { + mutex.withLock { + pushToken(token) + } + } + } + + override fun onMessageReceived(message: RemoteMessage) { + super.onMessageReceived(message) + + // Fire callbacks before display so handler can be configured if needed + onNotificationReceived( + Notification( + title = message.notification?.title ?: "", + body = message.notification?.body ?: "", + clickAction = message.notification?.clickAction ?: "", + color = message.notification?.color ?: "", + icon = message.notification?.icon ?: "", + imageURL = message.notification?.imageUrl?.toString() ?: "", + sound = message.notification?.sound ?: "", + data = message.data + ) + ) + + val notificationManager = + getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + val channel = NotificationChannel( + channelId, channelName, channelImportance + ).apply { + description = channelDescription + } + + // Recreate is a no-op if the channel already exists + notificationManager.createNotificationChannel(channel) + } + + if (message.notification != null && displayForeground) { + val builder = NotificationCompat.Builder(this, "io.appwrite.notifications") + .setContentTitle(message.notification?.title) + .setContentText(message.notification?.body) + .setPriority(NotificationCompat.PRIORITY_DEFAULT).setAutoCancel(autoCancel) + .setContentIntent(contentIntent) + + if (displayIcon != 0) { + builder.setSmallIcon(displayIcon) + } + + val notification = builder.build() + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + val hasPermission = packageManager.checkPermission( + Manifest.permission.POST_NOTIFICATIONS, + packageName + ) == PackageManager.PERMISSION_GRANTED + + if (!hasPermission) { + Log.w(javaClass.name, "Permission denied, make sure you have requested the POST_NOTIFICATIONS permission") + } + } + + notificationManager.notify(message.hashCode(), notification) + } + } + + private fun onClientInit() { + if (client == null) { + return + } + + if (account == null) { + account = Account(client!!) + } + + client?.cookieJar?.onSave(LISTENER_KEY, cookieListener!!) + } + + private suspend fun pushToken(token: String) { + if (client == null) { + return + } + + val currentToken = globalPrefs.getString("fcmToken", "") ?: "" + var currentTargetId = globalPrefs.getString("targetId", "") ?: "" + val existingUser: User>? + try { + existingUser = if (existingCookies.isEmpty() && newCookies.isNotEmpty()) { + request( + "GET", + "/account", + mapOf("cookie" to newCookies.joinToString("; ") { + cookieToString(it, true) + }) + ) + } else if (existingCookies.isNotEmpty()) { + request( + "GET", + "/account", + mapOf("cookie" to existingCookies.joinToString("; ") { + cookieToString(it, true) + }) + ) + } else { + account?.get() + } + } catch (ex: AppwriteException) { + Log.d(javaClass.name, "No existing user") + return + } + + if (existingUser == null) { + Log.d(javaClass.name, "No existing user") + return + } + + var newUser: User>? = null + if (newCookies.isNotEmpty()) { + newUser = request( + "GET", + "/account", + mapOf("cookie" to newCookies.joinToString("; ") { + cookieToString(it, true) + }) + ) + Log.d(javaClass.name, "New user: ${newUser!!.id}") + } + + if ( + token == currentToken + && (existingCookies.isNotEmpty() && existingUser.id == newUser?.id) + ) { + Log.d(javaClass.name, "Token and user are the same") + return + } + + globalPrefs.edit().putString("fcmToken", token).apply() + + try { + if (existingCookies.isNotEmpty() && existingUser.id != newUser?.id) { + Log.d(javaClass.name, "User has changed") + if (currentTargetId.isNotEmpty()) { + Log.d(javaClass.name, "Deleting existing target") + request( + "DELETE", + "/account/targets/$currentTargetId/push", + mapOf("cookie" to existingCookies.joinToString("; ") { + cookieToString(it, true) + }) + ) + globalPrefs.edit().remove("targetId").apply() + currentTargetId = "" + } + } + } catch (ex: AppwriteException) { + Log.e(javaClass.name, "Failed to delete existing target", ex) + } + + try { + val target: Target? + + if ((currentTargetId.isEmpty() && existingCookies.isEmpty()) || existingUser.id != newUser?.id) { + Log.d(javaClass.name, "Creating new target") + val params = mutableMapOf( + "targetId" to ID.unique(), + "identifier" to token + ) + if (providerId != null) { + params["providerId"] = providerId!! + } + target = request( + "POST", + "/account/targets/push", + mapOf("cookie" to newCookies.joinToString("; ") { + cookieToString(it, true) + }), + params.toJson().toRequestBody("application/json".toMediaType()) + ) + Log.d(javaClass.name, "New target: ${target?.id}") + } else { + Log.d(javaClass.name, "Updating existing target") + target = account?.updatePushTarget(currentTargetId, token) + Log.d(javaClass.name, "Updated target: ${target?.id}") + } + + globalPrefs.edit().putString("targetId", target?.id).apply() + } catch (ex: AppwriteException) { + Log.e(javaClass.name, "Failed to push token", ex) + } + + existingCookies = emptyList() + newCookies = emptyList() + Log.d(javaClass.name, "Token pushed") + } + + private suspend inline fun request( + method: String, + path: String, + headers: Map, + body: RequestBody? = null + ): T? { + val headerBuilder = Headers.Builder() + + for ((key, value) in client?.headers ?: mapOf()) { + headerBuilder.add(key, value) + } + + for ((key, value) in headers) { + headerBuilder.add(key, value) + } + + val request = Request.Builder() + .method(method, body) + .url(client?.endpoint + path) + .headers(headerBuilder.build()) + .build() + + try { + return suspendCancellableCoroutine { + httpClient + .newCall(request) + .enqueue(object : okhttp3.Callback { + override fun onFailure(call: okhttp3.Call, e: IOException) { + Log.e(javaClass.name, "Request failed", e) + it.resumeWith(Result.failure(e)) + } + override fun onResponse( + call: okhttp3.Call, + response: okhttp3.Response + ) { + if (response.isSuccessful) { + val bodyString = response.body?.string() + + it.resumeWith(Result.success(bodyString?.fromJson())) + } else { + it.resumeWith(Result.failure(IOException("Request failed with code ${response.code}"))) + } + } + }) + } + } catch (ex: IOException) { + return null + } + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/Query.kt b/library/src/main/java/io/appwrite/Query.kt index 7957865..6efbb11 100644 --- a/library/src/main/java/io/appwrite/Query.kt +++ b/library/src/main/java/io/appwrite/Query.kt @@ -1,60 +1,65 @@ package io.appwrite -class Query { - companion object { - fun equal(attribute: String, value: Any) = addQuery(attribute, "equal", value) +import io.appwrite.extensions.toJson +import io.appwrite.extensions.fromJson - fun notEqual(attribute: String, value: Any) = Query.addQuery(attribute, "notEqual", value) +class Query( + val method: String, + val attribute: String? = null, + val values: List? = null, +) { + override fun toString() = this.toJson() - fun lessThan(attribute: String, value: Any) = Query.addQuery(attribute, "lessThan", value) + companion object { + fun equal(attribute: String, value: Any) = Query("equal", attribute, parseValue(value)).toJson() - fun lessThanEqual(attribute: String, value: Any) = Query.addQuery(attribute, "lessThanEqual", value) + fun notEqual(attribute: String, value: Any) = Query("notEqual", attribute, parseValue(value)).toJson() - fun greaterThan(attribute: String, value: Any) = Query.addQuery(attribute, "greaterThan", value) + fun lessThan(attribute: String, value: Any) = Query("lessThan", attribute, parseValue(value)).toJson() - fun greaterThanEqual(attribute: String, value: Any) = Query.addQuery(attribute, "greaterThanEqual", value) - - fun search(attribute: String, value: String) = Query.addQuery(attribute, "search", value) + fun lessThanEqual(attribute: String, value: Any) = Query("lessThanEqual", attribute, parseValue(value)).toJson() - fun isNull(attribute: String) = "isNull(\"${attribute}\")" + fun greaterThan(attribute: String, value: Any) = Query("greaterThan", attribute, parseValue(value)).toJson() - fun isNotNull(attribute: String) = "isNotNull(\"${attribute}\")" + fun greaterThanEqual(attribute: String, value: Any) = Query("greaterThanEqual", attribute, parseValue(value)).toJson() - fun between(attribute: String, start: Int, end: Int) = "between(\"${attribute}\", ${start}, ${end})" + fun search(attribute: String, value: String) = Query("search", attribute, listOf(value)).toJson() - fun between(attribute: String, start: Double, end: Double) = "between(\"${attribute}\", ${start}, ${end})" + fun isNull(attribute: String) = Query("isNull", attribute).toJson() - fun between(attribute: String, start: String, end: String) = "between(\"${attribute}\", \"${start}\", \"${end}\")" + fun isNotNull(attribute: String) = Query("isNotNull", attribute).toJson() - fun startsWith(attribute: String, value: String) = Query.addQuery(attribute, "startsWith", value) + fun between(attribute: String, start: Any, end: Any) = Query("between", attribute, listOf(start, end)).toJson() - fun endsWith(attribute: String, value: String) = Query.addQuery(attribute, "endsWith", value) + fun startsWith(attribute: String, value: String) = Query("startsWith", attribute, listOf(value)).toJson() - fun select(attributes: List) = "select([${attributes.joinToString(",") { "\"$it\"" }}])" + fun endsWith(attribute: String, value: String) = Query("endsWith", attribute, listOf(value)).toJson() - fun orderAsc(attribute: String) = "orderAsc(\"${attribute}\")" + fun select(attributes: List) = Query("select", null, attributes).toJson() - fun orderDesc(attribute: String) = "orderDesc(\"${attribute}\")" + fun orderAsc(attribute: String) = Query("orderAsc", attribute).toJson() - fun cursorBefore(documentId: String) = "cursorBefore(\"${documentId}\")" + fun orderDesc(attribute: String) = Query("orderDesc", attribute).toJson() - fun cursorAfter(documentId: String) = "cursorAfter(\"${documentId}\")" + fun cursorBefore(documentId: String) = Query("cursorBefore", null, listOf(documentId)).toJson() - fun limit(limit: Int) = "limit(${limit})" + fun cursorAfter(documentId: String) = Query("cursorAfter", null, listOf(documentId)).toJson() - fun offset(offset: Int) = "offset(${offset})" + fun limit(limit: Int) = Query("limit", null, listOf(limit)).toJson() - private fun addQuery(attribute: String, method: String, value: Any): String { - return when (value) { - is List<*> -> "${method}(\"${attribute}\", [${value.map{it -> parseValues(it!!)}.joinToString(",")}])" - else -> "${method}(\"${attribute}\", [${Query.parseValues(value)}])" - } - } - private fun parseValues(value: Any): String { - return when (value) { - is String -> "\"${value}\"" - else -> "${value}" - } + fun offset(offset: Int) = Query("offset", null, listOf(offset)).toJson() + + fun contains(attribute: String, value: Any) = Query("contains", attribute, parseValue(value)).toJson() + + fun or(queries: List) = Query("or", null, queries.map { it.fromJson() }).toJson() + + fun and(queries: List) = Query("and", null, queries.map { it.fromJson() }).toJson() + + private fun parseValue(value: Any): List { + return when (value) { + is List<*> -> value as List + else -> listOf(value) + } + } } - } -} +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/cookies/ListenableCookieJar.kt b/library/src/main/java/io/appwrite/cookies/ListenableCookieJar.kt new file mode 100644 index 0000000..863eb42 --- /dev/null +++ b/library/src/main/java/io/appwrite/cookies/ListenableCookieJar.kt @@ -0,0 +1,119 @@ +package io.appwrite.cookies + +import okhttp3.Cookie +import okhttp3.CookieJar +import okhttp3.HttpUrl +import okhttp3.internal.cookieToString +import okhttp3.internal.delimiterOffset +import okhttp3.internal.platform.Platform +import okhttp3.internal.trimSubstring +import java.io.IOException +import java.net.CookieHandler +import java.net.HttpCookie +import java.util.Collections + +typealias CookieListener = (existing: List, new: List) -> Unit + +class ListenableCookieJar(private val cookieHandler: CookieHandler) : CookieJar { + + private val listeners: MutableMap = mutableMapOf() + + fun onSave(key: String, listener: CookieListener) { + listeners[key.hashCode()] = listener + } + + override fun saveFromResponse(url: HttpUrl, cookies: List) { + val existingCookies = loadForRequest(url) + + listeners.values.forEach { it(existingCookies, cookies) } + + val cookieStrings = mutableListOf() + for (cookie in cookies) { + cookieStrings.add(cookieToString(cookie, true)) + } + val multimap = mapOf("Set-Cookie" to cookieStrings) + try { + cookieHandler.put(url.toUri(), multimap) + } catch (e: IOException) { + Platform.get().log( + "Saving cookies failed for " + url.resolve("/...")!!, + Platform.WARN, e + ) + } + } + + override fun loadForRequest(url: HttpUrl): List { + val cookieHeaders = try { + cookieHandler.get(url.toUri(), emptyMap>()) + } catch (e: IOException) { + Platform.get().log( + "Loading cookies failed for " + url.resolve("/...")!!, + Platform.WARN, e + ) + return emptyList() + } + + var cookies: MutableList? = null + for ((key, value) in cookieHeaders) { + if (("Cookie".equals(key, ignoreCase = true) || "Cookie2".equals( + key, + ignoreCase = true + )) && + value.isNotEmpty() + ) { + for (header in value) { + if (cookies == null) cookies = mutableListOf() + cookies.addAll(decodeHeaderAsJavaNetCookies(url, header)) + } + } + } + + return if (cookies != null) { + Collections.unmodifiableList(cookies) + } else { + emptyList() + } + } + + /** + * Convert a request header to OkHttp's cookies via [HttpCookie]. That extra step handles + * multiple cookies in a single request header, which [Cookie.parse] doesn't support. + */ + private fun decodeHeaderAsJavaNetCookies(url: HttpUrl, header: String): List { + val result = mutableListOf() + var pos = 0 + val limit = header.length + var pairEnd: Int + while (pos < limit) { + pairEnd = header.delimiterOffset(";,", pos, limit) + val equalsSign = header.delimiterOffset('=', pos, pairEnd) + val name = header.trimSubstring(pos, equalsSign) + if (name.startsWith("$")) { + pos = pairEnd + 1 + continue + } + + // We have either name=value or just a name. + var value = if (equalsSign < pairEnd) { + header.trimSubstring(equalsSign + 1, pairEnd) + } else { + "" + } + + // If the value is "quoted", drop the quotes. + if (value.startsWith("\"") && value.endsWith("\"")) { + value = value.substring(1, value.length - 1) + } + + result.add( + Cookie.Builder() + .name(name) + .value(value) + .domain(url.host) + .build() + ) + pos = pairEnd + 1 + } + return result + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/cookies/stores/InMemoryCookieStore.kt b/library/src/main/java/io/appwrite/cookies/stores/InMemoryCookieStore.kt index 7de9ec9..1f2b536 100644 --- a/library/src/main/java/io/appwrite/cookies/stores/InMemoryCookieStore.kt +++ b/library/src/main/java/io/appwrite/cookies/stores/InMemoryCookieStore.kt @@ -6,10 +6,9 @@ import java.net.CookieStore import java.net.HttpCookie import java.net.URI import java.net.URISyntaxException -import java.util.Collections import java.util.concurrent.locks.ReentrantLock -open class InMemoryCookieStore(private val name: String) : CookieStore { +open class InMemoryCookieStore : CookieStore { internal val uriIndex = mutableMapOf>() private val lock = ReentrantLock(false) @@ -29,7 +28,7 @@ open class InMemoryCookieStore(private val name: String) : CookieStore { if (cookie == null) { Log.i( javaClass.simpleName, - "tried to add null cookie in cookie store named $name. Doing nothing." + "Tried to add null cookie in cookie store. Doing nothing." ) return } @@ -37,7 +36,7 @@ open class InMemoryCookieStore(private val name: String) : CookieStore { if (uri == null) { Log.i( javaClass.simpleName, - "tried to add null URI in cookie store named $name. Doing nothing." + "Tried to add null URI in cookie store. Doing nothing." ) return } @@ -89,7 +88,7 @@ open class InMemoryCookieStore(private val name: String) : CookieStore { if (cookie == null) { Log.i( javaClass.simpleName, - "tried to remove null cookie from cookie store named $name. Doing nothing." + "Tried to remove null cookie from cookie store. Doing nothing." ) return true } @@ -97,7 +96,7 @@ open class InMemoryCookieStore(private val name: String) : CookieStore { if (uri == null) { Log.i( javaClass.simpleName, - "tried to remove null URI from cookie store named $name. Doing nothing." + "Tried to remove null URI from cookie store. Doing nothing." ) return true } @@ -122,7 +121,7 @@ open class InMemoryCookieStore(private val name: String) : CookieStore { if (uri == null) { Log.i( javaClass.simpleName, - "getting cookies from cookie store named $name for null URI results in empty list" + "Getting cookies from cookie store for null URI results in empty list" ) return emptyList() } diff --git a/library/src/main/java/io/appwrite/cookies/stores/SharedPreferencesCookieStore.kt b/library/src/main/java/io/appwrite/cookies/stores/SharedPreferencesCookieStore.kt index 83c677d..0c0b760 100644 --- a/library/src/main/java/io/appwrite/cookies/stores/SharedPreferencesCookieStore.kt +++ b/library/src/main/java/io/appwrite/cookies/stores/SharedPreferencesCookieStore.kt @@ -1,7 +1,7 @@ package io.appwrite.cookies.stores import io.appwrite.cookies.InternalCookie -import android.content.Context +import android.content.SharedPreferences import android.os.Build import android.util.Log import com.google.gson.Gson @@ -10,11 +10,9 @@ import java.net.HttpCookie import java.net.URI open class SharedPreferencesCookieStore( - context: Context, - private val name: String -) : InMemoryCookieStore(name) { + private val preferences: SharedPreferences, +) : InMemoryCookieStore() { - private val preferences = context.getSharedPreferences(name, Context.MODE_PRIVATE) private val gson = Gson() init { @@ -30,7 +28,7 @@ open class SharedPreferencesCookieStore( } catch (exception: Throwable) { Log.e( javaClass.simpleName, - "Error while loading key = $key, value = $value from cookie store named $name", + "Error while loading key = $key, value = $value from cookie store", exception ) } diff --git a/library/src/main/java/io/appwrite/enums/AuthenticatorFactor.kt b/library/src/main/java/io/appwrite/enums/AuthenticatorFactor.kt new file mode 100644 index 0000000..1e0a0c4 --- /dev/null +++ b/library/src/main/java/io/appwrite/enums/AuthenticatorFactor.kt @@ -0,0 +1,7 @@ +package io.appwrite.enums + +enum class AuthenticatorFactor(val value: String) { + TOTP("totp"); + + override fun toString() = value +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/AuthenticatorProvider.kt b/library/src/main/java/io/appwrite/enums/AuthenticatorProvider.kt new file mode 100644 index 0000000..7757f8e --- /dev/null +++ b/library/src/main/java/io/appwrite/enums/AuthenticatorProvider.kt @@ -0,0 +1,7 @@ +package io.appwrite.enums + +enum class AuthenticatorProvider(val value: String) { + TOTP("totp"); + + override fun toString() = value +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/Browser.kt b/library/src/main/java/io/appwrite/enums/Browser.kt new file mode 100644 index 0000000..99f598e --- /dev/null +++ b/library/src/main/java/io/appwrite/enums/Browser.kt @@ -0,0 +1,20 @@ +package io.appwrite.enums + +enum class Browser(val value: String) { + AVANT_BROWSER("aa"), + ANDROID_WEB_VIEW_BETA("an"), + GOOGLE_CHROME("ch"), + GOOGLE_CHROMEI_OS("ci"), + GOOGLE_CHROME_MOBILE("cm"), + CHROMIUM("cr"), + MOZILLA_FIREFOX("ff"), + SAFARI("sf"), + MOBILE_SAFARI("mf"), + MICROSOFT_EDGE("ps"), + MICROSOFT_EDGEI_OS("oi"), + OPERA_MINI("om"), + OPERA("op"), + OPERA_NEXT("on"); + + override fun toString() = value +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/CreditCard.kt b/library/src/main/java/io/appwrite/enums/CreditCard.kt new file mode 100644 index 0000000..e99519b --- /dev/null +++ b/library/src/main/java/io/appwrite/enums/CreditCard.kt @@ -0,0 +1,22 @@ +package io.appwrite.enums + +enum class CreditCard(val value: String) { + AMERICAN_EXPRESS("amex"), + ARGENCARD("argencard"), + CABAL("cabal"), + CONSOSUD("censosud"), + DINERS_CLUB("diners"), + DISCOVER("discover"), + ELO("elo"), + HIPERCARD("hipercard"), + JCB("jcb"), + MASTERCARD("mastercard"), + NARANJA("naranja"), + TARJETA_SHOPPING("targeta-shopping"), + UNION_CHINA_PAY("union-china-pay"), + VISA("visa"), + MIR("mir"), + MAESTRO("maestro"); + + override fun toString() = value +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/ExecutionMethod.kt b/library/src/main/java/io/appwrite/enums/ExecutionMethod.kt new file mode 100644 index 0000000..edeb66b --- /dev/null +++ b/library/src/main/java/io/appwrite/enums/ExecutionMethod.kt @@ -0,0 +1,12 @@ +package io.appwrite.enums + +enum class ExecutionMethod(val value: String) { + GET("GET"), + POST("POST"), + PUT("PUT"), + PATCH("PATCH"), + DELETE("DELETE"), + OPTIONS("OPTIONS"); + + override fun toString() = value +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/Flag.kt b/library/src/main/java/io/appwrite/enums/Flag.kt new file mode 100644 index 0000000..4fcdd88 --- /dev/null +++ b/library/src/main/java/io/appwrite/enums/Flag.kt @@ -0,0 +1,200 @@ +package io.appwrite.enums + +enum class Flag(val value: String) { + AFGHANISTAN("af"), + ANGOLA("ao"), + ALBANIA("al"), + ANDORRA("ad"), + UNITED_ARAB_EMIRATES("ae"), + ARGENTINA("ar"), + ARMENIA("am"), + ANTIGUAAND_BARBUDA("ag"), + AUSTRALIA("au"), + AUSTRIA("at"), + AZERBAIJAN("az"), + BURUNDI("bi"), + BELGIUM("be"), + BENIN("bj"), + BURKINA_FASO("bf"), + BANGLADESH("bd"), + BULGARIA("bg"), + BAHRAIN("bh"), + BAHAMAS("bs"), + BOSNIAAND_HERZEGOVINA("ba"), + BELARUS("by"), + BELIZE("bz"), + BOLIVIA("bo"), + BRAZIL("br"), + BARBADOS("bb"), + BRUNEI_DARUSSALAM("bn"), + BHUTAN("bt"), + BOTSWANA("bw"), + CENTRAL_AFRICAN_REPUBLIC("cf"), + CANADA("ca"), + SWITZERLAND("ch"), + CHILE("cl"), + CHINA("cn"), + CTED_IVOIRE("ci"), + CAMEROON("cm"), + DEMOCRATIC_REPUBLICOFTHE_CONGO("cd"), + REPUBLICOFTHE_CONGO("cg"), + COLOMBIA("co"), + COMOROS("km"), + CAPE_VERDE("cv"), + COSTA_RICA("cr"), + CUBA("cu"), + CYPRUS("cy"), + CZECH_REPUBLIC("cz"), + GERMANY("de"), + DJIBOUTI("dj"), + DOMINICA("dm"), + DENMARK("dk"), + DOMINICAN_REPUBLIC("do"), + ALGERIA("dz"), + ECUADOR("ec"), + EGYPT("eg"), + ERITREA("er"), + SPAIN("es"), + ESTONIA("ee"), + ETHIOPIA("et"), + FINLAND("fi"), + FIJI("fj"), + FRANCE("fr"), + MICRONESIA_FEDERATED_STATESOF("fm"), + GABON("ga"), + UNITED_KINGDOM("gb"), + GEORGIA("ge"), + GHANA("gh"), + GUINEA("gn"), + GAMBIA("gm"), + GUINEA_BISSAU("gw"), + EQUATORIAL_GUINEA("gq"), + GREECE("gr"), + GRENADA("gd"), + GUATEMALA("gt"), + GUYANA("gy"), + HONDURAS("hn"), + CROATIA("hr"), + HAITI("ht"), + HUNGARY("hu"), + INDONESIA("id"), + INDIA("in"), + IRELAND("ie"), + IRAN_ISLAMIC_REPUBLICOF("ir"), + IRAQ("iq"), + ICELAND("is"), + ISRAEL("il"), + ITALY("it"), + JAMAICA("jm"), + JORDAN("jo"), + JAPAN("jp"), + KAZAKHSTAN("kz"), + KENYA("ke"), + KYRGYZSTAN("kg"), + CAMBODIA("kh"), + KIRIBATI("ki"), + SAINT_KITTSAND_NEVIS("kn"), + SOUTH_KOREA("kr"), + KUWAIT("kw"), + LAO_PEOPLES_DEMOCRATIC_REPUBLIC("la"), + LEBANON("lb"), + LIBERIA("lr"), + LIBYA("ly"), + SAINT_LUCIA("lc"), + LIECHTENSTEIN("li"), + SRI_LANKA("lk"), + LESOTHO("ls"), + LITHUANIA("lt"), + LUXEMBOURG("lu"), + LATVIA("lv"), + MOROCCO("ma"), + MONACO("mc"), + MOLDOVA("md"), + MADAGASCAR("mg"), + MALDIVES("mv"), + MEXICO("mx"), + MARSHALL_ISLANDS("mh"), + NORTH_MACEDONIA("mk"), + MALI("ml"), + MALTA("mt"), + MYANMAR("mm"), + MONTENEGRO("me"), + MONGOLIA("mn"), + MOZAMBIQUE("mz"), + MAURITANIA("mr"), + MAURITIUS("mu"), + MALAWI("mw"), + MALAYSIA("my"), + NAMIBIA("na"), + NIGER("ne"), + NIGERIA("ng"), + NICARAGUA("ni"), + NETHERLANDS("nl"), + NORWAY("no"), + NEPAL("np"), + NAURU("nr"), + NEW_ZEALAND("nz"), + OMAN("om"), + PAKISTAN("pk"), + PANAMA("pa"), + PERU("pe"), + PHILIPPINES("ph"), + PALAU("pw"), + PAPUA_NEW_GUINEA("pg"), + POLAND("pl"), + NORTH_KOREA("kp"), + PORTUGAL("pt"), + PARAGUAY("py"), + QATAR("qa"), + ROMANIA("ro"), + RUSSIA("ru"), + RWANDA("rw"), + SAUDI_ARABIA("sa"), + SUDAN("sd"), + SENEGAL("sn"), + SINGAPORE("sg"), + SOLOMON_ISLANDS("sb"), + SIERRA_LEONE("sl"), + EL_SALVADOR("sv"), + SAN_MARINO("sm"), + SOMALIA("so"), + SERBIA("rs"), + SOUTH_SUDAN("ss"), + SAO_TOMEAND_PRINCIPE("st"), + SURINAME("sr"), + SLOVAKIA("sk"), + SLOVENIA("si"), + SWEDEN("se"), + ESWATINI("sz"), + SEYCHELLES("sc"), + SYRIA("sy"), + CHAD("td"), + TOGO("tg"), + THAILAND("th"), + TAJIKISTAN("tj"), + TURKMENISTAN("tm"), + TIMOR_LESTE("tl"), + TONGA("to"), + TRINIDADAND_TOBAGO("tt"), + TUNISIA("tn"), + TURKEY("tr"), + TUVALU("tv"), + TANZANIA("tz"), + UGANDA("ug"), + UKRAINE("ua"), + URUGUAY("uy"), + UNITED_STATES("us"), + UZBEKISTAN("uz"), + VATICAN_CITY("va"), + SAINT_VINCENTANDTHE_GRENADINES("vc"), + VENEZUELA("ve"), + VIETNAM("vn"), + VANUATU("vu"), + SAMOA("ws"), + YEMEN("ye"), + SOUTH_AFRICA("za"), + ZAMBIA("zm"), + ZIMBABWE("zw"); + + override fun toString() = value +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/ImageFormat.kt b/library/src/main/java/io/appwrite/enums/ImageFormat.kt new file mode 100644 index 0000000..6a4c422 --- /dev/null +++ b/library/src/main/java/io/appwrite/enums/ImageFormat.kt @@ -0,0 +1,11 @@ +package io.appwrite.enums + +enum class ImageFormat(val value: String) { + JPG("jpg"), + JPEG("jpeg"), + GIF("gif"), + PNG("png"), + WEBP("webp"); + + override fun toString() = value +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/ImageGravity.kt b/library/src/main/java/io/appwrite/enums/ImageGravity.kt new file mode 100644 index 0000000..a8fa441 --- /dev/null +++ b/library/src/main/java/io/appwrite/enums/ImageGravity.kt @@ -0,0 +1,15 @@ +package io.appwrite.enums + +enum class ImageGravity(val value: String) { + CENTER("center"), + TOPLEFT("top-left"), + TOP("top"), + TOPRIGHT("top-right"), + LEFT("left"), + RIGHT("right"), + BOTTOMLEFT("bottom-left"), + BOTTOM("bottom"), + BOTTOMRIGHT("bottom-right"); + + override fun toString() = value +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/OAuthProvider.kt b/library/src/main/java/io/appwrite/enums/OAuthProvider.kt new file mode 100644 index 0000000..4a38a2e --- /dev/null +++ b/library/src/main/java/io/appwrite/enums/OAuthProvider.kt @@ -0,0 +1,45 @@ +package io.appwrite.enums + +enum class OAuthProvider(val value: String) { + AMAZON("amazon"), + APPLE("apple"), + AUTH0("auth0"), + AUTHENTIK("authentik"), + AUTODESK("autodesk"), + BITBUCKET("bitbucket"), + BITLY("bitly"), + BOX("box"), + DAILYMOTION("dailymotion"), + DISCORD("discord"), + DISQUS("disqus"), + DROPBOX("dropbox"), + ETSY("etsy"), + FACEBOOK("facebook"), + GITHUB("github"), + GITLAB("gitlab"), + GOOGLE("google"), + LINKEDIN("linkedin"), + MICROSOFT("microsoft"), + NOTION("notion"), + OIDC("oidc"), + OKTA("okta"), + PAYPAL("paypal"), + PAYPAL_SANDBOX("paypalSandbox"), + PODIO("podio"), + SALESFORCE("salesforce"), + SLACK("slack"), + SPOTIFY("spotify"), + STRIPE("stripe"), + TRADESHIFT("tradeshift"), + TRADESHIFT_BOX("tradeshiftBox"), + TWITCH("twitch"), + WORDPRESS("wordpress"), + YAHOO("yahoo"), + YAMMER("yammer"), + YANDEX("yandex"), + ZOHO("zoho"), + ZOOM("zoom"), + MOCK("mock"); + + override fun toString() = value +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/extensions/ActivityExtensions.kt b/library/src/main/java/io/appwrite/extensions/ActivityExtensions.kt new file mode 100644 index 0000000..b5164b8 --- /dev/null +++ b/library/src/main/java/io/appwrite/extensions/ActivityExtensions.kt @@ -0,0 +1,46 @@ +package io.appwrite.extensions + +import android.Manifest +import android.content.pm.PackageManager +import android.os.Build +import androidx.activity.result.contract.ActivityResultContracts +import androidx.appcompat.app.AppCompatActivity +import androidx.core.content.ContextCompat + +fun AppCompatActivity.requestNotificationPermission( + onGranted: () -> Unit, + onDenied: () -> Unit, + onShowRationale: () -> Unit, +) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) { + onGranted() + return + } + + if (ContextCompat.checkSelfPermission( + this, + Manifest.permission.POST_NOTIFICATIONS + ) == PackageManager.PERMISSION_GRANTED) { + onGranted() + } else if (shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS)) { + onShowRationale() + } else { + requestPermissionLauncher( + onGranted, + onDenied + ).launch(Manifest.permission.POST_NOTIFICATIONS) + } +} + +private fun AppCompatActivity.requestPermissionLauncher( + onGranted: () -> Unit, + onDenied: () -> Unit, +) = registerForActivityResult( + ActivityResultContracts.RequestPermission(), +) { isGranted: Boolean -> + if (isGranted) { + onGranted() + } else { + onDenied() + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/extensions/MessagingExtensions.kt b/library/src/main/java/io/appwrite/extensions/MessagingExtensions.kt new file mode 100644 index 0000000..515ef51 --- /dev/null +++ b/library/src/main/java/io/appwrite/extensions/MessagingExtensions.kt @@ -0,0 +1,14 @@ +package io.appwrite.extensions + +import io.appwrite.models.Notification +import io.appwrite.services.Messaging + +private val callbacks: MutableList<(Notification) -> Unit> = mutableListOf() + +internal fun onNotificationReceived(notification: Notification) { + callbacks.forEach { it(notification) } +} + +fun Messaging.onNotificationReceived(callback: (Notification) -> Unit) { + callbacks.add(callback) +} \ 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 index 2674b99..e699a54 100644 --- a/library/src/main/java/io/appwrite/extensions/TypeExtensions.kt +++ b/library/src/main/java/io/appwrite/extensions/TypeExtensions.kt @@ -4,5 +4,6 @@ import kotlin.reflect.KClass import kotlin.reflect.typeOf inline fun classOf(): Class { + @Suppress("UNCHECKED_CAST") return (typeOf().classifier!! as KClass).java } \ 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 96a364f..17ab303 100644 --- a/library/src/main/java/io/appwrite/models/Membership.kt +++ b/library/src/main/java/io/appwrite/models/Membership.kt @@ -73,6 +73,12 @@ data class Membership( @SerializedName("confirm") val confirm: Boolean, + /** + * Multi factor authentication status, true if the user has MFA enabled or false otherwise. + */ + @SerializedName("mfa") + val mfa: Boolean, + /** * User list of roles */ @@ -92,6 +98,7 @@ data class Membership( "invited" to invited as Any, "joined" to joined as Any, "confirm" to confirm as Any, + "mfa" to mfa as Any, "roles" to roles as Any, ) @@ -112,6 +119,7 @@ data class Membership( invited = map["invited"] as String, joined = map["joined"] as String, confirm = map["confirm"] as Boolean, + mfa = map["mfa"] as Boolean, roles = map["roles"] as List, ) } diff --git a/library/src/main/java/io/appwrite/models/MfaChallenge.kt b/library/src/main/java/io/appwrite/models/MfaChallenge.kt new file mode 100644 index 0000000..82b1d18 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/MfaChallenge.kt @@ -0,0 +1,54 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * MFA Challenge + */ +data class MfaChallenge( + /** + * 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 expiration date in ISO 8601 format. + */ + @SerializedName("expire") + val expire: String, + +) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "userId" to userId as Any, + "expire" to expire as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = MfaChallenge( + id = map["\$id"] as String, + createdAt = map["\$createdAt"] as String, + userId = map["userId"] as String, + expire = map["expire"] as String, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/MfaProvider.kt b/library/src/main/java/io/appwrite/models/MfaProvider.kt new file mode 100644 index 0000000..330f98a --- /dev/null +++ b/library/src/main/java/io/appwrite/models/MfaProvider.kt @@ -0,0 +1,46 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * MFAProvider + */ +data class MfaProvider( + /** + * Backup codes. + */ + @SerializedName("backups") + val backups: List, + + /** + * Secret token used for TOTP factor. + */ + @SerializedName("secret") + val secret: String, + + /** + * URI for authenticator apps. + */ + @SerializedName("uri") + val uri: String, + +) { + fun toMap(): Map = mapOf( + "backups" to backups as Any, + "secret" to secret as Any, + "uri" to uri as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = MfaProvider( + backups = map["backups"] as List, + secret = map["secret"] as String, + uri = map["uri"] as String, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/MfaProviders.kt b/library/src/main/java/io/appwrite/models/MfaProviders.kt new file mode 100644 index 0000000..cb16f91 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/MfaProviders.kt @@ -0,0 +1,46 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * MFAProviders + */ +data class MfaProviders( + /** + * TOTP + */ + @SerializedName("totp") + val totp: Boolean, + + /** + * Phone + */ + @SerializedName("phone") + val phone: Boolean, + + /** + * Email + */ + @SerializedName("email") + val email: Boolean, + +) { + fun toMap(): Map = mapOf( + "totp" to totp as Any, + "phone" to phone as Any, + "email" to email as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = MfaProviders( + totp = map["totp"] as Boolean, + phone = map["phone"] as Boolean, + email = map["email"] as Boolean, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Notification.kt b/library/src/main/java/io/appwrite/models/Notification.kt new file mode 100644 index 0000000..f5b5f38 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Notification.kt @@ -0,0 +1,12 @@ +package io.appwrite.models + +data class Notification( + val title: String = "", + val body: String = "", + val clickAction: String = "", + val color: String = "", + val icon: String = "", + val imageURL: String = "", + val sound: String = "", + val data: Map = mapOf(), +) \ 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 7674d72..acf70cd 100644 --- a/library/src/main/java/io/appwrite/models/Session.kt +++ b/library/src/main/java/io/appwrite/models/Session.kt @@ -157,6 +157,18 @@ data class Session( @SerializedName("current") val current: Boolean, + /** + * Returns a list of active session factors. + */ + @SerializedName("factors") + val factors: Long, + + /** + * Secret used to authenticate the user. Only included if the request was made with an API key + */ + @SerializedName("secret") + val secret: String, + ) { fun toMap(): Map = mapOf( "\$id" to id as Any, @@ -184,6 +196,8 @@ data class Session( "countryCode" to countryCode as Any, "countryName" to countryName as Any, "current" to current as Any, + "factors" to factors as Any, + "secret" to secret as Any, ) companion object { @@ -217,6 +231,8 @@ data class Session( countryCode = map["countryCode"] as String, countryName = map["countryName"] as String, current = map["current"] as Boolean, + factors = (map["factors"] as Number).toLong(), + secret = map["secret"] as String, ) } } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Subscriber.kt b/library/src/main/java/io/appwrite/models/Subscriber.kt new file mode 100644 index 0000000..1920691 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Subscriber.kt @@ -0,0 +1,94 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Subscriber + */ +data class Subscriber( + /** + * Subscriber ID. + */ + @SerializedName("\$id") + val id: String, + + /** + * Subscriber creation time in ISO 8601 format. + */ + @SerializedName("\$createdAt") + val createdAt: String, + + /** + * Subscriber update date in ISO 8601 format. + */ + @SerializedName("\$updatedAt") + val updatedAt: String, + + /** + * Target ID. + */ + @SerializedName("targetId") + val targetId: String, + + /** + * Target. + */ + @SerializedName("target") + val target: Target, + + /** + * Topic ID. + */ + @SerializedName("userId") + val userId: String, + + /** + * User Name. + */ + @SerializedName("userName") + val userName: String, + + /** + * Topic ID. + */ + @SerializedName("topicId") + val topicId: String, + + /** + * The target provider type. Can be one of the following: `email`, `sms` or `push`. + */ + @SerializedName("providerType") + val providerType: String, + +) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "targetId" to targetId as Any, + "target" to target.toMap() as Any, + "userId" to userId as Any, + "userName" to userName as Any, + "topicId" to topicId as Any, + "providerType" to providerType as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = Subscriber( + id = map["\$id"] as String, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, + targetId = map["targetId"] as String, + target = Target.from(map = map["target"] as Map), + userId = map["userId"] as String, + userName = map["userName"] as String, + topicId = map["topicId"] as String, + providerType = map["providerType"] as String, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Target.kt b/library/src/main/java/io/appwrite/models/Target.kt new file mode 100644 index 0000000..bd4d207 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Target.kt @@ -0,0 +1,86 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Target + */ +data class Target( + /** + * Target ID. + */ + @SerializedName("\$id") + val id: String, + + /** + * Target creation time in ISO 8601 format. + */ + @SerializedName("\$createdAt") + val createdAt: String, + + /** + * Target update date in ISO 8601 format. + */ + @SerializedName("\$updatedAt") + val updatedAt: String, + + /** + * Target Name. + */ + @SerializedName("name") + val name: String, + + /** + * User ID. + */ + @SerializedName("userId") + val userId: String, + + /** + * Provider ID. + */ + @SerializedName("providerId") + var providerId: String?, + + /** + * The target provider type. Can be one of the following: `email`, `sms` or `push`. + */ + @SerializedName("providerType") + val providerType: String, + + /** + * The target identifier. + */ + @SerializedName("identifier") + val identifier: String, + +) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "name" to name as Any, + "userId" to userId as Any, + "providerId" to providerId as Any, + "providerType" to providerType as Any, + "identifier" to identifier as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = Target( + id = map["\$id"] as String, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, + name = map["name"] as String, + userId = map["userId"] as String, + providerId = map["providerId"] as? String?, + providerType = map["providerType"] as String, + identifier = map["identifier"] as String, + ) + } +} \ 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 8c0f0e0..e36d060 100644 --- a/library/src/main/java/io/appwrite/models/Token.kt +++ b/library/src/main/java/io/appwrite/models/Token.kt @@ -37,6 +37,12 @@ data class Token( @SerializedName("expire") val expire: String, + /** + * Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. + */ + @SerializedName("phrase") + val phrase: String, + ) { fun toMap(): Map = mapOf( "\$id" to id as Any, @@ -44,6 +50,7 @@ data class Token( "userId" to userId as Any, "secret" to secret as Any, "expire" to expire as Any, + "phrase" to phrase as Any, ) companion object { @@ -57,6 +64,7 @@ data class Token( userId = map["userId"] as String, secret = map["secret"] as String, expire = map["expire"] as String, + phrase = map["phrase"] as String, ) } } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/User.kt b/library/src/main/java/io/appwrite/models/User.kt index 9bf7eb4..4c776b9 100644 --- a/library/src/main/java/io/appwrite/models/User.kt +++ b/library/src/main/java/io/appwrite/models/User.kt @@ -97,12 +97,30 @@ data class User( @SerializedName("phoneVerification") val phoneVerification: Boolean, + /** + * Multi factor authentication status. + */ + @SerializedName("mfa") + val mfa: Boolean, + + /** + * TOTP status. + */ + @SerializedName("totp") + val totp: Boolean, + /** * User preferences as a key-value object */ @SerializedName("prefs") val prefs: Preferences, + /** + * A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. + */ + @SerializedName("targets") + val targets: List, + /** * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. */ @@ -126,7 +144,10 @@ data class User( "phone" to phone as Any, "emailVerification" to emailVerification as Any, "phoneVerification" to phoneVerification as Any, + "mfa" to mfa as Any, + "totp" to totp as Any, "prefs" to prefs.toMap() as Any, + "targets" to targets.map { it.toMap() } as Any, "accessedAt" to accessedAt as Any, ) @@ -147,7 +168,10 @@ data class User( phone: String, emailVerification: Boolean, phoneVerification: Boolean, + mfa: Boolean, + totp: Boolean, prefs: Preferences>, + targets: List, accessedAt: String, ) = User>( id, @@ -165,7 +189,10 @@ data class User( phone, emailVerification, phoneVerification, + mfa, + totp, prefs, + targets, accessedAt, ) @@ -189,7 +216,10 @@ data class User( phone = map["phone"] as String, emailVerification = map["emailVerification"] as Boolean, phoneVerification = map["phoneVerification"] as Boolean, + mfa = map["mfa"] as Boolean, + totp = map["totp"] as Boolean, prefs = Preferences.from(map = map["prefs"] as Map, nestedType), + targets = (map["targets"] as List>).map { Target.from(map = it) }, accessedAt = map["accessedAt"] as String, ) } diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 3c9cca1..1e12e94 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -3,6 +3,7 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client import io.appwrite.models.* +import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import io.appwrite.WebAuthComponent @@ -15,9 +16,7 @@ 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) { } +class Account(client: Client) : Service(client) { /** * Get account @@ -37,6 +36,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( @@ -67,9 +67,9 @@ class Account : Service { * * Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). * - * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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 User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 New user password. Must be at least 8 chars. + * @param password New user password. Must be between 8 and 256 chars. * @param name User name. Max length: 128 chars. * @return [io.appwrite.models.User] */ @@ -93,6 +93,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( @@ -110,9 +111,9 @@ class Account : Service { * * Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). * - * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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 User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 New user password. Must be at least 8 chars. + * @param password New user password. Must be between 8 and 256 chars. * @param name User name. Max length: 128 chars. * @return [io.appwrite.models.User] */ @@ -155,6 +156,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( @@ -196,7 +198,7 @@ class Account : Service { */ @JvmOverloads suspend fun listIdentities( - queries: String? = null, + queries: List? = null, ): io.appwrite.models.IdentityList { val apiPath = "/account/identities" @@ -207,6 +209,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.IdentityList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.IdentityList.from(map = it as Map) } return client.call( @@ -221,7 +224,7 @@ class Account : Service { /** - * Delete Identity + * Delete identity * * Delete an identity by its unique ID. * @@ -266,6 +269,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Jwt = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Jwt.from(map = it as Map) } return client.call( @@ -300,6 +304,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LogList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.LogList.from(map = it as Map) } return client.call( @@ -313,6 +318,299 @@ class Account : Service { } + /** + * Update MFA + * + * + * + * @param mfa Enable or disable MFA. + * @return [io.appwrite.models.User] + */ + suspend fun updateMFA( + mfa: Boolean, + nestedType: Class, + ): io.appwrite.models.User { + val apiPath = "/account/mfa" + + val apiParams = mutableMapOf( + "mfa" to mfa, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.User.from(map = it as Map, nestedType) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Update MFA + * + * + * + * @param mfa Enable or disable MFA. + * @return [io.appwrite.models.User] + */ + @Throws(AppwriteException::class) + suspend fun updateMFA( + mfa: Boolean, + ): io.appwrite.models.User> = updateMFA( + mfa, + nestedType = classOf(), + ) + + /** + * Create MFA Challenge + * + * + * + * @param provider provider. + * @return [io.appwrite.models.MfaChallenge] + */ + suspend fun createChallenge( + provider: AuthenticatorProvider, + ): io.appwrite.models.MfaChallenge { + val apiPath = "/account/mfa/challenge" + + val apiParams = mutableMapOf( + "provider" to provider, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.MfaChallenge = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.MfaChallenge.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.MfaChallenge::class.java, + converter, + ) + } + + + /** + * Create MFA Challenge (confirmation) + * + * + * + * @param challengeId Valid verification token. + * @param otp Valid verification token. + * @return [Any] + */ + suspend fun updateChallenge( + challengeId: String, + otp: String, + ): Any { + val apiPath = "/account/mfa/challenge" + + val apiParams = mutableMapOf( + "challengeId" to challengeId, + "otp" to otp, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + return client.call( + "PUT", + apiPath, + apiHeaders, + apiParams, + responseType = Any::class.java, + ) + } + + + /** + * List Factors + * + * Get the currently logged in user. + * + * @return [io.appwrite.models.MfaProviders] + */ + suspend fun listFactors( + ): io.appwrite.models.MfaProviders { + val apiPath = "/account/mfa/factors" + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.MfaProviders = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.MfaProviders.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.MfaProviders::class.java, + converter, + ) + } + + + /** + * Add Authenticator + * + * + * + * @param factor Factor. + * @return [io.appwrite.models.MfaProvider] + */ + suspend fun addAuthenticator( + factor: AuthenticatorFactor, + ): io.appwrite.models.MfaProvider { + val apiPath = "/account/mfa/{factor}" + .replace("{factor}", factor.value) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.MfaProvider = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.MfaProvider.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.MfaProvider::class.java, + converter, + ) + } + + + /** + * Verify Authenticator + * + * + * + * @param factor Factor. + * @param otp Valid verification token. + * @return [io.appwrite.models.User] + */ + suspend fun verifyAuthenticator( + factor: AuthenticatorFactor, + otp: String, + nestedType: Class, + ): io.appwrite.models.User { + val apiPath = "/account/mfa/{factor}" + .replace("{factor}", factor.value) + + val apiParams = mutableMapOf( + "otp" to otp, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.User.from(map = it as Map, nestedType) + } + return client.call( + "PUT", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Verify Authenticator + * + * + * + * @param factor Factor. + * @param otp Valid verification token. + * @return [io.appwrite.models.User] + */ + @Throws(AppwriteException::class) + suspend fun verifyAuthenticator( + factor: AuthenticatorFactor, + otp: String, + ): io.appwrite.models.User> = verifyAuthenticator( + factor, + otp, + nestedType = classOf(), + ) + + /** + * Delete Authenticator + * + * + * + * @param provider Provider. + * @param otp Valid verification token. + * @return [io.appwrite.models.User] + */ + suspend fun deleteAuthenticator( + provider: AuthenticatorProvider, + otp: String, + nestedType: Class, + ): io.appwrite.models.User { + val apiPath = "/account/mfa/{provider}" + .replace("{provider}", provider.value) + + val apiParams = mutableMapOf( + "otp" to otp, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.User.from(map = it as Map, nestedType) + } + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Delete Authenticator + * + * + * + * @param provider Provider. + * @param otp Valid verification token. + * @return [io.appwrite.models.User] + */ + @Throws(AppwriteException::class) + suspend fun deleteAuthenticator( + provider: AuthenticatorProvider, + otp: String, + ): io.appwrite.models.User> = deleteAuthenticator( + provider, + otp, + nestedType = classOf(), + ) + /** * Update name * @@ -334,6 +632,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( @@ -387,6 +686,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( @@ -443,6 +743,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( @@ -492,6 +793,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Preferences.from(map = it as Map, nestedType) } return client.call( @@ -538,6 +840,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( @@ -589,6 +892,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } return client.call( @@ -609,15 +913,13 @@ class Account : Service { * * @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. + * @param password New user password. Must be between 8 and 256 chars. * @return [io.appwrite.models.Token] */ suspend fun updateRecovery( userId: String, secret: String, password: String, - passwordAgain: String, ): io.appwrite.models.Token { val apiPath = "/account/recovery" @@ -625,12 +927,12 @@ class Account : Service { "userId" to userId, "secret" to secret, "password" to password, - "passwordAgain" to passwordAgain, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } return client.call( @@ -661,6 +963,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.SessionList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.SessionList.from(map = it as Map) } return client.call( @@ -717,6 +1020,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } return client.call( @@ -731,7 +1035,7 @@ class Account : Service { /** - * Create email session + * Create email password session * * Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * @@ -739,7 +1043,7 @@ class Account : Service { * @param password User password. Must be at least 8 chars. * @return [io.appwrite.models.Session] */ - suspend fun createEmailSession( + suspend fun createEmailPasswordSession( email: String, password: String, ): io.appwrite.models.Session { @@ -753,6 +1057,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } return client.call( @@ -767,51 +1072,11 @@ class Account : Service { /** - * Create magic URL session - * - * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [PUT /account/sessions/magic-url](https://appwrite.io/docs/references/cloud/client-web/account#updateMagicURLSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). - * - * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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] - */ - @JvmOverloads - suspend fun createMagicURLSession( - userId: String, - email: String, - url: String? = null, - ): io.appwrite.models.Token { - val apiPath = "/account/sessions/magic-url" - - val apiParams = mutableMapOf( - "userId" to userId, - "email" to email, - "url" to url, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it as Map) - } - return client.call( - "POST", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.Token::class.java, - converter, - ) - } - - - /** - * Create magic URL session (confirmation) + * Create session (deprecated) * - * 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](https://appwrite.io/docs/references/cloud/client-web/account#createMagicURLSession) 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 create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. * - * @param userId User ID. + * @param userId User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 secret Valid verification token. * @return [io.appwrite.models.Session] */ @@ -829,6 +1094,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } return client.call( @@ -847,25 +1113,28 @@ class Account : Service { * * 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](https://appwrite.io/docs/authentication-security#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, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoom. + * @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, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom. * @param success URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's 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's 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 token Include token credentials in the final redirect, useful for server-side integrations, or when cookies are not available. * @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 suspend fun createOAuth2Session( activity: ComponentActivity, - provider: String, + provider: OAuthProvider, success: String? = null, failure: String? = null, + token: Boolean? = null, scopes: List? = null, ) { val apiPath = "/account/sessions/oauth2/{provider}" - .replace("{provider}", provider) + .replace("{provider}", provider.value) val apiParams = mutableMapOf( "success" to success, "failure" to failure, + "token" to token, "scopes" to scopes, "project" to client.config["project"], ) @@ -884,7 +1153,7 @@ class Account : Service { } } - val apiUrl = Uri.parse("${client.endPoint}${apiPath}?${apiQuery.joinToString("&")}") + val apiUrl = Uri.parse("${client.endpoint}${apiPath}?${apiQuery.joinToString("&")}") val callbackUrlScheme = "appwrite-callback-${client.config["project"]}" WebAuthComponent.authenticate(activity, apiUrl, callbackUrlScheme) { @@ -902,12 +1171,12 @@ class Account : Service { val cookie = Cookie.Builder() .name(key) .value(secret) - .domain(Uri.parse(client.endPoint).host!!) + .domain(Uri.parse(client.endpoint).host!!) .httpOnly() .build() client.http.cookieJar.saveFromResponse( - client.endPoint.toHttpUrl(), + client.endpoint.toHttpUrl(), listOf(cookie) ) } @@ -915,55 +1184,19 @@ class Account : Service { /** - * Create phone session + * Create 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](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. * - * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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] - */ - suspend fun createPhoneSession( - userId: String, - phone: String, - ): io.appwrite.models.Token { - val apiPath = "/account/sessions/phone" - - val apiParams = mutableMapOf( - "userId" to userId, - "phone" to phone, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it as Map) - } - return client.call( - "POST", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.Token::class.java, - converter, - ) - } - - - /** - * Create phone session (confirmation) - * - * Use this endpoint to complete creating a session with SMS. Use the **userId** from the [createPhoneSession](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneSession) endpoint and the **secret** received via SMS to successfully update and confirm the phone session. - * - * @param userId User ID. - * @param secret Valid verification token. + * @param userId User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 secret Secret of a token generated by login methods. For example, the `createMagicURLToken` or `createPhoneToken` methods. * @return [io.appwrite.models.Session] */ - suspend fun updatePhoneSession( + suspend fun createSession( userId: String, secret: String, ): io.appwrite.models.Session { - val apiPath = "/account/sessions/phone" + val apiPath = "/account/sessions/token" val apiParams = mutableMapOf( "userId" to userId, @@ -973,10 +1206,11 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } return client.call( - "PUT", + "POST", apiPath, apiHeaders, apiParams, @@ -1006,6 +1240,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } return client.call( @@ -1020,9 +1255,9 @@ class Account : Service { /** - * Update OAuth session (refresh tokens) + * Update (or renew) a session * - * Access tokens have limited lifespan and expire to mitigate security risks. If session was created using an OAuth provider, this route can be used to "refresh" the access token. + * Extend session's expiry to increase it's lifespan. Extending a session is useful when session length is short such as 5 minutes. * * @param sessionId Session ID. Use the string 'current' to update the current device session. * @return [io.appwrite.models.Session] @@ -1039,6 +1274,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } return client.call( @@ -1099,6 +1335,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( @@ -1124,6 +1361,235 @@ class Account : Service { nestedType = classOf(), ) + /** + * Create a push target + * + * + * + * @param targetId Target ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 identifier The target identifier (token, email, phone etc.) + * @param providerId Provider ID. Message will be sent to this target from the specified provider ID. If no provider ID is set the first setup provider will be used. + * @return [io.appwrite.models.Target] + */ + @JvmOverloads + suspend fun createPushTarget( + targetId: String, + identifier: String, + providerId: String? = null, + ): io.appwrite.models.Target { + val apiPath = "/account/targets/push" + + val apiParams = mutableMapOf( + "targetId" to targetId, + "identifier" to identifier, + "providerId" to providerId, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Target = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Target.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Target::class.java, + converter, + ) + } + + + /** + * Update a push target + * + * + * + * @param targetId Target ID. + * @param identifier The target identifier (token, email, phone etc.) + * @return [io.appwrite.models.Target] + */ + suspend fun updatePushTarget( + targetId: String, + identifier: String, + ): io.appwrite.models.Target { + val apiPath = "/account/targets/{targetId}/push" + .replace("{targetId}", targetId) + + val apiParams = mutableMapOf( + "identifier" to identifier, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Target = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Target.from(map = it as Map) + } + return client.call( + "PUT", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Target::class.java, + converter, + ) + } + + + /** + * Delete a push target + * + * + * + * @param targetId Target ID. + * @return [Any] + */ + suspend fun deletePushTarget( + targetId: String, + ): Any { + val apiPath = "/account/targets/{targetId}/push" + .replace("{targetId}", targetId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = Any::class.java, + ) + } + + + /** + * Create email token (OTP) + * + * Sends the user an email with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's email is valid for 15 minutes.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * + * @param userId User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 phrase Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. + * @return [io.appwrite.models.Token] + */ + @JvmOverloads + suspend fun createEmailToken( + userId: String, + email: String, + phrase: Boolean? = null, + ): io.appwrite.models.Token { + val apiPath = "/account/tokens/email" + + val apiParams = mutableMapOf( + "userId" to userId, + "email" to email, + "phrase" to phrase, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Token = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Token.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Token::class.java, + converter, + ) + } + + + /** + * Create magic URL token + * + * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * + * @param userId User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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. + * @param phrase Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. + * @return [io.appwrite.models.Token] + */ + @JvmOverloads + suspend fun createMagicURLToken( + userId: String, + email: String, + url: String? = null, + phrase: Boolean? = null, + ): io.appwrite.models.Token { + val apiPath = "/account/tokens/magic-url" + + val apiParams = mutableMapOf( + "userId" to userId, + "email" to email, + "url" to url, + "phrase" to phrase, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Token = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Token.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Token::class.java, + converter, + ) + } + + + /** + * Create phone token + * + * Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * + * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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] + */ + suspend fun createPhoneToken( + userId: String, + phone: String, + ): io.appwrite.models.Token { + val apiPath = "/account/tokens/phone" + + val apiParams = mutableMapOf( + "userId" to userId, + "phone" to phone, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Token = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Token.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Token::class.java, + converter, + ) + } + + /** * Create email verification * @@ -1144,6 +1610,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } return client.call( @@ -1180,6 +1647,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } return client.call( @@ -1210,6 +1678,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } return client.call( @@ -1246,6 +1715,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } return client.call( diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt index 27b7cde..bdf97ae 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -3,6 +3,7 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client import io.appwrite.models.* +import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import okhttp3.Cookie @@ -13,9 +14,7 @@ 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) { } +class Avatars(client: Client) : Service(client) { /** * Get browser icon @@ -30,13 +29,13 @@ class Avatars : Service { */ @JvmOverloads suspend fun getBrowser( - code: String, + code: Browser, width: Long? = null, height: Long? = null, quality: Long? = null, ): ByteArray { val apiPath = "/avatars/browsers/{code}" - .replace("{code}", code) + .replace("{code}", code.value) val apiParams = mutableMapOf( "width" to width, @@ -66,13 +65,13 @@ class Avatars : Service { */ @JvmOverloads suspend fun getCreditCard( - code: String, + code: CreditCard, width: Long? = null, height: Long? = null, quality: Long? = null, ): ByteArray { val apiPath = "/avatars/credit-cards/{code}" - .replace("{code}", code) + .replace("{code}", code.value) val apiParams = mutableMapOf( "width" to width, @@ -128,13 +127,13 @@ class Avatars : Service { */ @JvmOverloads suspend fun getFlag( - code: String, + code: Flag, width: Long? = null, height: Long? = null, quality: Long? = null, ): ByteArray { val apiPath = "/avatars/flags/{code}" - .replace("{code}", code) + .replace("{code}", code.value) val apiParams = mutableMapOf( "width" to width, diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index 4329b35..b95d6cc 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -3,6 +3,7 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client import io.appwrite.models.* +import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import okhttp3.Cookie @@ -11,9 +12,7 @@ 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) { } +class Databases(client: Client) : Service(client) { /** * List documents @@ -43,6 +42,7 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.DocumentList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.DocumentList.from(map = it as Map, nestedType) } return client.call( @@ -112,6 +112,7 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Document.from(map = it as Map, nestedType) } return client.call( @@ -161,7 +162,7 @@ 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. - * @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 method allowed is select. + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.Document] */ @JvmOverloads @@ -184,6 +185,7 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Document.from(map = it as Map, nestedType) } return client.call( @@ -204,7 +206,7 @@ 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. - * @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 method allowed is select. + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.Document] */ @JvmOverloads @@ -256,6 +258,7 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Document.from(map = it as Map, nestedType) } return client.call( diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index 257a130..286ec5d 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -3,6 +3,7 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client import io.appwrite.models.* +import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import okhttp3.Cookie @@ -11,9 +12,7 @@ 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) { } +class Functions(client: Client) : Service(client) { /** * List executions @@ -42,6 +41,7 @@ class Functions : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.ExecutionList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.ExecutionList.from(map = it as Map) } return client.call( @@ -74,7 +74,7 @@ class Functions : Service { body: String? = null, async: Boolean? = null, path: String? = null, - method: String? = null, + method: ExecutionMethod? = null, headers: Any? = null, ): io.appwrite.models.Execution { val apiPath = "/functions/{functionId}/executions" @@ -91,6 +91,7 @@ class Functions : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Execution = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Execution.from(map = it as Map) } return client.call( @@ -127,6 +128,7 @@ class Functions : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Execution = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Execution.from(map = it as Map) } return client.call( diff --git a/library/src/main/java/io/appwrite/services/Graphql.kt b/library/src/main/java/io/appwrite/services/Graphql.kt index 3a925d5..b1a8254 100644 --- a/library/src/main/java/io/appwrite/services/Graphql.kt +++ b/library/src/main/java/io/appwrite/services/Graphql.kt @@ -3,6 +3,7 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client import io.appwrite.models.* +import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import okhttp3.Cookie @@ -11,9 +12,7 @@ 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) { } +class Graphql(client: Client) : Service(client) { /** * GraphQL endpoint diff --git a/library/src/main/java/io/appwrite/services/Locale.kt b/library/src/main/java/io/appwrite/services/Locale.kt index 510f451..ee26888 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -3,6 +3,7 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client import io.appwrite.models.* +import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import okhttp3.Cookie @@ -11,9 +12,7 @@ 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) { } +class Locale(client: Client) : Service(client) { /** * Get user locale @@ -32,6 +31,7 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Locale = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Locale.from(map = it as Map) } return client.call( @@ -62,6 +62,7 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LocaleCodeList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.LocaleCodeList.from(map = it as Map) } return client.call( @@ -92,6 +93,7 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.ContinentList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.ContinentList.from(map = it as Map) } return client.call( @@ -122,6 +124,7 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CountryList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.CountryList.from(map = it as Map) } return client.call( @@ -152,6 +155,7 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CountryList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.CountryList.from(map = it as Map) } return client.call( @@ -182,6 +186,7 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.PhoneList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.PhoneList.from(map = it as Map) } return client.call( @@ -212,6 +217,7 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CurrencyList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.CurrencyList.from(map = it as Map) } return client.call( @@ -242,6 +248,7 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LanguageList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.LanguageList.from(map = it as Map) } return client.call( diff --git a/library/src/main/java/io/appwrite/services/Messaging.kt b/library/src/main/java/io/appwrite/services/Messaging.kt new file mode 100644 index 0000000..2035dbf --- /dev/null +++ b/library/src/main/java/io/appwrite/services/Messaging.kt @@ -0,0 +1,89 @@ +package io.appwrite.services + +import android.net.Uri +import io.appwrite.Client +import io.appwrite.models.* +import io.appwrite.enums.* +import io.appwrite.exceptions.AppwriteException +import io.appwrite.extensions.classOf +import okhttp3.Cookie +import java.io.File + +/** + * The Messaging service allows you to send messages to any provider type (SMTP, push notification, SMS, etc.). +**/ +class Messaging(client: Client) : Service(client) { + + /** + * Create a subscriber. + * + * + * + * @param topicId Topic ID. The topic ID to subscribe to. + * @param subscriberId Subscriber ID. Choose a custom Subscriber ID or a new Subscriber ID. + * @param targetId Target ID. The target ID to link to the specified Topic ID. + * @return [io.appwrite.models.Subscriber] + */ + suspend fun createSubscriber( + topicId: String, + subscriberId: String, + targetId: String, + ): io.appwrite.models.Subscriber { + val apiPath = "/messaging/topics/{topicId}/subscribers" + .replace("{topicId}", topicId) + + val apiParams = mutableMapOf( + "subscriberId" to subscriberId, + "targetId" to targetId, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Subscriber = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Subscriber.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Subscriber::class.java, + converter, + ) + } + + + /** + * Delete a subscriber. + * + * + * + * @param topicId Topic ID. The topic ID subscribed to. + * @param subscriberId Subscriber ID. + * @return [Any] + */ + suspend fun deleteSubscriber( + topicId: String, + subscriberId: String, + ): Any { + val apiPath = "/messaging/topics/{topicId}/subscribers/{subscriberId}" + .replace("{topicId}", topicId) + .replace("{subscriberId}", subscriberId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = Any::class.java, + ) + } + + +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Realtime.kt b/library/src/main/java/io/appwrite/services/Realtime.kt index 316054a..e3709e5 100644 --- a/library/src/main/java/io/appwrite/services/Realtime.kt +++ b/library/src/main/java/io/appwrite/services/Realtime.kt @@ -55,7 +55,7 @@ class Realtime(client: Client) : Service(client), CoroutineScope { } val request = Request.Builder() - .url("${client.endPointRealtime}/realtime?$queryParamBuilder") + .url("${client.endpointRealtime}/realtime?$queryParamBuilder") .build() if (socket != null) { diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index 2b49f56..3830e20 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -3,6 +3,7 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client import io.appwrite.models.* +import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import okhttp3.Cookie @@ -13,9 +14,7 @@ import java.io.File /** * The Storage service allows you to manage your project files. **/ -class Storage : Service { - - public constructor (client: Client) : super(client) { } +class Storage(client: Client) : Service(client) { /** * List files @@ -44,6 +43,7 @@ class Storage : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.FileList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.FileList.from(map = it as Map) } return client.call( @@ -88,6 +88,7 @@ class Storage : Service { "content-type" to "multipart/form-data", ) val converter: (Any) -> io.appwrite.models.File = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.File.from(map = it as Map) } val idParamName: String? = "fileId" @@ -128,6 +129,7 @@ class Storage : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.File = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.File.from(map = it as Map) } return client.call( @@ -171,6 +173,7 @@ class Storage : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.File = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.File.from(map = it as Map) } return client.call( @@ -271,7 +274,7 @@ class Storage : Service { fileId: String, width: Long? = null, height: Long? = null, - gravity: String? = null, + gravity: ImageGravity? = null, quality: Long? = null, borderWidth: Long? = null, borderColor: String? = null, @@ -279,7 +282,7 @@ class Storage : Service { opacity: Double? = null, rotation: Long? = null, background: String? = null, - output: String? = null, + output: ImageFormat? = null, ): ByteArray { val apiPath = "/storage/buckets/{bucketId}/files/{fileId}/preview" .replace("{bucketId}", bucketId) diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 7f303ab..8c89184 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -3,6 +3,7 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client import io.appwrite.models.* +import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import okhttp3.Cookie @@ -11,16 +12,14 @@ 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) { } +class Teams(client: Client) : Service(client) { /** * 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. * - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total, billingPlan * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.TeamList] */ @@ -40,6 +39,7 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.TeamList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.TeamList.from(map = it as Map, nestedType) } return client.call( @@ -57,7 +57,7 @@ class Teams : Service { * * Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results. * - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total, billingPlan * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.TeamList] */ @@ -100,6 +100,7 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Team = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Team.from(map = it as Map, nestedType) } return client.call( @@ -156,6 +157,7 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Team = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Team.from(map = it as Map, nestedType) } return client.call( @@ -208,6 +210,7 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Team = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Team.from(map = it as Map, nestedType) } return client.call( @@ -295,6 +298,7 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MembershipList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.MembershipList.from(map = it as Map) } return client.call( @@ -347,6 +351,7 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Membership.from(map = it as Map) } return client.call( @@ -383,6 +388,7 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Membership.from(map = it as Map) } return client.call( @@ -422,6 +428,7 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Membership.from(map = it as Map) } return client.call( @@ -496,6 +503,7 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Membership.from(map = it as Map) } return client.call( @@ -530,6 +538,7 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Preferences.from(map = it as Map, nestedType) } return client.call( @@ -582,6 +591,7 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Preferences.from(map = it as Map, nestedType) } return client.call( diff --git a/library/src/main/java/io/appwrite/services/Users.kt b/library/src/main/java/io/appwrite/services/Users.kt new file mode 100644 index 0000000..e425c70 --- /dev/null +++ b/library/src/main/java/io/appwrite/services/Users.kt @@ -0,0 +1,113 @@ +package io.appwrite.services + +import android.net.Uri +import io.appwrite.Client +import io.appwrite.models.* +import io.appwrite.enums.* +import io.appwrite.exceptions.AppwriteException +import io.appwrite.extensions.classOf +import okhttp3.Cookie +import java.io.File + +/** + * The Users service allows you to manage your project users. +**/ +class Users(client: Client) : Service(client) { + + /** + * Delete Authenticator + * + * + * + * @param userId User ID. + * @param provider Provider. + * @param otp Valid verification token. + * @return [io.appwrite.models.User] + */ + suspend fun deleteAuthenticator( + userId: String, + provider: AuthenticatorProvider, + otp: String, + nestedType: Class, + ): io.appwrite.models.User { + val apiPath = "/users/{userId}/mfa/{provider}" + .replace("{userId}", userId) + .replace("{provider}", provider.value) + + val apiParams = mutableMapOf( + "otp" to otp, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.User.from(map = it as Map, nestedType) + } + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Delete Authenticator + * + * + * + * @param userId User ID. + * @param provider Provider. + * @param otp Valid verification token. + * @return [io.appwrite.models.User] + */ + @Throws(AppwriteException::class) + suspend fun deleteAuthenticator( + userId: String, + provider: AuthenticatorProvider, + otp: String, + ): io.appwrite.models.User> = deleteAuthenticator( + userId, + provider, + otp, + nestedType = classOf(), + ) + + /** + * List Providers + * + * + * + * @param userId User ID. + * @return [io.appwrite.models.MfaProviders] + */ + suspend fun listProviders( + userId: String, + ): io.appwrite.models.MfaProviders { + val apiPath = "/users/{userId}/providers" + .replace("{userId}", userId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.MfaProviders = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.MfaProviders.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.MfaProviders::class.java, + converter, + ) + } + + +} \ No newline at end of file diff --git a/scripts/publish-module.gradle b/scripts/publish-module.gradle index e32ff84..96b31b2 100644 --- a/scripts/publish-module.gradle +++ b/scripts/publish-module.gradle @@ -63,7 +63,8 @@ publishing { configurations .getByName("releaseCompileClasspath") .resolvedConfiguration - .firstLevelModuleDependencies.forEach { + .firstLevelModuleDependencies + .forEach { def dependency = dependencies.appendNode("dependency") dependency.appendNode("groupId", it.moduleGroup) dependency.appendNode("artifactId", it.moduleName) diff --git a/settings.gradle b/settings.gradle index 73c359b..423c64e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,3 @@ rootProject.name = "Appwrite Android SDK" include ':example' -include ':library' -include ':example-java' \ No newline at end of file +include ':library' \ No newline at end of file From d42be7aa6628d2dbdb5248bfdca9a8e8572257fb Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 7 Feb 2024 19:24:01 +1300 Subject: [PATCH 060/118] Fixes for nested query parsing and MFA route authentication types --- .../java/users/delete-authenticator.md | 24 ---- docs/examples/java/users/list-providers.md | 21 ---- .../kotlin/users/delete-authenticator.md | 16 --- docs/examples/kotlin/users/list-providers.md | 13 -- .../main/java/io/appwrite/models/Session.kt | 4 +- .../main/java/io/appwrite/services/Users.kt | 113 ------------------ 6 files changed, 2 insertions(+), 189 deletions(-) delete mode 100644 docs/examples/java/users/delete-authenticator.md delete mode 100644 docs/examples/java/users/list-providers.md delete mode 100644 docs/examples/kotlin/users/delete-authenticator.md delete mode 100644 docs/examples/kotlin/users/list-providers.md delete mode 100644 library/src/main/java/io/appwrite/services/Users.kt diff --git a/docs/examples/java/users/delete-authenticator.md b/docs/examples/java/users/delete-authenticator.md deleted file mode 100644 index 2de3df7..0000000 --- a/docs/examples/java/users/delete-authenticator.md +++ /dev/null @@ -1,24 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Users; -import io.appwrite.enums.AuthenticatorProvider; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - -Users users = new Users(client); - -users.deleteAuthenticator( - "[USER_ID]", - AuthenticatorProvider.TOTP, - "[OTP]", - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); \ No newline at end of file diff --git a/docs/examples/java/users/list-providers.md b/docs/examples/java/users/list-providers.md deleted file mode 100644 index ca2f27d..0000000 --- a/docs/examples/java/users/list-providers.md +++ /dev/null @@ -1,21 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Users; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - -Users users = new Users(client); - -users.listProviders( - "[USER_ID]", - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); \ No newline at end of file diff --git a/docs/examples/kotlin/users/delete-authenticator.md b/docs/examples/kotlin/users/delete-authenticator.md deleted file mode 100644 index 9c36173..0000000 --- a/docs/examples/kotlin/users/delete-authenticator.md +++ /dev/null @@ -1,16 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Users -import io.appwrite.enums.AuthenticatorProvider - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - -val users = Users(client) - -val response = users.deleteAuthenticator( - userId = "[USER_ID]", - provider = AuthenticatorProvider.TOTP, - otp = "[OTP]", -) \ No newline at end of file diff --git a/docs/examples/kotlin/users/list-providers.md b/docs/examples/kotlin/users/list-providers.md deleted file mode 100644 index 008cf93..0000000 --- a/docs/examples/kotlin/users/list-providers.md +++ /dev/null @@ -1,13 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Users - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - -val users = Users(client) - -val response = users.listProviders( - userId = "[USER_ID]", -) \ 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 acf70cd..da71926 100644 --- a/library/src/main/java/io/appwrite/models/Session.kt +++ b/library/src/main/java/io/appwrite/models/Session.kt @@ -161,7 +161,7 @@ data class Session( * Returns a list of active session factors. */ @SerializedName("factors") - val factors: Long, + val factors: List, /** * Secret used to authenticate the user. Only included if the request was made with an API key @@ -231,7 +231,7 @@ data class Session( countryCode = map["countryCode"] as String, countryName = map["countryName"] as String, current = map["current"] as Boolean, - factors = (map["factors"] as Number).toLong(), + factors = map["factors"] as List, secret = map["secret"] as String, ) } diff --git a/library/src/main/java/io/appwrite/services/Users.kt b/library/src/main/java/io/appwrite/services/Users.kt deleted file mode 100644 index e425c70..0000000 --- a/library/src/main/java/io/appwrite/services/Users.kt +++ /dev/null @@ -1,113 +0,0 @@ -package io.appwrite.services - -import android.net.Uri -import io.appwrite.Client -import io.appwrite.models.* -import io.appwrite.enums.* -import io.appwrite.exceptions.AppwriteException -import io.appwrite.extensions.classOf -import okhttp3.Cookie -import java.io.File - -/** - * The Users service allows you to manage your project users. -**/ -class Users(client: Client) : Service(client) { - - /** - * Delete Authenticator - * - * - * - * @param userId User ID. - * @param provider Provider. - * @param otp Valid verification token. - * @return [io.appwrite.models.User] - */ - suspend fun deleteAuthenticator( - userId: String, - provider: AuthenticatorProvider, - otp: String, - nestedType: Class, - ): io.appwrite.models.User { - val apiPath = "/users/{userId}/mfa/{provider}" - .replace("{userId}", userId) - .replace("{provider}", provider.value) - - val apiParams = mutableMapOf( - "otp" to otp, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.User = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.User.from(map = it as Map, nestedType) - } - return client.call( - "DELETE", - apiPath, - apiHeaders, - apiParams, - responseType = classOf(), - converter, - ) - } - - /** - * Delete Authenticator - * - * - * - * @param userId User ID. - * @param provider Provider. - * @param otp Valid verification token. - * @return [io.appwrite.models.User] - */ - @Throws(AppwriteException::class) - suspend fun deleteAuthenticator( - userId: String, - provider: AuthenticatorProvider, - otp: String, - ): io.appwrite.models.User> = deleteAuthenticator( - userId, - provider, - otp, - nestedType = classOf(), - ) - - /** - * List Providers - * - * - * - * @param userId User ID. - * @return [io.appwrite.models.MfaProviders] - */ - suspend fun listProviders( - userId: String, - ): io.appwrite.models.MfaProviders { - val apiPath = "/users/{userId}/providers" - .replace("{userId}", userId) - - val apiParams = mutableMapOf( - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.MfaProviders = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.MfaProviders.from(map = it as Map) - } - return client.call( - "GET", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.MfaProviders::class.java, - converter, - ) - } - - -} \ No newline at end of file From 946cbe722e25c675362531eb6fe7ae8d3e7ceaf6 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 14 Feb 2024 07:23:05 +0000 Subject: [PATCH 061/118] chore: bug fixes and improvements --- README.md | 6 +- build.gradle | 11 +- .../java/account/add-authenticator.md | 22 - .../java/account/create-anonymous-session.md | 2 +- .../examples/java/account/create-challenge.md | 22 - .../account/create-email-password-session.md | 22 - ...email-token.md => create-email-session.md} | 6 +- docs/examples/java/account/create-j-w-t.md | 2 +- ...token.md => create-magic-u-r-l-session.md} | 4 +- .../java/account/create-o-auth2session.md | 5 +- ...phone-token.md => create-phone-session.md} | 6 +- .../java/account/create-phone-verification.md | 2 +- .../java/account/create-push-target.md | 22 - docs/examples/java/account/create-recovery.md | 4 +- .../java/account/create-verification.md | 4 +- docs/examples/java/account/create.md | 2 +- .../java/account/delete-authenticator.md | 23 - docs/examples/java/account/delete-identity.md | 4 +- .../java/account/delete-push-target.md | 21 - docs/examples/java/account/delete-session.md | 4 +- docs/examples/java/account/delete-sessions.md | 2 +- docs/examples/java/account/get-prefs.md | 2 +- docs/examples/java/account/get-session.md | 4 +- docs/examples/java/account/get.md | 2 +- docs/examples/java/account/list-factors.md | 18 - docs/examples/java/account/list-identities.md | 2 +- docs/examples/java/account/list-logs.md | 2 +- docs/examples/java/account/list-sessions.md | 2 +- .../examples/java/account/update-challenge.md | 22 - docs/examples/java/account/update-email.md | 4 +- docs/examples/java/account/update-m-f-a.md | 21 - .../account/update-magic-u-r-l-session.md | 4 +- docs/examples/java/account/update-name.md | 4 +- docs/examples/java/account/update-password.md | 2 +- ...ate-session.md => update-phone-session.md} | 6 +- .../java/account/update-phone-verification.md | 4 +- docs/examples/java/account/update-phone.md | 4 +- docs/examples/java/account/update-prefs.md | 4 +- .../java/account/update-push-target.md | 22 - docs/examples/java/account/update-recovery.md | 5 +- docs/examples/java/account/update-session.md | 4 +- docs/examples/java/account/update-status.md | 2 +- .../java/account/update-verification.md | 4 +- .../java/account/verify-authenticator.md | 23 - docs/examples/java/avatars/get-browser.md | 5 +- docs/examples/java/avatars/get-credit-card.md | 5 +- docs/examples/java/avatars/get-favicon.md | 4 +- docs/examples/java/avatars/get-flag.md | 5 +- docs/examples/java/avatars/get-image.md | 2 +- docs/examples/java/avatars/get-initials.md | 2 +- docs/examples/java/avatars/get-q-r.md | 2 +- .../java/databases/create-document.md | 2 +- .../java/databases/delete-document.md | 4 +- docs/examples/java/databases/get-document.md | 2 +- .../examples/java/databases/list-documents.md | 2 +- .../java/databases/update-document.md | 2 +- .../java/functions/create-execution.md | 2 +- docs/examples/java/functions/get-execution.md | 4 +- .../java/functions/list-executions.md | 2 +- docs/examples/java/graphql/mutation.md | 4 +- docs/examples/java/graphql/query.md | 4 +- docs/examples/java/locale/get.md | 2 +- docs/examples/java/locale/list-codes.md | 2 +- docs/examples/java/locale/list-continents.md | 2 +- .../java/locale/list-countries-e-u.md | 2 +- .../java/locale/list-countries-phones.md | 2 +- docs/examples/java/locale/list-countries.md | 2 +- docs/examples/java/locale/list-currencies.md | 2 +- docs/examples/java/locale/list-languages.md | 2 +- .../java/messaging/create-subscriber.md | 23 - .../java/messaging/delete-subscriber.md | 22 - docs/examples/java/storage/create-file.md | 2 +- docs/examples/java/storage/delete-file.md | 4 +- .../java/storage/get-file-download.md | 4 +- .../examples/java/storage/get-file-preview.md | 2 +- docs/examples/java/storage/get-file-view.md | 4 +- docs/examples/java/storage/get-file.md | 4 +- docs/examples/java/storage/list-files.md | 2 +- docs/examples/java/storage/update-file.md | 2 +- docs/examples/java/teams/create-membership.md | 2 +- docs/examples/java/teams/create.md | 2 +- docs/examples/java/teams/delete-membership.md | 4 +- docs/examples/java/teams/delete.md | 4 +- docs/examples/java/teams/get-membership.md | 4 +- docs/examples/java/teams/get-prefs.md | 4 +- docs/examples/java/teams/get.md | 4 +- docs/examples/java/teams/list-memberships.md | 2 +- docs/examples/java/teams/list.md | 2 +- .../java/teams/update-membership-status.md | 4 +- docs/examples/java/teams/update-membership.md | 4 +- docs/examples/java/teams/update-name.md | 4 +- docs/examples/java/teams/update-prefs.md | 4 +- .../kotlin/account/add-authenticator.md | 14 - .../account/create-anonymous-session.md | 1 - .../kotlin/account/create-challenge.md | 14 - .../account/create-email-password-session.md | 14 - ...u-r-l-token.md => create-email-session.md} | 7 +- docs/examples/kotlin/account/create-j-w-t.md | 1 - ...token.md => create-magic-u-r-l-session.md} | 5 +- .../kotlin/account/create-o-auth2session.md | 6 +- ...pdate-m-f-a.md => create-phone-session.md} | 8 +- .../kotlin/account/create-phone-token.md | 14 - .../account/create-phone-verification.md | 1 - .../kotlin/account/create-push-target.md | 14 - .../kotlin/account/create-recovery.md | 5 +- .../examples/kotlin/account/create-session.md | 14 - .../kotlin/account/create-verification.md | 5 +- docs/examples/kotlin/account/create.md | 3 +- .../kotlin/account/delete-authenticator.md | 15 - .../kotlin/account/delete-identity.md | 5 +- .../kotlin/account/delete-push-target.md | 13 - .../examples/kotlin/account/delete-session.md | 5 +- .../kotlin/account/delete-sessions.md | 1 - docs/examples/kotlin/account/get-prefs.md | 1 - docs/examples/kotlin/account/get-session.md | 5 +- docs/examples/kotlin/account/get.md | 1 - .../kotlin/account/list-identities.md | 3 +- docs/examples/kotlin/account/list-logs.md | 3 +- docs/examples/kotlin/account/list-sessions.md | 1 - .../kotlin/account/update-challenge.md | 14 - docs/examples/kotlin/account/update-email.md | 5 +- .../account/update-magic-u-r-l-session.md | 5 +- docs/examples/kotlin/account/update-name.md | 5 +- .../kotlin/account/update-password.md | 3 +- ...ist-factors.md => update-phone-session.md} | 6 +- .../account/update-phone-verification.md | 5 +- docs/examples/kotlin/account/update-phone.md | 5 +- docs/examples/kotlin/account/update-prefs.md | 5 +- .../kotlin/account/update-push-target.md | 14 - .../kotlin/account/update-recovery.md | 6 +- .../examples/kotlin/account/update-session.md | 5 +- docs/examples/kotlin/account/update-status.md | 1 - .../kotlin/account/update-verification.md | 5 +- .../kotlin/account/verify-authenticator.md | 15 - docs/examples/kotlin/avatars/get-browser.md | 8 +- .../kotlin/avatars/get-credit-card.md | 8 +- docs/examples/kotlin/avatars/get-favicon.md | 7 +- docs/examples/kotlin/avatars/get-flag.md | 8 +- docs/examples/kotlin/avatars/get-image.md | 5 +- docs/examples/kotlin/avatars/get-initials.md | 5 +- docs/examples/kotlin/avatars/get-q-r.md | 5 +- .../kotlin/databases/create-document.md | 3 +- .../kotlin/databases/delete-document.md | 5 +- .../examples/kotlin/databases/get-document.md | 3 +- .../kotlin/databases/list-documents.md | 3 +- .../kotlin/databases/update-document.md | 3 +- .../kotlin/functions/create-execution.md | 3 +- .../kotlin/functions/get-execution.md | 5 +- .../kotlin/functions/list-executions.md | 3 +- docs/examples/kotlin/graphql/mutation.md | 5 +- docs/examples/kotlin/graphql/query.md | 5 +- docs/examples/kotlin/locale/get.md | 1 - docs/examples/kotlin/locale/list-codes.md | 1 - .../examples/kotlin/locale/list-continents.md | 1 - .../kotlin/locale/list-countries-e-u.md | 1 - .../kotlin/locale/list-countries-phones.md | 1 - docs/examples/kotlin/locale/list-countries.md | 1 - .../examples/kotlin/locale/list-currencies.md | 1 - docs/examples/kotlin/locale/list-languages.md | 1 - .../kotlin/messaging/create-subscriber.md | 15 - .../kotlin/messaging/delete-subscriber.md | 14 - docs/examples/kotlin/storage/create-file.md | 3 +- docs/examples/kotlin/storage/delete-file.md | 5 +- .../kotlin/storage/get-file-download.md | 7 +- .../kotlin/storage/get-file-preview.md | 5 +- docs/examples/kotlin/storage/get-file-view.md | 7 +- docs/examples/kotlin/storage/get-file.md | 5 +- docs/examples/kotlin/storage/list-files.md | 3 +- docs/examples/kotlin/storage/update-file.md | 3 +- .../kotlin/teams/create-membership.md | 3 +- docs/examples/kotlin/teams/create.md | 3 +- .../kotlin/teams/delete-membership.md | 5 +- docs/examples/kotlin/teams/delete.md | 5 +- docs/examples/kotlin/teams/get-membership.md | 5 +- docs/examples/kotlin/teams/get-prefs.md | 5 +- docs/examples/kotlin/teams/get.md | 5 +- .../examples/kotlin/teams/list-memberships.md | 3 +- docs/examples/kotlin/teams/list.md | 3 +- .../kotlin/teams/update-membership-status.md | 5 +- .../kotlin/teams/update-membership.md | 5 +- docs/examples/kotlin/teams/update-name.md | 5 +- docs/examples/kotlin/teams/update-prefs.md | 5 +- example-java/.gitignore | 1 + example-java/build.gradle | 39 + example-java/src/main/AndroidManifest.xml | 21 + .../appwrite/example_java/MainActivity.java | 34 + .../res/drawable/ic_launcher_background.xml | 170 +++++ .../res/drawable/ic_launcher_foreground.xml | 30 + .../src/main/res/layout/activity_main.xml | 18 + .../res/mipmap-anydpi-v26/ic_launcher.xml | 5 + .../mipmap-anydpi-v26/ic_launcher_round.xml | 5 + example-java/src/main/res/values/colors.xml | 10 + example-java/src/main/res/values/strings.xml | 3 + example-java/src/main/res/values/themes.xml | 16 + example/build.gradle | 31 +- example/src/main/AndroidManifest.xml | 13 +- .../android/ui/accounts/AccountsFragment.kt | 16 +- .../android/ui/accounts/AccountsViewModel.kt | 17 +- .../java/io/appwrite/android/utils/Client.kt | 11 +- .../src/main/res/layout/fragment_account.xml | 1 - gradle/wrapper/gradle-wrapper.properties | 2 +- library/build.gradle | 44 +- library/src/main/AndroidManifest.xml | 7 +- library/src/main/java/io/appwrite/Client.kt | 84 +-- .../java/io/appwrite/NotificationHandler.kt | 410 ----------- library/src/main/java/io/appwrite/Query.kt | 79 +- .../appwrite/cookies/ListenableCookieJar.kt | 119 --- .../cookies/stores/InMemoryCookieStore.kt | 13 +- .../stores/SharedPreferencesCookieStore.kt | 10 +- .../io/appwrite/enums/AuthenticatorFactor.kt | 7 - .../appwrite/enums/AuthenticatorProvider.kt | 7 - .../main/java/io/appwrite/enums/Browser.kt | 20 - .../main/java/io/appwrite/enums/CreditCard.kt | 22 - .../java/io/appwrite/enums/ExecutionMethod.kt | 12 - .../src/main/java/io/appwrite/enums/Flag.kt | 200 ----- .../java/io/appwrite/enums/ImageFormat.kt | 11 - .../java/io/appwrite/enums/ImageGravity.kt | 15 - .../java/io/appwrite/enums/OAuthProvider.kt | 45 -- .../appwrite/extensions/ActivityExtensions.kt | 46 -- .../extensions/MessagingExtensions.kt | 14 - .../io/appwrite/extensions/TypeExtensions.kt | 1 - .../java/io/appwrite/models/Membership.kt | 8 - .../java/io/appwrite/models/MfaChallenge.kt | 54 -- .../java/io/appwrite/models/MfaProvider.kt | 46 -- .../java/io/appwrite/models/MfaProviders.kt | 46 -- .../java/io/appwrite/models/Notification.kt | 12 - .../main/java/io/appwrite/models/Session.kt | 16 - .../java/io/appwrite/models/Subscriber.kt | 94 --- .../main/java/io/appwrite/models/Target.kt | 86 --- .../src/main/java/io/appwrite/models/Token.kt | 8 - .../src/main/java/io/appwrite/models/User.kt | 30 - .../main/java/io/appwrite/services/Account.kt | 688 +++--------------- .../main/java/io/appwrite/services/Avatars.kt | 17 +- .../java/io/appwrite/services/Databases.kt | 13 +- .../java/io/appwrite/services/Functions.kt | 10 +- .../main/java/io/appwrite/services/Graphql.kt | 5 +- .../main/java/io/appwrite/services/Locale.kt | 13 +- .../java/io/appwrite/services/Messaging.kt | 89 --- .../java/io/appwrite/services/Realtime.kt | 2 +- .../main/java/io/appwrite/services/Storage.kt | 13 +- .../main/java/io/appwrite/services/Teams.kt | 20 +- scripts/publish-module.gradle | 3 +- settings.gradle | 3 +- 243 files changed, 883 insertions(+), 3041 deletions(-) delete mode 100644 docs/examples/java/account/add-authenticator.md delete mode 100644 docs/examples/java/account/create-challenge.md delete mode 100644 docs/examples/java/account/create-email-password-session.md rename docs/examples/java/account/{create-email-token.md => create-email-session.md} (92%) rename docs/examples/java/account/{create-magic-u-r-l-token.md => create-magic-u-r-l-session.md} (94%) rename docs/examples/java/account/{create-phone-token.md => create-phone-session.md} (91%) delete mode 100644 docs/examples/java/account/create-push-target.md delete mode 100644 docs/examples/java/account/delete-authenticator.md delete mode 100644 docs/examples/java/account/delete-push-target.md delete mode 100644 docs/examples/java/account/list-factors.md delete mode 100644 docs/examples/java/account/update-challenge.md delete mode 100644 docs/examples/java/account/update-m-f-a.md rename docs/examples/java/account/{create-session.md => update-phone-session.md} (92%) delete mode 100644 docs/examples/java/account/update-push-target.md delete mode 100644 docs/examples/java/account/verify-authenticator.md delete mode 100644 docs/examples/java/messaging/create-subscriber.md delete mode 100644 docs/examples/java/messaging/delete-subscriber.md delete mode 100644 docs/examples/kotlin/account/add-authenticator.md delete mode 100644 docs/examples/kotlin/account/create-challenge.md delete mode 100644 docs/examples/kotlin/account/create-email-password-session.md rename docs/examples/kotlin/account/{create-magic-u-r-l-token.md => create-email-session.md} (70%) rename docs/examples/kotlin/account/{create-email-token.md => create-magic-u-r-l-session.md} (77%) rename docs/examples/kotlin/account/{update-m-f-a.md => create-phone-session.md} (71%) delete mode 100644 docs/examples/kotlin/account/create-phone-token.md delete mode 100644 docs/examples/kotlin/account/create-push-target.md delete mode 100644 docs/examples/kotlin/account/create-session.md delete mode 100644 docs/examples/kotlin/account/delete-authenticator.md delete mode 100644 docs/examples/kotlin/account/delete-push-target.md delete mode 100644 docs/examples/kotlin/account/update-challenge.md rename docs/examples/kotlin/account/{list-factors.md => update-phone-session.md} (72%) delete mode 100644 docs/examples/kotlin/account/update-push-target.md delete mode 100644 docs/examples/kotlin/account/verify-authenticator.md delete mode 100644 docs/examples/kotlin/messaging/create-subscriber.md delete mode 100644 docs/examples/kotlin/messaging/delete-subscriber.md create mode 100644 example-java/.gitignore create mode 100644 example-java/build.gradle create mode 100644 example-java/src/main/AndroidManifest.xml create mode 100644 example-java/src/main/java/io/appwrite/example_java/MainActivity.java create mode 100644 example-java/src/main/res/drawable/ic_launcher_background.xml create mode 100644 example-java/src/main/res/drawable/ic_launcher_foreground.xml create mode 100644 example-java/src/main/res/layout/activity_main.xml create mode 100644 example-java/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 example-java/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100644 example-java/src/main/res/values/colors.xml create mode 100644 example-java/src/main/res/values/strings.xml create mode 100644 example-java/src/main/res/values/themes.xml delete mode 100644 library/src/main/java/io/appwrite/NotificationHandler.kt delete mode 100644 library/src/main/java/io/appwrite/cookies/ListenableCookieJar.kt delete mode 100644 library/src/main/java/io/appwrite/enums/AuthenticatorFactor.kt delete mode 100644 library/src/main/java/io/appwrite/enums/AuthenticatorProvider.kt delete mode 100644 library/src/main/java/io/appwrite/enums/Browser.kt delete mode 100644 library/src/main/java/io/appwrite/enums/CreditCard.kt delete mode 100644 library/src/main/java/io/appwrite/enums/ExecutionMethod.kt delete mode 100644 library/src/main/java/io/appwrite/enums/Flag.kt delete mode 100644 library/src/main/java/io/appwrite/enums/ImageFormat.kt delete mode 100644 library/src/main/java/io/appwrite/enums/ImageGravity.kt delete mode 100644 library/src/main/java/io/appwrite/enums/OAuthProvider.kt delete mode 100644 library/src/main/java/io/appwrite/extensions/ActivityExtensions.kt delete mode 100644 library/src/main/java/io/appwrite/extensions/MessagingExtensions.kt delete mode 100644 library/src/main/java/io/appwrite/models/MfaChallenge.kt delete mode 100644 library/src/main/java/io/appwrite/models/MfaProvider.kt delete mode 100644 library/src/main/java/io/appwrite/models/MfaProviders.kt delete mode 100644 library/src/main/java/io/appwrite/models/Notification.kt delete mode 100644 library/src/main/java/io/appwrite/models/Subscriber.kt delete mode 100644 library/src/main/java/io/appwrite/models/Target.kt delete mode 100644 library/src/main/java/io/appwrite/services/Messaging.kt diff --git a/README.md b/README.md index 054a54c..464c725 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![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.5.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.4.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:5.0.0-rc.1") +implementation("io.appwrite:sdk-for-android:4.0.1") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 5.0.0-rc.1 + 4.0.1 ``` diff --git a/build.gradle b/build.gradle index 0b0c86c..f2080e6 100644 --- a/build.gradle +++ b/build.gradle @@ -2,19 +2,20 @@ 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.9.10" - + ext.kotlin_version = "1.8.0" version System.getenv("SDK_VERSION") - repositories { maven { url "https://plugins.gradle.org/m2/" } google() mavenCentral() } dependencies { - classpath "com.android.tools.build:gradle:8.2.2" + 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.3.0" + classpath 'io.github.gradle-nexus:publish-plugin:1.1.0' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files } } diff --git a/docs/examples/java/account/add-authenticator.md b/docs/examples/java/account/add-authenticator.md deleted file mode 100644 index 35935a4..0000000 --- a/docs/examples/java/account/add-authenticator.md +++ /dev/null @@ -1,22 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Account; -import io.appwrite.enums.AuthenticatorFactor; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - -Account account = new Account(client); - -account.addAuthenticator( - AuthenticatorFactor.TOTP, - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); \ No newline at end of file diff --git a/docs/examples/java/account/create-anonymous-session.md b/docs/examples/java/account/create-anonymous-session.md index 46ae275..59c7630 100644 --- a/docs/examples/java/account/create-anonymous-session.md +++ b/docs/examples/java/account/create-anonymous-session.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.createAnonymousSession(new CoroutineCallback<>((result, error) -> { - if (error != null) { + if (error != null) error.printStackTrace(); return; } diff --git a/docs/examples/java/account/create-challenge.md b/docs/examples/java/account/create-challenge.md deleted file mode 100644 index 5080f10..0000000 --- a/docs/examples/java/account/create-challenge.md +++ /dev/null @@ -1,22 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Account; -import io.appwrite.enums.AuthenticatorProvider; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - -Account account = new Account(client); - -account.createChallenge( - AuthenticatorProvider.TOTP, - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); \ No newline at end of file diff --git a/docs/examples/java/account/create-email-password-session.md b/docs/examples/java/account/create-email-password-session.md deleted file mode 100644 index e3cd353..0000000 --- a/docs/examples/java/account/create-email-password-session.md +++ /dev/null @@ -1,22 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Account; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - -Account account = new Account(client); - -account.createEmailPasswordSession( - "email@example.com", - "password", - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); \ No newline at end of file diff --git a/docs/examples/java/account/create-email-token.md b/docs/examples/java/account/create-email-session.md similarity index 92% rename from docs/examples/java/account/create-email-token.md rename to docs/examples/java/account/create-email-session.md index f032eb6..e3e6fdd 100644 --- a/docs/examples/java/account/create-email-token.md +++ b/docs/examples/java/account/create-email-session.md @@ -8,9 +8,9 @@ Client client = new Client(context) Account account = new Account(client); -account.createEmailToken( - "[USER_ID]", +account.createEmailSession( "email@example.com", + "password" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.createEmailToken( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/account/create-j-w-t.md b/docs/examples/java/account/create-j-w-t.md index 13e6e49..c312386 100644 --- a/docs/examples/java/account/create-j-w-t.md +++ b/docs/examples/java/account/create-j-w-t.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.createJWT(new CoroutineCallback<>((result, error) -> { - if (error != null) { + if (error != null) error.printStackTrace(); return; } diff --git a/docs/examples/java/account/create-magic-u-r-l-token.md b/docs/examples/java/account/create-magic-u-r-l-session.md similarity index 94% rename from docs/examples/java/account/create-magic-u-r-l-token.md rename to docs/examples/java/account/create-magic-u-r-l-session.md index 48a8b9b..0ed43dc 100644 --- a/docs/examples/java/account/create-magic-u-r-l-token.md +++ b/docs/examples/java/account/create-magic-u-r-l-session.md @@ -8,7 +8,7 @@ Client client = new Client(context) Account account = new Account(client); -account.createMagicURLToken( +account.createMagicURLSession( "[USER_ID]", "email@example.com", new CoroutineCallback<>((result, error) -> { @@ -19,4 +19,4 @@ account.createMagicURLToken( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/account/create-o-auth2session.md b/docs/examples/java/account/create-o-auth2session.md index 1389673..cb9386a 100644 --- a/docs/examples/java/account/create-o-auth2session.md +++ b/docs/examples/java/account/create-o-auth2session.md @@ -1,7 +1,6 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; -import io.appwrite.enums.OAuthProvider; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -10,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.createOAuth2Session( - OAuthProvider.AMAZON, + "amazon", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +18,4 @@ account.createOAuth2Session( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/account/create-phone-token.md b/docs/examples/java/account/create-phone-session.md similarity index 91% rename from docs/examples/java/account/create-phone-token.md rename to docs/examples/java/account/create-phone-session.md index a839e81..df5bc86 100644 --- a/docs/examples/java/account/create-phone-token.md +++ b/docs/examples/java/account/create-phone-session.md @@ -8,9 +8,9 @@ Client client = new Client(context) Account account = new Account(client); -account.createPhoneToken( +account.createPhoneSession( "[USER_ID]", - "+12065550100", + "+12065550100" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.createPhoneToken( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/account/create-phone-verification.md b/docs/examples/java/account/create-phone-verification.md index ef14ce8..1545d0f 100644 --- a/docs/examples/java/account/create-phone-verification.md +++ b/docs/examples/java/account/create-phone-verification.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.createPhoneVerification(new CoroutineCallback<>((result, error) -> { - if (error != null) { + if (error != null) error.printStackTrace(); return; } diff --git a/docs/examples/java/account/create-push-target.md b/docs/examples/java/account/create-push-target.md deleted file mode 100644 index 18a5e76..0000000 --- a/docs/examples/java/account/create-push-target.md +++ /dev/null @@ -1,22 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Account; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - -Account account = new Account(client); - -account.createPushTarget( - "[TARGET_ID]", - "[IDENTIFIER]", - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); \ No newline at end of file diff --git a/docs/examples/java/account/create-recovery.md b/docs/examples/java/account/create-recovery.md index f167af2..5e8584f 100644 --- a/docs/examples/java/account/create-recovery.md +++ b/docs/examples/java/account/create-recovery.md @@ -10,7 +10,7 @@ Account account = new Account(client); account.createRecovery( "email@example.com", - "https://example.com", + "https://example.com" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.createRecovery( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/account/create-verification.md b/docs/examples/java/account/create-verification.md index eb7a537..fcea98f 100644 --- a/docs/examples/java/account/create-verification.md +++ b/docs/examples/java/account/create-verification.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.createVerification( - "https://example.com", + "https://example.com" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ account.createVerification( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/account/create.md b/docs/examples/java/account/create.md index a16d2c7..e08731f 100644 --- a/docs/examples/java/account/create.md +++ b/docs/examples/java/account/create.md @@ -20,4 +20,4 @@ account.create( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/account/delete-authenticator.md b/docs/examples/java/account/delete-authenticator.md deleted file mode 100644 index d7e4196..0000000 --- a/docs/examples/java/account/delete-authenticator.md +++ /dev/null @@ -1,23 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Account; -import io.appwrite.enums.AuthenticatorProvider; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - -Account account = new Account(client); - -account.deleteAuthenticator( - AuthenticatorProvider.TOTP, - "[OTP]", - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); \ No newline at end of file diff --git a/docs/examples/java/account/delete-identity.md b/docs/examples/java/account/delete-identity.md index f33c29a..0d92d04 100644 --- a/docs/examples/java/account/delete-identity.md +++ b/docs/examples/java/account/delete-identity.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.deleteIdentity( - "[IDENTITY_ID]", + "[IDENTITY_ID]" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ account.deleteIdentity( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/account/delete-push-target.md b/docs/examples/java/account/delete-push-target.md deleted file mode 100644 index 77b21d6..0000000 --- a/docs/examples/java/account/delete-push-target.md +++ /dev/null @@ -1,21 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Account; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - -Account account = new Account(client); - -account.deletePushTarget( - "[TARGET_ID]", - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); \ No newline at end of file diff --git a/docs/examples/java/account/delete-session.md b/docs/examples/java/account/delete-session.md index 2b8d228..28009d0 100644 --- a/docs/examples/java/account/delete-session.md +++ b/docs/examples/java/account/delete-session.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.deleteSession( - "[SESSION_ID]", + "[SESSION_ID]" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ account.deleteSession( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/account/delete-sessions.md b/docs/examples/java/account/delete-sessions.md index 147523e..6bdc840 100644 --- a/docs/examples/java/account/delete-sessions.md +++ b/docs/examples/java/account/delete-sessions.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.deleteSessions(new CoroutineCallback<>((result, error) -> { - if (error != null) { + if (error != null) error.printStackTrace(); return; } diff --git a/docs/examples/java/account/get-prefs.md b/docs/examples/java/account/get-prefs.md index bfa3c1a..9911ad3 100644 --- a/docs/examples/java/account/get-prefs.md +++ b/docs/examples/java/account/get-prefs.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.getPrefs(new CoroutineCallback<>((result, error) -> { - if (error != null) { + if (error != null) error.printStackTrace(); return; } diff --git a/docs/examples/java/account/get-session.md b/docs/examples/java/account/get-session.md index dd9c89c..fecb543 100644 --- a/docs/examples/java/account/get-session.md +++ b/docs/examples/java/account/get-session.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.getSession( - "[SESSION_ID]", + "[SESSION_ID]" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ account.getSession( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/account/get.md b/docs/examples/java/account/get.md index 9006cb8..2e5f40a 100644 --- a/docs/examples/java/account/get.md +++ b/docs/examples/java/account/get.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.get(new CoroutineCallback<>((result, error) -> { - if (error != null) { + if (error != null) error.printStackTrace(); return; } diff --git a/docs/examples/java/account/list-factors.md b/docs/examples/java/account/list-factors.md deleted file mode 100644 index e2d92b5..0000000 --- a/docs/examples/java/account/list-factors.md +++ /dev/null @@ -1,18 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Account; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - -Account account = new Account(client); - -account.listFactors(new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); -})); diff --git a/docs/examples/java/account/list-identities.md b/docs/examples/java/account/list-identities.md index 08d4c19..d1f6a48 100644 --- a/docs/examples/java/account/list-identities.md +++ b/docs/examples/java/account/list-identities.md @@ -17,4 +17,4 @@ account.listIdentities( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/account/list-logs.md b/docs/examples/java/account/list-logs.md index f4c39fb..d2ce790 100644 --- a/docs/examples/java/account/list-logs.md +++ b/docs/examples/java/account/list-logs.md @@ -17,4 +17,4 @@ account.listLogs( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/account/list-sessions.md b/docs/examples/java/account/list-sessions.md index 9e70f0d..7fd587e 100644 --- a/docs/examples/java/account/list-sessions.md +++ b/docs/examples/java/account/list-sessions.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.listSessions(new CoroutineCallback<>((result, error) -> { - if (error != null) { + if (error != null) error.printStackTrace(); return; } diff --git a/docs/examples/java/account/update-challenge.md b/docs/examples/java/account/update-challenge.md deleted file mode 100644 index d972a14..0000000 --- a/docs/examples/java/account/update-challenge.md +++ /dev/null @@ -1,22 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Account; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - -Account account = new Account(client); - -account.updateChallenge( - "[CHALLENGE_ID]", - "[OTP]", - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); \ No newline at end of file diff --git a/docs/examples/java/account/update-email.md b/docs/examples/java/account/update-email.md index a7cb414..8034ada 100644 --- a/docs/examples/java/account/update-email.md +++ b/docs/examples/java/account/update-email.md @@ -10,7 +10,7 @@ Account account = new Account(client); account.updateEmail( "email@example.com", - "password", + "password" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.updateEmail( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/account/update-m-f-a.md b/docs/examples/java/account/update-m-f-a.md deleted file mode 100644 index 16f6973..0000000 --- a/docs/examples/java/account/update-m-f-a.md +++ /dev/null @@ -1,21 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Account; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - -Account account = new Account(client); - -account.updateMFA( - false, - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); \ No newline at end of file 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 f46422b..0f8f2b3 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 @@ -10,7 +10,7 @@ Account account = new Account(client); account.updateMagicURLSession( "[USER_ID]", - "[SECRET]", + "[SECRET]" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.updateMagicURLSession( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/account/update-name.md b/docs/examples/java/account/update-name.md index 8b27389..5940f93 100644 --- a/docs/examples/java/account/update-name.md +++ b/docs/examples/java/account/update-name.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.updateName( - "[NAME]", + "[NAME]" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ account.updateName( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/account/update-password.md b/docs/examples/java/account/update-password.md index 430ab7e..d942632 100644 --- a/docs/examples/java/account/update-password.md +++ b/docs/examples/java/account/update-password.md @@ -18,4 +18,4 @@ account.updatePassword( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/account/create-session.md b/docs/examples/java/account/update-phone-session.md similarity index 92% rename from docs/examples/java/account/create-session.md rename to docs/examples/java/account/update-phone-session.md index d853209..589e4ff 100644 --- a/docs/examples/java/account/create-session.md +++ b/docs/examples/java/account/update-phone-session.md @@ -8,9 +8,9 @@ Client client = new Client(context) Account account = new Account(client); -account.createSession( +account.updatePhoneSession( "[USER_ID]", - "[SECRET]", + "[SECRET]" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.createSession( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/account/update-phone-verification.md b/docs/examples/java/account/update-phone-verification.md index 7d66fd9..81785f9 100644 --- a/docs/examples/java/account/update-phone-verification.md +++ b/docs/examples/java/account/update-phone-verification.md @@ -10,7 +10,7 @@ Account account = new Account(client); account.updatePhoneVerification( "[USER_ID]", - "[SECRET]", + "[SECRET]" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.updatePhoneVerification( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/account/update-phone.md b/docs/examples/java/account/update-phone.md index c958911..a8572f9 100644 --- a/docs/examples/java/account/update-phone.md +++ b/docs/examples/java/account/update-phone.md @@ -10,7 +10,7 @@ Account account = new Account(client); account.updatePhone( "+12065550100", - "password", + "password" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.updatePhone( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/account/update-prefs.md b/docs/examples/java/account/update-prefs.md index 5d2e75d..ffd5ef0 100644 --- a/docs/examples/java/account/update-prefs.md +++ b/docs/examples/java/account/update-prefs.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.updatePrefs( - mapOf( "a" to "b" ), + mapOf( "a" to "b" ) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ account.updatePrefs( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/account/update-push-target.md b/docs/examples/java/account/update-push-target.md deleted file mode 100644 index 10efbad..0000000 --- a/docs/examples/java/account/update-push-target.md +++ /dev/null @@ -1,22 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Account; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - -Account account = new Account(client); - -account.updatePushTarget( - "[TARGET_ID]", - "[IDENTIFIER]", - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); \ No newline at end of file diff --git a/docs/examples/java/account/update-recovery.md b/docs/examples/java/account/update-recovery.md index 313eaa5..7b0f392 100644 --- a/docs/examples/java/account/update-recovery.md +++ b/docs/examples/java/account/update-recovery.md @@ -11,7 +11,8 @@ Account account = new Account(client); account.updateRecovery( "[USER_ID]", "[SECRET]", - "", + "password", + "password" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -20,4 +21,4 @@ account.updateRecovery( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/account/update-session.md b/docs/examples/java/account/update-session.md index 66eda54..27b8f00 100644 --- a/docs/examples/java/account/update-session.md +++ b/docs/examples/java/account/update-session.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.updateSession( - "[SESSION_ID]", + "[SESSION_ID]" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ account.updateSession( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/account/update-status.md b/docs/examples/java/account/update-status.md index 61cb944..1e18ded 100644 --- a/docs/examples/java/account/update-status.md +++ b/docs/examples/java/account/update-status.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.updateStatus(new CoroutineCallback<>((result, error) -> { - if (error != null) { + if (error != null) error.printStackTrace(); return; } diff --git a/docs/examples/java/account/update-verification.md b/docs/examples/java/account/update-verification.md index 9beb1bd..d852dbf 100644 --- a/docs/examples/java/account/update-verification.md +++ b/docs/examples/java/account/update-verification.md @@ -10,7 +10,7 @@ Account account = new Account(client); account.updateVerification( "[USER_ID]", - "[SECRET]", + "[SECRET]" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.updateVerification( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/account/verify-authenticator.md b/docs/examples/java/account/verify-authenticator.md deleted file mode 100644 index 7a99ffc..0000000 --- a/docs/examples/java/account/verify-authenticator.md +++ /dev/null @@ -1,23 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Account; -import io.appwrite.enums.AuthenticatorFactor; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - -Account account = new Account(client); - -account.verifyAuthenticator( - AuthenticatorFactor.TOTP, - "[OTP]", - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); \ No newline at end of file diff --git a/docs/examples/java/avatars/get-browser.md b/docs/examples/java/avatars/get-browser.md index 0652a47..f072110 100644 --- a/docs/examples/java/avatars/get-browser.md +++ b/docs/examples/java/avatars/get-browser.md @@ -1,7 +1,6 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Avatars; -import io.appwrite.enums.Browser; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -10,7 +9,7 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); avatars.getBrowser( - Browser.AVANT_BROWSER, + "aa", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +18,4 @@ avatars.getBrowser( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/avatars/get-credit-card.md b/docs/examples/java/avatars/get-credit-card.md index 0f0541a..0a73312 100644 --- a/docs/examples/java/avatars/get-credit-card.md +++ b/docs/examples/java/avatars/get-credit-card.md @@ -1,7 +1,6 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Avatars; -import io.appwrite.enums.CreditCard; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -10,7 +9,7 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); avatars.getCreditCard( - CreditCard.AMERICAN_EXPRESS, + "amex", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +18,4 @@ avatars.getCreditCard( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/avatars/get-favicon.md b/docs/examples/java/avatars/get-favicon.md index cef5b08..e0c1cb6 100644 --- a/docs/examples/java/avatars/get-favicon.md +++ b/docs/examples/java/avatars/get-favicon.md @@ -9,7 +9,7 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); avatars.getFavicon( - "https://example.com", + "https://example.com" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ avatars.getFavicon( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/avatars/get-flag.md b/docs/examples/java/avatars/get-flag.md index c931336..a5f4790 100644 --- a/docs/examples/java/avatars/get-flag.md +++ b/docs/examples/java/avatars/get-flag.md @@ -1,7 +1,6 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Avatars; -import io.appwrite.enums.Flag; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -10,7 +9,7 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); avatars.getFlag( - Flag.AFGHANISTAN, + "af", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +18,4 @@ avatars.getFlag( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/avatars/get-image.md b/docs/examples/java/avatars/get-image.md index 8ae4df1..cdc8ac7 100644 --- a/docs/examples/java/avatars/get-image.md +++ b/docs/examples/java/avatars/get-image.md @@ -18,4 +18,4 @@ avatars.getImage( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/avatars/get-initials.md b/docs/examples/java/avatars/get-initials.md index 36757c4..c02490c 100644 --- a/docs/examples/java/avatars/get-initials.md +++ b/docs/examples/java/avatars/get-initials.md @@ -17,4 +17,4 @@ avatars.getInitials( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/avatars/get-q-r.md b/docs/examples/java/avatars/get-q-r.md index 4894433..2532f20 100644 --- a/docs/examples/java/avatars/get-q-r.md +++ b/docs/examples/java/avatars/get-q-r.md @@ -18,4 +18,4 @@ avatars.getQR( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index c26a142..715e4cd 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -21,4 +21,4 @@ databases.createDocument( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/databases/delete-document.md b/docs/examples/java/databases/delete-document.md index d59266b..1387f48 100644 --- a/docs/examples/java/databases/delete-document.md +++ b/docs/examples/java/databases/delete-document.md @@ -11,7 +11,7 @@ Databases databases = new Databases(client); databases.deleteDocument( "[DATABASE_ID]", "[COLLECTION_ID]", - "[DOCUMENT_ID]", + "[DOCUMENT_ID]" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -20,4 +20,4 @@ databases.deleteDocument( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/databases/get-document.md b/docs/examples/java/databases/get-document.md index a63836e..b1a7161 100644 --- a/docs/examples/java/databases/get-document.md +++ b/docs/examples/java/databases/get-document.md @@ -20,4 +20,4 @@ databases.getDocument( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/databases/list-documents.md b/docs/examples/java/databases/list-documents.md index 6f577ef..62dc2c7 100644 --- a/docs/examples/java/databases/list-documents.md +++ b/docs/examples/java/databases/list-documents.md @@ -19,4 +19,4 @@ databases.listDocuments( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/databases/update-document.md b/docs/examples/java/databases/update-document.md index ae4d539..d1ed59d 100644 --- a/docs/examples/java/databases/update-document.md +++ b/docs/examples/java/databases/update-document.md @@ -20,4 +20,4 @@ databases.updateDocument( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/functions/create-execution.md b/docs/examples/java/functions/create-execution.md index 985d502..3cce1c3 100644 --- a/docs/examples/java/functions/create-execution.md +++ b/docs/examples/java/functions/create-execution.md @@ -18,4 +18,4 @@ functions.createExecution( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/functions/get-execution.md b/docs/examples/java/functions/get-execution.md index c066540..459d743 100644 --- a/docs/examples/java/functions/get-execution.md +++ b/docs/examples/java/functions/get-execution.md @@ -10,7 +10,7 @@ Functions functions = new Functions(client); functions.getExecution( "[FUNCTION_ID]", - "[EXECUTION_ID]", + "[EXECUTION_ID]" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ functions.getExecution( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/functions/list-executions.md b/docs/examples/java/functions/list-executions.md index 53f45ca..c1f982b 100644 --- a/docs/examples/java/functions/list-executions.md +++ b/docs/examples/java/functions/list-executions.md @@ -18,4 +18,4 @@ functions.listExecutions( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/graphql/mutation.md b/docs/examples/java/graphql/mutation.md index 5d140d6..262e513 100644 --- a/docs/examples/java/graphql/mutation.md +++ b/docs/examples/java/graphql/mutation.md @@ -9,7 +9,7 @@ Client client = new Client(context) Graphql graphql = new Graphql(client); graphql.mutation( - mapOf( "a" to "b" ), + mapOf( "a" to "b" ) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ graphql.mutation( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/graphql/query.md b/docs/examples/java/graphql/query.md index de693fa..4291b47 100644 --- a/docs/examples/java/graphql/query.md +++ b/docs/examples/java/graphql/query.md @@ -9,7 +9,7 @@ Client client = new Client(context) Graphql graphql = new Graphql(client); graphql.query( - mapOf( "a" to "b" ), + mapOf( "a" to "b" ) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ graphql.query( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/locale/get.md b/docs/examples/java/locale/get.md index cc37896..4d14be6 100644 --- a/docs/examples/java/locale/get.md +++ b/docs/examples/java/locale/get.md @@ -9,7 +9,7 @@ Client client = new Client(context) Locale locale = new Locale(client); locale.get(new CoroutineCallback<>((result, error) -> { - if (error != null) { + if (error != null) error.printStackTrace(); return; } diff --git a/docs/examples/java/locale/list-codes.md b/docs/examples/java/locale/list-codes.md index 3fbdf85..599070e 100644 --- a/docs/examples/java/locale/list-codes.md +++ b/docs/examples/java/locale/list-codes.md @@ -9,7 +9,7 @@ Client client = new Client(context) Locale locale = new Locale(client); locale.listCodes(new CoroutineCallback<>((result, error) -> { - if (error != null) { + if (error != null) error.printStackTrace(); return; } diff --git a/docs/examples/java/locale/list-continents.md b/docs/examples/java/locale/list-continents.md index 296eade..6abe97a 100644 --- a/docs/examples/java/locale/list-continents.md +++ b/docs/examples/java/locale/list-continents.md @@ -9,7 +9,7 @@ Client client = new Client(context) Locale locale = new Locale(client); locale.listContinents(new CoroutineCallback<>((result, error) -> { - if (error != null) { + if (error != null) error.printStackTrace(); return; } diff --git a/docs/examples/java/locale/list-countries-e-u.md b/docs/examples/java/locale/list-countries-e-u.md index f674ac5..3c5ca3a 100644 --- a/docs/examples/java/locale/list-countries-e-u.md +++ b/docs/examples/java/locale/list-countries-e-u.md @@ -9,7 +9,7 @@ Client client = new Client(context) Locale locale = new Locale(client); locale.listCountriesEU(new CoroutineCallback<>((result, error) -> { - if (error != null) { + if (error != null) error.printStackTrace(); return; } diff --git a/docs/examples/java/locale/list-countries-phones.md b/docs/examples/java/locale/list-countries-phones.md index 6280cbb..81ef94d 100644 --- a/docs/examples/java/locale/list-countries-phones.md +++ b/docs/examples/java/locale/list-countries-phones.md @@ -9,7 +9,7 @@ Client client = new Client(context) Locale locale = new Locale(client); locale.listCountriesPhones(new CoroutineCallback<>((result, error) -> { - if (error != null) { + if (error != null) error.printStackTrace(); return; } diff --git a/docs/examples/java/locale/list-countries.md b/docs/examples/java/locale/list-countries.md index eab9ae2..dc0d5f5 100644 --- a/docs/examples/java/locale/list-countries.md +++ b/docs/examples/java/locale/list-countries.md @@ -9,7 +9,7 @@ Client client = new Client(context) Locale locale = new Locale(client); locale.listCountries(new CoroutineCallback<>((result, error) -> { - if (error != null) { + if (error != null) error.printStackTrace(); return; } diff --git a/docs/examples/java/locale/list-currencies.md b/docs/examples/java/locale/list-currencies.md index 662e025..7a327b3 100644 --- a/docs/examples/java/locale/list-currencies.md +++ b/docs/examples/java/locale/list-currencies.md @@ -9,7 +9,7 @@ Client client = new Client(context) Locale locale = new Locale(client); locale.listCurrencies(new CoroutineCallback<>((result, error) -> { - if (error != null) { + if (error != null) error.printStackTrace(); return; } diff --git a/docs/examples/java/locale/list-languages.md b/docs/examples/java/locale/list-languages.md index dd68bf2..0688614 100644 --- a/docs/examples/java/locale/list-languages.md +++ b/docs/examples/java/locale/list-languages.md @@ -9,7 +9,7 @@ Client client = new Client(context) Locale locale = new Locale(client); locale.listLanguages(new CoroutineCallback<>((result, error) -> { - if (error != null) { + if (error != null) error.printStackTrace(); return; } diff --git a/docs/examples/java/messaging/create-subscriber.md b/docs/examples/java/messaging/create-subscriber.md deleted file mode 100644 index d071008..0000000 --- a/docs/examples/java/messaging/create-subscriber.md +++ /dev/null @@ -1,23 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Messaging; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - -Messaging messaging = new Messaging(client); - -messaging.createSubscriber( - "[TOPIC_ID]", - "[SUBSCRIBER_ID]", - "[TARGET_ID]", - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); \ No newline at end of file diff --git a/docs/examples/java/messaging/delete-subscriber.md b/docs/examples/java/messaging/delete-subscriber.md deleted file mode 100644 index a1d5686..0000000 --- a/docs/examples/java/messaging/delete-subscriber.md +++ /dev/null @@ -1,22 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Messaging; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID - -Messaging messaging = new Messaging(client); - -messaging.deleteSubscriber( - "[TOPIC_ID]", - "[SUBSCRIBER_ID]", - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); \ No newline at end of file diff --git a/docs/examples/java/storage/create-file.md b/docs/examples/java/storage/create-file.md index b99312b..732b302 100644 --- a/docs/examples/java/storage/create-file.md +++ b/docs/examples/java/storage/create-file.md @@ -21,4 +21,4 @@ storage.createFile( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/storage/delete-file.md b/docs/examples/java/storage/delete-file.md index 9ac7f2e..69a0f0f 100644 --- a/docs/examples/java/storage/delete-file.md +++ b/docs/examples/java/storage/delete-file.md @@ -10,7 +10,7 @@ Storage storage = new Storage(client); storage.deleteFile( "[BUCKET_ID]", - "[FILE_ID]", + "[FILE_ID]" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ storage.deleteFile( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/storage/get-file-download.md b/docs/examples/java/storage/get-file-download.md index 7428cc0..2ab30dc 100644 --- a/docs/examples/java/storage/get-file-download.md +++ b/docs/examples/java/storage/get-file-download.md @@ -10,7 +10,7 @@ Storage storage = new Storage(client); storage.getFileDownload( "[BUCKET_ID]", - "[FILE_ID]", + "[FILE_ID]" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ storage.getFileDownload( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/storage/get-file-preview.md b/docs/examples/java/storage/get-file-preview.md index 6de0abf..483f2fc 100644 --- a/docs/examples/java/storage/get-file-preview.md +++ b/docs/examples/java/storage/get-file-preview.md @@ -19,4 +19,4 @@ storage.getFilePreview( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/storage/get-file-view.md b/docs/examples/java/storage/get-file-view.md index 3c0392d..5614b69 100644 --- a/docs/examples/java/storage/get-file-view.md +++ b/docs/examples/java/storage/get-file-view.md @@ -10,7 +10,7 @@ Storage storage = new Storage(client); storage.getFileView( "[BUCKET_ID]", - "[FILE_ID]", + "[FILE_ID]" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ storage.getFileView( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/storage/get-file.md b/docs/examples/java/storage/get-file.md index c425758..4ae0de0 100644 --- a/docs/examples/java/storage/get-file.md +++ b/docs/examples/java/storage/get-file.md @@ -10,7 +10,7 @@ Storage storage = new Storage(client); storage.getFile( "[BUCKET_ID]", - "[FILE_ID]", + "[FILE_ID]" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ storage.getFile( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/storage/list-files.md b/docs/examples/java/storage/list-files.md index b6d38aa..dedfb6c 100644 --- a/docs/examples/java/storage/list-files.md +++ b/docs/examples/java/storage/list-files.md @@ -18,4 +18,4 @@ storage.listFiles( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/storage/update-file.md b/docs/examples/java/storage/update-file.md index 6aae427..9b4dd92 100644 --- a/docs/examples/java/storage/update-file.md +++ b/docs/examples/java/storage/update-file.md @@ -19,4 +19,4 @@ storage.updateFile( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/teams/create-membership.md b/docs/examples/java/teams/create-membership.md index 3091164..6073f5b 100644 --- a/docs/examples/java/teams/create-membership.md +++ b/docs/examples/java/teams/create-membership.md @@ -19,4 +19,4 @@ teams.createMembership( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/teams/create.md b/docs/examples/java/teams/create.md index aa7f567..263fa57 100644 --- a/docs/examples/java/teams/create.md +++ b/docs/examples/java/teams/create.md @@ -19,4 +19,4 @@ teams.create( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/teams/delete-membership.md b/docs/examples/java/teams/delete-membership.md index 3837fad..40f28f0 100644 --- a/docs/examples/java/teams/delete-membership.md +++ b/docs/examples/java/teams/delete-membership.md @@ -10,7 +10,7 @@ Teams teams = new Teams(client); teams.deleteMembership( "[TEAM_ID]", - "[MEMBERSHIP_ID]", + "[MEMBERSHIP_ID]" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ teams.deleteMembership( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/teams/delete.md b/docs/examples/java/teams/delete.md index 75355ae..5b4c378 100644 --- a/docs/examples/java/teams/delete.md +++ b/docs/examples/java/teams/delete.md @@ -9,7 +9,7 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.delete( - "[TEAM_ID]", + "[TEAM_ID]" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ teams.delete( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/teams/get-membership.md b/docs/examples/java/teams/get-membership.md index 0ba9c87..f2f1d99 100644 --- a/docs/examples/java/teams/get-membership.md +++ b/docs/examples/java/teams/get-membership.md @@ -10,7 +10,7 @@ Teams teams = new Teams(client); teams.getMembership( "[TEAM_ID]", - "[MEMBERSHIP_ID]", + "[MEMBERSHIP_ID]" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ teams.getMembership( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/teams/get-prefs.md b/docs/examples/java/teams/get-prefs.md index e93b482..6963cb4 100644 --- a/docs/examples/java/teams/get-prefs.md +++ b/docs/examples/java/teams/get-prefs.md @@ -9,7 +9,7 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.getPrefs( - "[TEAM_ID]", + "[TEAM_ID]" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ teams.getPrefs( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/teams/get.md b/docs/examples/java/teams/get.md index f5406a2..549af20 100644 --- a/docs/examples/java/teams/get.md +++ b/docs/examples/java/teams/get.md @@ -9,7 +9,7 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.get( - "[TEAM_ID]", + "[TEAM_ID]" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ teams.get( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/teams/list-memberships.md b/docs/examples/java/teams/list-memberships.md index b61b0d0..3da4e33 100644 --- a/docs/examples/java/teams/list-memberships.md +++ b/docs/examples/java/teams/list-memberships.md @@ -18,4 +18,4 @@ teams.listMemberships( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/teams/list.md b/docs/examples/java/teams/list.md index 2f21813..b20ad4a 100644 --- a/docs/examples/java/teams/list.md +++ b/docs/examples/java/teams/list.md @@ -17,4 +17,4 @@ teams.list( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/teams/update-membership-status.md b/docs/examples/java/teams/update-membership-status.md index 33bd869..499251f 100644 --- a/docs/examples/java/teams/update-membership-status.md +++ b/docs/examples/java/teams/update-membership-status.md @@ -12,7 +12,7 @@ teams.updateMembershipStatus( "[TEAM_ID]", "[MEMBERSHIP_ID]", "[USER_ID]", - "[SECRET]", + "[SECRET]" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -21,4 +21,4 @@ teams.updateMembershipStatus( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/teams/update-membership.md b/docs/examples/java/teams/update-membership.md index 48efbe3..6cb3346 100644 --- a/docs/examples/java/teams/update-membership.md +++ b/docs/examples/java/teams/update-membership.md @@ -11,7 +11,7 @@ Teams teams = new Teams(client); teams.updateMembership( "[TEAM_ID]", "[MEMBERSHIP_ID]", - listOf(), + listOf() new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -20,4 +20,4 @@ teams.updateMembership( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/teams/update-name.md b/docs/examples/java/teams/update-name.md index a84ba84..170ee59 100644 --- a/docs/examples/java/teams/update-name.md +++ b/docs/examples/java/teams/update-name.md @@ -10,7 +10,7 @@ Teams teams = new Teams(client); teams.updateName( "[TEAM_ID]", - "[NAME]", + "[NAME]" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ teams.updateName( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/java/teams/update-prefs.md b/docs/examples/java/teams/update-prefs.md index 874f976..a19ad82 100644 --- a/docs/examples/java/teams/update-prefs.md +++ b/docs/examples/java/teams/update-prefs.md @@ -10,7 +10,7 @@ Teams teams = new Teams(client); teams.updatePrefs( "[TEAM_ID]", - mapOf( "a" to "b" ), + mapOf( "a" to "b" ) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ teams.updatePrefs( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); diff --git a/docs/examples/kotlin/account/add-authenticator.md b/docs/examples/kotlin/account/add-authenticator.md deleted file mode 100644 index adb0cf9..0000000 --- a/docs/examples/kotlin/account/add-authenticator.md +++ /dev/null @@ -1,14 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Account -import io.appwrite.enums.AuthenticatorFactor - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - -val account = Account(client) - -val response = account.addAuthenticator( - factor = AuthenticatorFactor.TOTP, -) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-anonymous-session.md b/docs/examples/kotlin/account/create-anonymous-session.md index 6d1e632..cdcf401 100644 --- a/docs/examples/kotlin/account/create-anonymous-session.md +++ b/docs/examples/kotlin/account/create-anonymous-session.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) diff --git a/docs/examples/kotlin/account/create-challenge.md b/docs/examples/kotlin/account/create-challenge.md deleted file mode 100644 index d1b0df9..0000000 --- a/docs/examples/kotlin/account/create-challenge.md +++ /dev/null @@ -1,14 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Account -import io.appwrite.enums.AuthenticatorProvider - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - -val account = Account(client) - -val response = account.createChallenge( - provider = AuthenticatorProvider.TOTP, -) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-email-password-session.md b/docs/examples/kotlin/account/create-email-password-session.md deleted file mode 100644 index 016e73b..0000000 --- a/docs/examples/kotlin/account/create-email-password-session.md +++ /dev/null @@ -1,14 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Account - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - -val account = Account(client) - -val response = account.createEmailPasswordSession( - email = "email@example.com", - password = "password", -) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-magic-u-r-l-token.md b/docs/examples/kotlin/account/create-email-session.md similarity index 70% rename from docs/examples/kotlin/account/create-magic-u-r-l-token.md rename to docs/examples/kotlin/account/create-email-session.md index 9d02c96..ab8d581 100644 --- a/docs/examples/kotlin/account/create-magic-u-r-l-token.md +++ b/docs/examples/kotlin/account/create-email-session.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -8,7 +7,7 @@ val client = Client(context) val account = Account(client) -val response = account.createMagicURLToken( - userId = "[USER_ID]", +val response = account.createEmailSession( email = "email@example.com", -) \ No newline at end of file + 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 c3131e6..35e7a6f 100644 --- a/docs/examples/kotlin/account/create-j-w-t.md +++ b/docs/examples/kotlin/account/create-j-w-t.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) diff --git a/docs/examples/kotlin/account/create-email-token.md b/docs/examples/kotlin/account/create-magic-u-r-l-session.md similarity index 77% rename from docs/examples/kotlin/account/create-email-token.md rename to docs/examples/kotlin/account/create-magic-u-r-l-session.md index 6165707..51368b5 100644 --- a/docs/examples/kotlin/account/create-email-token.md +++ b/docs/examples/kotlin/account/create-magic-u-r-l-session.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -8,7 +7,7 @@ val client = Client(context) val account = Account(client) -val response = account.createEmailToken( +val response = account.createMagicURLSession( userId = "[USER_ID]", email = "email@example.com", -) \ No newline at end of file +) diff --git a/docs/examples/kotlin/account/create-o-auth2session.md b/docs/examples/kotlin/account/create-o-auth2session.md index ac01fe5..395bfad 100644 --- a/docs/examples/kotlin/account/create-o-auth2session.md +++ b/docs/examples/kotlin/account/create-o-auth2session.md @@ -1,7 +1,5 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account -import io.appwrite.enums.OAuthProvider val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -10,5 +8,5 @@ val client = Client(context) val account = Account(client) account.createOAuth2Session( - provider = OAuthProvider.AMAZON, -) \ No newline at end of file + provider = "amazon", +) diff --git a/docs/examples/kotlin/account/update-m-f-a.md b/docs/examples/kotlin/account/create-phone-session.md similarity index 71% rename from docs/examples/kotlin/account/update-m-f-a.md rename to docs/examples/kotlin/account/create-phone-session.md index 1bd3fd2..eed6f7a 100644 --- a/docs/examples/kotlin/account/update-m-f-a.md +++ b/docs/examples/kotlin/account/create-phone-session.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -8,6 +7,7 @@ val client = Client(context) val account = Account(client) -val response = account.updateMFA( - mfa = false, -) \ No newline at end of file +val response = account.createPhoneSession( + userId = "[USER_ID]", + phone = "+12065550100" +) diff --git a/docs/examples/kotlin/account/create-phone-token.md b/docs/examples/kotlin/account/create-phone-token.md deleted file mode 100644 index abb46c5..0000000 --- a/docs/examples/kotlin/account/create-phone-token.md +++ /dev/null @@ -1,14 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Account - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - -val account = Account(client) - -val response = account.createPhoneToken( - userId = "[USER_ID]", - phone = "+12065550100", -) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-phone-verification.md b/docs/examples/kotlin/account/create-phone-verification.md index 3fb5064..12fb9f7 100644 --- a/docs/examples/kotlin/account/create-phone-verification.md +++ b/docs/examples/kotlin/account/create-phone-verification.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) diff --git a/docs/examples/kotlin/account/create-push-target.md b/docs/examples/kotlin/account/create-push-target.md deleted file mode 100644 index 30c4d39..0000000 --- a/docs/examples/kotlin/account/create-push-target.md +++ /dev/null @@ -1,14 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Account - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - -val account = Account(client) - -val response = account.createPushTarget( - targetId = "[TARGET_ID]", - identifier = "[IDENTIFIER]", -) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-recovery.md b/docs/examples/kotlin/account/create-recovery.md index f678fcf..7d73a67 100644 --- a/docs/examples/kotlin/account/create-recovery.md +++ b/docs/examples/kotlin/account/create-recovery.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -10,5 +9,5 @@ val account = Account(client) val response = account.createRecovery( email = "email@example.com", - url = "https://example.com", -) \ No newline at end of file + url = "https://example.com" +) diff --git a/docs/examples/kotlin/account/create-session.md b/docs/examples/kotlin/account/create-session.md deleted file mode 100644 index ceb7726..0000000 --- a/docs/examples/kotlin/account/create-session.md +++ /dev/null @@ -1,14 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Account - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - -val account = Account(client) - -val response = account.createSession( - userId = "[USER_ID]", - secret = "[SECRET]", -) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-verification.md b/docs/examples/kotlin/account/create-verification.md index 1832348..b3dc43a 100644 --- a/docs/examples/kotlin/account/create-verification.md +++ b/docs/examples/kotlin/account/create-verification.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -9,5 +8,5 @@ val client = Client(context) val account = Account(client) val response = account.createVerification( - url = "https://example.com", -) \ No newline at end of file + url = "https://example.com" +) diff --git a/docs/examples/kotlin/account/create.md b/docs/examples/kotlin/account/create.md index 8022955..c72ae90 100644 --- a/docs/examples/kotlin/account/create.md +++ b/docs/examples/kotlin/account/create.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -12,4 +11,4 @@ val response = account.create( userId = "[USER_ID]", email = "email@example.com", password = "", -) \ No newline at end of file +) diff --git a/docs/examples/kotlin/account/delete-authenticator.md b/docs/examples/kotlin/account/delete-authenticator.md deleted file mode 100644 index beb63f1..0000000 --- a/docs/examples/kotlin/account/delete-authenticator.md +++ /dev/null @@ -1,15 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Account -import io.appwrite.enums.AuthenticatorProvider - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - -val account = Account(client) - -val response = account.deleteAuthenticator( - provider = AuthenticatorProvider.TOTP, - otp = "[OTP]", -) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-identity.md b/docs/examples/kotlin/account/delete-identity.md index cbf6913..440333e 100644 --- a/docs/examples/kotlin/account/delete-identity.md +++ b/docs/examples/kotlin/account/delete-identity.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -9,5 +8,5 @@ val client = Client(context) val account = Account(client) val response = account.deleteIdentity( - identityId = "[IDENTITY_ID]", -) \ No newline at end of file + identityId = "[IDENTITY_ID]" +) diff --git a/docs/examples/kotlin/account/delete-push-target.md b/docs/examples/kotlin/account/delete-push-target.md deleted file mode 100644 index ea79749..0000000 --- a/docs/examples/kotlin/account/delete-push-target.md +++ /dev/null @@ -1,13 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Account - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - -val account = Account(client) - -val response = account.deletePushTarget( - targetId = "[TARGET_ID]", -) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-session.md b/docs/examples/kotlin/account/delete-session.md index 615f218..a98a286 100644 --- a/docs/examples/kotlin/account/delete-session.md +++ b/docs/examples/kotlin/account/delete-session.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -9,5 +8,5 @@ val client = Client(context) val account = Account(client) val response = account.deleteSession( - sessionId = "[SESSION_ID]", -) \ No newline at end of file + sessionId = "[SESSION_ID]" +) diff --git a/docs/examples/kotlin/account/delete-sessions.md b/docs/examples/kotlin/account/delete-sessions.md index db8e00d..c9afbf1 100644 --- a/docs/examples/kotlin/account/delete-sessions.md +++ b/docs/examples/kotlin/account/delete-sessions.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) diff --git a/docs/examples/kotlin/account/get-prefs.md b/docs/examples/kotlin/account/get-prefs.md index 0112f8b..bd3f81a 100644 --- a/docs/examples/kotlin/account/get-prefs.md +++ b/docs/examples/kotlin/account/get-prefs.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) diff --git a/docs/examples/kotlin/account/get-session.md b/docs/examples/kotlin/account/get-session.md index 1b15d5b..d6d6c72 100644 --- a/docs/examples/kotlin/account/get-session.md +++ b/docs/examples/kotlin/account/get-session.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -9,5 +8,5 @@ val client = Client(context) val account = Account(client) val response = account.getSession( - sessionId = "[SESSION_ID]", -) \ No newline at end of file + sessionId = "[SESSION_ID]" +) diff --git a/docs/examples/kotlin/account/get.md b/docs/examples/kotlin/account/get.md index 6c08a1c..4c8f0be 100644 --- a/docs/examples/kotlin/account/get.md +++ b/docs/examples/kotlin/account/get.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) diff --git a/docs/examples/kotlin/account/list-identities.md b/docs/examples/kotlin/account/list-identities.md index d87409c..3292b35 100644 --- a/docs/examples/kotlin/account/list-identities.md +++ b/docs/examples/kotlin/account/list-identities.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -9,4 +8,4 @@ val client = Client(context) val account = Account(client) val response = account.listIdentities( -) \ No newline at end of file +) diff --git a/docs/examples/kotlin/account/list-logs.md b/docs/examples/kotlin/account/list-logs.md index f4ce74f..eb337ca 100644 --- a/docs/examples/kotlin/account/list-logs.md +++ b/docs/examples/kotlin/account/list-logs.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -9,4 +8,4 @@ val client = Client(context) val account = Account(client) val response = account.listLogs( -) \ No newline at end of file +) diff --git a/docs/examples/kotlin/account/list-sessions.md b/docs/examples/kotlin/account/list-sessions.md index 2c692b8..cd9f63b 100644 --- a/docs/examples/kotlin/account/list-sessions.md +++ b/docs/examples/kotlin/account/list-sessions.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) diff --git a/docs/examples/kotlin/account/update-challenge.md b/docs/examples/kotlin/account/update-challenge.md deleted file mode 100644 index 23718d2..0000000 --- a/docs/examples/kotlin/account/update-challenge.md +++ /dev/null @@ -1,14 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Account - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - -val account = Account(client) - -val response = account.updateChallenge( - challengeId = "[CHALLENGE_ID]", - otp = "[OTP]", -) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-email.md b/docs/examples/kotlin/account/update-email.md index 6b3655a..85a0242 100644 --- a/docs/examples/kotlin/account/update-email.md +++ b/docs/examples/kotlin/account/update-email.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -10,5 +9,5 @@ val account = Account(client) val response = account.updateEmail( email = "email@example.com", - password = "password", -) \ No newline at end of file + 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 1f77281..c7286ba 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,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -10,5 +9,5 @@ val account = Account(client) val response = account.updateMagicURLSession( userId = "[USER_ID]", - secret = "[SECRET]", -) \ No newline at end of file + secret = "[SECRET]" +) diff --git a/docs/examples/kotlin/account/update-name.md b/docs/examples/kotlin/account/update-name.md index 5d18e1f..574f493 100644 --- a/docs/examples/kotlin/account/update-name.md +++ b/docs/examples/kotlin/account/update-name.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -9,5 +8,5 @@ val client = Client(context) val account = Account(client) val response = account.updateName( - name = "[NAME]", -) \ No newline at end of file + name = "[NAME]" +) diff --git a/docs/examples/kotlin/account/update-password.md b/docs/examples/kotlin/account/update-password.md index 45e9556..c5338b8 100644 --- a/docs/examples/kotlin/account/update-password.md +++ b/docs/examples/kotlin/account/update-password.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -10,4 +9,4 @@ val account = Account(client) val response = account.updatePassword( password = "", -) \ No newline at end of file +) diff --git a/docs/examples/kotlin/account/list-factors.md b/docs/examples/kotlin/account/update-phone-session.md similarity index 72% rename from docs/examples/kotlin/account/list-factors.md rename to docs/examples/kotlin/account/update-phone-session.md index e30f652..d3b02e0 100644 --- a/docs/examples/kotlin/account/list-factors.md +++ b/docs/examples/kotlin/account/update-phone-session.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -8,4 +7,7 @@ val client = Client(context) val account = Account(client) -val response = account.listFactors() +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 c4c0e84..0314f74 100644 --- a/docs/examples/kotlin/account/update-phone-verification.md +++ b/docs/examples/kotlin/account/update-phone-verification.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -10,5 +9,5 @@ val account = Account(client) val response = account.updatePhoneVerification( userId = "[USER_ID]", - secret = "[SECRET]", -) \ No newline at end of file + secret = "[SECRET]" +) diff --git a/docs/examples/kotlin/account/update-phone.md b/docs/examples/kotlin/account/update-phone.md index d86e628..76eb8aa 100644 --- a/docs/examples/kotlin/account/update-phone.md +++ b/docs/examples/kotlin/account/update-phone.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -10,5 +9,5 @@ val account = Account(client) val response = account.updatePhone( phone = "+12065550100", - password = "password", -) \ No newline at end of file + password = "password" +) diff --git a/docs/examples/kotlin/account/update-prefs.md b/docs/examples/kotlin/account/update-prefs.md index 58d5cd0..f16e40b 100644 --- a/docs/examples/kotlin/account/update-prefs.md +++ b/docs/examples/kotlin/account/update-prefs.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -9,5 +8,5 @@ val client = Client(context) val account = Account(client) val response = account.updatePrefs( - prefs = mapOf( "a" to "b" ), -) \ No newline at end of file + prefs = mapOf( "a" to "b" ) +) diff --git a/docs/examples/kotlin/account/update-push-target.md b/docs/examples/kotlin/account/update-push-target.md deleted file mode 100644 index ff1e3a1..0000000 --- a/docs/examples/kotlin/account/update-push-target.md +++ /dev/null @@ -1,14 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Account - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - -val account = Account(client) - -val response = account.updatePushTarget( - targetId = "[TARGET_ID]", - identifier = "[IDENTIFIER]", -) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-recovery.md b/docs/examples/kotlin/account/update-recovery.md index 6b7a6d0..9682899 100644 --- a/docs/examples/kotlin/account/update-recovery.md +++ b/docs/examples/kotlin/account/update-recovery.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -11,5 +10,6 @@ val account = Account(client) val response = account.updateRecovery( userId = "[USER_ID]", secret = "[SECRET]", - password = "", -) \ No newline at end of file + password = "password", + passwordAgain = "password" +) diff --git a/docs/examples/kotlin/account/update-session.md b/docs/examples/kotlin/account/update-session.md index 1257334..e9e83d0 100644 --- a/docs/examples/kotlin/account/update-session.md +++ b/docs/examples/kotlin/account/update-session.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -9,5 +8,5 @@ val client = Client(context) val account = Account(client) val response = account.updateSession( - sessionId = "[SESSION_ID]", -) \ No newline at end of file + sessionId = "[SESSION_ID]" +) diff --git a/docs/examples/kotlin/account/update-status.md b/docs/examples/kotlin/account/update-status.md index e822de9..f7789ea 100644 --- a/docs/examples/kotlin/account/update-status.md +++ b/docs/examples/kotlin/account/update-status.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) diff --git a/docs/examples/kotlin/account/update-verification.md b/docs/examples/kotlin/account/update-verification.md index 0dcd75b..af800c1 100644 --- a/docs/examples/kotlin/account/update-verification.md +++ b/docs/examples/kotlin/account/update-verification.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -10,5 +9,5 @@ val account = Account(client) val response = account.updateVerification( userId = "[USER_ID]", - secret = "[SECRET]", -) \ No newline at end of file + secret = "[SECRET]" +) diff --git a/docs/examples/kotlin/account/verify-authenticator.md b/docs/examples/kotlin/account/verify-authenticator.md deleted file mode 100644 index 65144f7..0000000 --- a/docs/examples/kotlin/account/verify-authenticator.md +++ /dev/null @@ -1,15 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Account -import io.appwrite.enums.AuthenticatorFactor - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - -val account = Account(client) - -val response = account.verifyAuthenticator( - factor = AuthenticatorFactor.TOTP, - otp = "[OTP]", -) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-browser.md b/docs/examples/kotlin/avatars/get-browser.md index ab7c749..b1b2d08 100644 --- a/docs/examples/kotlin/avatars/get-browser.md +++ b/docs/examples/kotlin/avatars/get-browser.md @@ -1,7 +1,5 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars -import io.appwrite.enums.Browser val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -9,6 +7,6 @@ val client = Client(context) val avatars = Avatars(client) -val result =avatars.getBrowser( - code = Browser.AVANT_BROWSER, -) \ 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 758f70d..411e05a 100644 --- a/docs/examples/kotlin/avatars/get-credit-card.md +++ b/docs/examples/kotlin/avatars/get-credit-card.md @@ -1,7 +1,5 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars -import io.appwrite.enums.CreditCard val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -9,6 +7,6 @@ val client = Client(context) val avatars = Avatars(client) -val result =avatars.getCreditCard( - code = CreditCard.AMERICAN_EXPRESS, -) \ 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 1bb1372..1a4b217 100644 --- a/docs/examples/kotlin/avatars/get-favicon.md +++ b/docs/examples/kotlin/avatars/get-favicon.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars val client = Client(context) @@ -8,6 +7,6 @@ val client = Client(context) val avatars = Avatars(client) -val result =avatars.getFavicon( - url = "https://example.com", -) \ 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 142f626..5c882d6 100644 --- a/docs/examples/kotlin/avatars/get-flag.md +++ b/docs/examples/kotlin/avatars/get-flag.md @@ -1,7 +1,5 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars -import io.appwrite.enums.Flag val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -9,6 +7,6 @@ val client = Client(context) val avatars = Avatars(client) -val result =avatars.getFlag( - code = Flag.AFGHANISTAN, -) \ 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 c1ccd96..20d8dff 100644 --- a/docs/examples/kotlin/avatars/get-image.md +++ b/docs/examples/kotlin/avatars/get-image.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars val client = Client(context) @@ -8,6 +7,6 @@ val client = Client(context) val avatars = Avatars(client) -val result =avatars.getImage( +val result = avatars.getImage( url = "https://example.com", -) \ No newline at end of file +) diff --git a/docs/examples/kotlin/avatars/get-initials.md b/docs/examples/kotlin/avatars/get-initials.md index 62c69c8..70ef9b2 100644 --- a/docs/examples/kotlin/avatars/get-initials.md +++ b/docs/examples/kotlin/avatars/get-initials.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars val client = Client(context) @@ -8,5 +7,5 @@ val client = Client(context) val avatars = Avatars(client) -val result =avatars.getInitials( -) \ 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 85de6d3..92b17e1 100644 --- a/docs/examples/kotlin/avatars/get-q-r.md +++ b/docs/examples/kotlin/avatars/get-q-r.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars val client = Client(context) @@ -8,6 +7,6 @@ val client = Client(context) val avatars = Avatars(client) -val result =avatars.getQR( +val result = avatars.getQR( text = "[TEXT]", -) \ No newline at end of file +) diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index bc5445a..d7f1991 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Databases val client = Client(context) @@ -13,4 +12,4 @@ val response = databases.createDocument( collectionId = "[COLLECTION_ID]", documentId = "[DOCUMENT_ID]", data = mapOf( "a" to "b" ), -) \ No newline at end of file +) diff --git a/docs/examples/kotlin/databases/delete-document.md b/docs/examples/kotlin/databases/delete-document.md index d24db61..c5bf2a2 100644 --- a/docs/examples/kotlin/databases/delete-document.md +++ b/docs/examples/kotlin/databases/delete-document.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Databases val client = Client(context) @@ -11,5 +10,5 @@ val databases = Databases(client) val response = databases.deleteDocument( databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", - documentId = "[DOCUMENT_ID]", -) \ No newline at end of file + documentId = "[DOCUMENT_ID]" +) diff --git a/docs/examples/kotlin/databases/get-document.md b/docs/examples/kotlin/databases/get-document.md index 328b801..abdee36 100644 --- a/docs/examples/kotlin/databases/get-document.md +++ b/docs/examples/kotlin/databases/get-document.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Databases val client = Client(context) @@ -12,4 +11,4 @@ val response = databases.getDocument( databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", documentId = "[DOCUMENT_ID]", -) \ No newline at end of file +) diff --git a/docs/examples/kotlin/databases/list-documents.md b/docs/examples/kotlin/databases/list-documents.md index b5511d6..f97d878 100644 --- a/docs/examples/kotlin/databases/list-documents.md +++ b/docs/examples/kotlin/databases/list-documents.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Databases val client = Client(context) @@ -11,4 +10,4 @@ val databases = Databases(client) val response = databases.listDocuments( databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", -) \ No newline at end of file +) diff --git a/docs/examples/kotlin/databases/update-document.md b/docs/examples/kotlin/databases/update-document.md index e2d989e..3820b89 100644 --- a/docs/examples/kotlin/databases/update-document.md +++ b/docs/examples/kotlin/databases/update-document.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Databases val client = Client(context) @@ -12,4 +11,4 @@ val response = databases.updateDocument( databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", documentId = "[DOCUMENT_ID]", -) \ No newline at end of file +) diff --git a/docs/examples/kotlin/functions/create-execution.md b/docs/examples/kotlin/functions/create-execution.md index 96dad59..77d4587 100644 --- a/docs/examples/kotlin/functions/create-execution.md +++ b/docs/examples/kotlin/functions/create-execution.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Functions val client = Client(context) @@ -10,4 +9,4 @@ val functions = Functions(client) val response = functions.createExecution( functionId = "[FUNCTION_ID]", -) \ No newline at end of file +) diff --git a/docs/examples/kotlin/functions/get-execution.md b/docs/examples/kotlin/functions/get-execution.md index e366f4b..b576686 100644 --- a/docs/examples/kotlin/functions/get-execution.md +++ b/docs/examples/kotlin/functions/get-execution.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Functions val client = Client(context) @@ -10,5 +9,5 @@ val functions = Functions(client) val response = functions.getExecution( functionId = "[FUNCTION_ID]", - executionId = "[EXECUTION_ID]", -) \ No newline at end of file + executionId = "[EXECUTION_ID]" +) diff --git a/docs/examples/kotlin/functions/list-executions.md b/docs/examples/kotlin/functions/list-executions.md index ba2ff2d..14b613f 100644 --- a/docs/examples/kotlin/functions/list-executions.md +++ b/docs/examples/kotlin/functions/list-executions.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Functions val client = Client(context) @@ -10,4 +9,4 @@ val functions = Functions(client) val response = functions.listExecutions( functionId = "[FUNCTION_ID]", -) \ No newline at end of file +) diff --git a/docs/examples/kotlin/graphql/mutation.md b/docs/examples/kotlin/graphql/mutation.md index eee3f82..dc37a3e 100644 --- a/docs/examples/kotlin/graphql/mutation.md +++ b/docs/examples/kotlin/graphql/mutation.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Graphql val client = Client(context) @@ -9,5 +8,5 @@ val client = Client(context) val graphql = Graphql(client) val response = graphql.mutation( - query = mapOf( "a" to "b" ), -) \ No newline at end of file + query = mapOf( "a" to "b" ) +) diff --git a/docs/examples/kotlin/graphql/query.md b/docs/examples/kotlin/graphql/query.md index 1337d36..d821070 100644 --- a/docs/examples/kotlin/graphql/query.md +++ b/docs/examples/kotlin/graphql/query.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Graphql val client = Client(context) @@ -9,5 +8,5 @@ val client = Client(context) val graphql = Graphql(client) val response = graphql.query( - query = mapOf( "a" to "b" ), -) \ No newline at end of file + query = mapOf( "a" to "b" ) +) diff --git a/docs/examples/kotlin/locale/get.md b/docs/examples/kotlin/locale/get.md index ec7f625..a2044c7 100644 --- a/docs/examples/kotlin/locale/get.md +++ b/docs/examples/kotlin/locale/get.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) diff --git a/docs/examples/kotlin/locale/list-codes.md b/docs/examples/kotlin/locale/list-codes.md index e81e106..b4e949b 100644 --- a/docs/examples/kotlin/locale/list-codes.md +++ b/docs/examples/kotlin/locale/list-codes.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) diff --git a/docs/examples/kotlin/locale/list-continents.md b/docs/examples/kotlin/locale/list-continents.md index 0255e65..610747e 100644 --- a/docs/examples/kotlin/locale/list-continents.md +++ b/docs/examples/kotlin/locale/list-continents.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) diff --git a/docs/examples/kotlin/locale/list-countries-e-u.md b/docs/examples/kotlin/locale/list-countries-e-u.md index 4cf60d9..fa5483f 100644 --- a/docs/examples/kotlin/locale/list-countries-e-u.md +++ b/docs/examples/kotlin/locale/list-countries-e-u.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) diff --git a/docs/examples/kotlin/locale/list-countries-phones.md b/docs/examples/kotlin/locale/list-countries-phones.md index 1f8f75b..6aba463 100644 --- a/docs/examples/kotlin/locale/list-countries-phones.md +++ b/docs/examples/kotlin/locale/list-countries-phones.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) diff --git a/docs/examples/kotlin/locale/list-countries.md b/docs/examples/kotlin/locale/list-countries.md index f221fc6..c58456b 100644 --- a/docs/examples/kotlin/locale/list-countries.md +++ b/docs/examples/kotlin/locale/list-countries.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) diff --git a/docs/examples/kotlin/locale/list-currencies.md b/docs/examples/kotlin/locale/list-currencies.md index 6e5ab0d..2cf0644 100644 --- a/docs/examples/kotlin/locale/list-currencies.md +++ b/docs/examples/kotlin/locale/list-currencies.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) diff --git a/docs/examples/kotlin/locale/list-languages.md b/docs/examples/kotlin/locale/list-languages.md index 97a9eb7..afc00b1 100644 --- a/docs/examples/kotlin/locale/list-languages.md +++ b/docs/examples/kotlin/locale/list-languages.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) diff --git a/docs/examples/kotlin/messaging/create-subscriber.md b/docs/examples/kotlin/messaging/create-subscriber.md deleted file mode 100644 index 1da3ed3..0000000 --- a/docs/examples/kotlin/messaging/create-subscriber.md +++ /dev/null @@ -1,15 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Messaging - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - -val messaging = Messaging(client) - -val response = messaging.createSubscriber( - topicId = "[TOPIC_ID]", - subscriberId = "[SUBSCRIBER_ID]", - targetId = "[TARGET_ID]", -) \ No newline at end of file diff --git a/docs/examples/kotlin/messaging/delete-subscriber.md b/docs/examples/kotlin/messaging/delete-subscriber.md deleted file mode 100644 index 0096de3..0000000 --- a/docs/examples/kotlin/messaging/delete-subscriber.md +++ /dev/null @@ -1,14 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Messaging - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID - -val messaging = Messaging(client) - -val response = messaging.deleteSubscriber( - topicId = "[TOPIC_ID]", - subscriberId = "[SUBSCRIBER_ID]", -) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/create-file.md b/docs/examples/kotlin/storage/create-file.md index 19eae0f..7bb79ac 100644 --- a/docs/examples/kotlin/storage/create-file.md +++ b/docs/examples/kotlin/storage/create-file.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.models.InputFile import io.appwrite.services.Storage @@ -13,4 +12,4 @@ val response = storage.createFile( bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]", file = InputFile.fromPath("file.png"), -) \ No newline at end of file +) diff --git a/docs/examples/kotlin/storage/delete-file.md b/docs/examples/kotlin/storage/delete-file.md index c64e8dc..9430d7e 100644 --- a/docs/examples/kotlin/storage/delete-file.md +++ b/docs/examples/kotlin/storage/delete-file.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) @@ -10,5 +9,5 @@ val storage = Storage(client) val response = storage.deleteFile( bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]", -) \ No newline at end of file + fileId = "[FILE_ID]" +) diff --git a/docs/examples/kotlin/storage/get-file-download.md b/docs/examples/kotlin/storage/get-file-download.md index 07ebcc0..85bd22c 100644 --- a/docs/examples/kotlin/storage/get-file-download.md +++ b/docs/examples/kotlin/storage/get-file-download.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) @@ -8,7 +7,7 @@ val client = Client(context) val storage = Storage(client) -val result =storage.getFileDownload( +val result = storage.getFileDownload( bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]", -) \ No newline at end of file + fileId = "[FILE_ID]" +) diff --git a/docs/examples/kotlin/storage/get-file-preview.md b/docs/examples/kotlin/storage/get-file-preview.md index b5995ae..c5bbdef 100644 --- a/docs/examples/kotlin/storage/get-file-preview.md +++ b/docs/examples/kotlin/storage/get-file-preview.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) @@ -8,7 +7,7 @@ val client = Client(context) val storage = Storage(client) -val result =storage.getFilePreview( +val result = storage.getFilePreview( bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]", -) \ No newline at end of file +) diff --git a/docs/examples/kotlin/storage/get-file-view.md b/docs/examples/kotlin/storage/get-file-view.md index 82b55c2..7e7589c 100644 --- a/docs/examples/kotlin/storage/get-file-view.md +++ b/docs/examples/kotlin/storage/get-file-view.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) @@ -8,7 +7,7 @@ val client = Client(context) val storage = Storage(client) -val result =storage.getFileView( +val result = storage.getFileView( bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]", -) \ No newline at end of file + fileId = "[FILE_ID]" +) diff --git a/docs/examples/kotlin/storage/get-file.md b/docs/examples/kotlin/storage/get-file.md index 9c1abd4..8fb6e24 100644 --- a/docs/examples/kotlin/storage/get-file.md +++ b/docs/examples/kotlin/storage/get-file.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) @@ -10,5 +9,5 @@ val storage = Storage(client) val response = storage.getFile( bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]", -) \ No newline at end of file + fileId = "[FILE_ID]" +) diff --git a/docs/examples/kotlin/storage/list-files.md b/docs/examples/kotlin/storage/list-files.md index 575a8b9..191a3cc 100644 --- a/docs/examples/kotlin/storage/list-files.md +++ b/docs/examples/kotlin/storage/list-files.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) @@ -10,4 +9,4 @@ val storage = Storage(client) val response = storage.listFiles( bucketId = "[BUCKET_ID]", -) \ No newline at end of file +) diff --git a/docs/examples/kotlin/storage/update-file.md b/docs/examples/kotlin/storage/update-file.md index 75585fa..005270f 100644 --- a/docs/examples/kotlin/storage/update-file.md +++ b/docs/examples/kotlin/storage/update-file.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) @@ -11,4 +10,4 @@ val storage = Storage(client) val response = storage.updateFile( bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]", -) \ No newline at end of file +) diff --git a/docs/examples/kotlin/teams/create-membership.md b/docs/examples/kotlin/teams/create-membership.md index 231a991..4d1de49 100644 --- a/docs/examples/kotlin/teams/create-membership.md +++ b/docs/examples/kotlin/teams/create-membership.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -11,4 +10,4 @@ val teams = Teams(client) val response = teams.createMembership( teamId = "[TEAM_ID]", roles = listOf(), -) \ No newline at end of file +) diff --git a/docs/examples/kotlin/teams/create.md b/docs/examples/kotlin/teams/create.md index dd1125c..5e70bd8 100644 --- a/docs/examples/kotlin/teams/create.md +++ b/docs/examples/kotlin/teams/create.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -11,4 +10,4 @@ val teams = Teams(client) val response = teams.create( teamId = "[TEAM_ID]", name = "[NAME]", -) \ No newline at end of file +) diff --git a/docs/examples/kotlin/teams/delete-membership.md b/docs/examples/kotlin/teams/delete-membership.md index 3f165a7..04ef5d3 100644 --- a/docs/examples/kotlin/teams/delete-membership.md +++ b/docs/examples/kotlin/teams/delete-membership.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -10,5 +9,5 @@ val teams = Teams(client) val response = teams.deleteMembership( teamId = "[TEAM_ID]", - membershipId = "[MEMBERSHIP_ID]", -) \ No newline at end of file + membershipId = "[MEMBERSHIP_ID]" +) diff --git a/docs/examples/kotlin/teams/delete.md b/docs/examples/kotlin/teams/delete.md index 756e91f..7d58960 100644 --- a/docs/examples/kotlin/teams/delete.md +++ b/docs/examples/kotlin/teams/delete.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -9,5 +8,5 @@ val client = Client(context) val teams = Teams(client) val response = teams.delete( - teamId = "[TEAM_ID]", -) \ No newline at end of file + teamId = "[TEAM_ID]" +) diff --git a/docs/examples/kotlin/teams/get-membership.md b/docs/examples/kotlin/teams/get-membership.md index 7c5d286..653bd52 100644 --- a/docs/examples/kotlin/teams/get-membership.md +++ b/docs/examples/kotlin/teams/get-membership.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -10,5 +9,5 @@ val teams = Teams(client) val response = teams.getMembership( teamId = "[TEAM_ID]", - membershipId = "[MEMBERSHIP_ID]", -) \ No newline at end of file + membershipId = "[MEMBERSHIP_ID]" +) diff --git a/docs/examples/kotlin/teams/get-prefs.md b/docs/examples/kotlin/teams/get-prefs.md index 2953dcf..bfd8f75 100644 --- a/docs/examples/kotlin/teams/get-prefs.md +++ b/docs/examples/kotlin/teams/get-prefs.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -9,5 +8,5 @@ val client = Client(context) val teams = Teams(client) val response = teams.getPrefs( - teamId = "[TEAM_ID]", -) \ No newline at end of file + teamId = "[TEAM_ID]" +) diff --git a/docs/examples/kotlin/teams/get.md b/docs/examples/kotlin/teams/get.md index 63cdd05..72aea07 100644 --- a/docs/examples/kotlin/teams/get.md +++ b/docs/examples/kotlin/teams/get.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -9,5 +8,5 @@ val client = Client(context) val teams = Teams(client) val response = teams.get( - teamId = "[TEAM_ID]", -) \ No newline at end of file + teamId = "[TEAM_ID]" +) diff --git a/docs/examples/kotlin/teams/list-memberships.md b/docs/examples/kotlin/teams/list-memberships.md index c82fa52..53bd6f3 100644 --- a/docs/examples/kotlin/teams/list-memberships.md +++ b/docs/examples/kotlin/teams/list-memberships.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -10,4 +9,4 @@ val teams = Teams(client) val response = teams.listMemberships( teamId = "[TEAM_ID]", -) \ No newline at end of file +) diff --git a/docs/examples/kotlin/teams/list.md b/docs/examples/kotlin/teams/list.md index f0f4af2..57c5fe8 100644 --- a/docs/examples/kotlin/teams/list.md +++ b/docs/examples/kotlin/teams/list.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -9,4 +8,4 @@ val client = Client(context) val teams = Teams(client) val response = teams.list( -) \ No newline at end of file +) diff --git a/docs/examples/kotlin/teams/update-membership-status.md b/docs/examples/kotlin/teams/update-membership-status.md index 50f04a2..33de006 100644 --- a/docs/examples/kotlin/teams/update-membership-status.md +++ b/docs/examples/kotlin/teams/update-membership-status.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -12,5 +11,5 @@ val response = teams.updateMembershipStatus( teamId = "[TEAM_ID]", membershipId = "[MEMBERSHIP_ID]", userId = "[USER_ID]", - secret = "[SECRET]", -) \ No newline at end of file + secret = "[SECRET]" +) diff --git a/docs/examples/kotlin/teams/update-membership.md b/docs/examples/kotlin/teams/update-membership.md index 9990cc4..40005ed 100644 --- a/docs/examples/kotlin/teams/update-membership.md +++ b/docs/examples/kotlin/teams/update-membership.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -11,5 +10,5 @@ val teams = Teams(client) val response = teams.updateMembership( teamId = "[TEAM_ID]", membershipId = "[MEMBERSHIP_ID]", - roles = listOf(), -) \ No newline at end of file + roles = listOf() +) diff --git a/docs/examples/kotlin/teams/update-name.md b/docs/examples/kotlin/teams/update-name.md index 1332fe1..59c6812 100644 --- a/docs/examples/kotlin/teams/update-name.md +++ b/docs/examples/kotlin/teams/update-name.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -10,5 +9,5 @@ val teams = Teams(client) val response = teams.updateName( teamId = "[TEAM_ID]", - name = "[NAME]", -) \ No newline at end of file + name = "[NAME]" +) diff --git a/docs/examples/kotlin/teams/update-prefs.md b/docs/examples/kotlin/teams/update-prefs.md index 5f77c6c..6a89ac7 100644 --- a/docs/examples/kotlin/teams/update-prefs.md +++ b/docs/examples/kotlin/teams/update-prefs.md @@ -1,5 +1,4 @@ import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -10,5 +9,5 @@ val teams = Teams(client) val response = teams.updatePrefs( teamId = "[TEAM_ID]", - prefs = mapOf( "a" to "b" ), -) \ No newline at end of file + prefs = mapOf( "a" to "b" ) +) diff --git a/example-java/.gitignore b/example-java/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/example-java/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/example-java/build.gradle b/example-java/build.gradle new file mode 100644 index 0000000..774d3ba --- /dev/null +++ b/example-java/build.gradle @@ -0,0 +1,39 @@ +plugins { + id 'com.android.application' +} + +android { + compileSdkVersion 33 + + defaultConfig { + applicationId "io.appwrite.example_java" + minSdkVersion 23 + targetSdkVersion 33 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation project(path: ':library') + + implementation 'androidx.appcompat:appcompat:1.6.0' + implementation 'com.google.android.material:material:1.8.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' +} \ No newline at end of file diff --git a/example-java/src/main/AndroidManifest.xml b/example-java/src/main/AndroidManifest.xml new file mode 100644 index 0000000..0276c9c --- /dev/null +++ b/example-java/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + \ No newline at end of file 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 new file mode 100644 index 0000000..04f46b3 --- /dev/null +++ b/example-java/src/main/java/io/appwrite/example_java/MainActivity.java @@ -0,0 +1,34 @@ +package io.appwrite.example_java; + +import android.os.Bundle; +import android.util.Log; + +import androidx.appcompat.app.AppCompatActivity; + +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +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://demo.appwrite.io/v1") + .setProject("6070749e6acd4"); + + Account account = new Account(client); + + 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-java/src/main/res/drawable/ic_launcher_background.xml b/example-java/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/example-java/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example-java/src/main/res/drawable/ic_launcher_foreground.xml b/example-java/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/example-java/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/example-java/src/main/res/layout/activity_main.xml b/example-java/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..4fc2444 --- /dev/null +++ b/example-java/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/example-java/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/example-java/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/example-java/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/example-java/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/example-java/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/example-java/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/example-java/src/main/res/values/colors.xml b/example-java/src/main/res/values/colors.xml new file mode 100644 index 0000000..f8c6127 --- /dev/null +++ b/example-java/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/example-java/src/main/res/values/strings.xml b/example-java/src/main/res/values/strings.xml new file mode 100644 index 0000000..71e50b3 --- /dev/null +++ b/example-java/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + Example Java + \ No newline at end of file diff --git a/example-java/src/main/res/values/themes.xml b/example-java/src/main/res/values/themes.xml new file mode 100644 index 0000000..dde245d --- /dev/null +++ b/example-java/src/main/res/values/themes.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/example/build.gradle b/example/build.gradle index e57d59b..62a34ed 100644 --- a/example/build.gradle +++ b/example/build.gradle @@ -1,18 +1,15 @@ plugins { id 'com.android.application' id 'kotlin-android' - id 'kotlin-kapt' } android { - namespace "io.appwrite.android" - - compileSdkVersion 34 + compileSdkVersion 33 defaultConfig { applicationId "io.appwrite.android" minSdkVersion 21 - targetSdkVersion 34 + targetSdkVersion 33 versionCode 1 versionName "1.0" @@ -42,19 +39,19 @@ dependencies { implementation project(path: ':library') implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.core:core-ktx:1.12.0' - implementation 'androidx.appcompat:appcompat:1.6.1' - implementation 'com.google.android.material:material:1.11.0' + implementation 'androidx.core:core-ktx:1.9.0' + implementation 'androidx.appcompat:appcompat:1.6.0' + implementation 'com.google.android.material:material:1.8.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'androidx.navigation:navigation-fragment-ktx:2.7.6' - implementation "androidx.fragment:fragment-ktx:1.6.2" - implementation 'androidx.navigation:navigation-ui-ktx:2.7.6' - implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.7.0' - implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0' - implementation 'androidx.navigation:navigation-fragment-ktx:2.7.6' - implementation 'androidx.navigation:navigation-ui-ktx:2.7.6' - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1" + implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3' + implementation "androidx.fragment:fragment-ktx:1.5.5" + implementation 'androidx.navigation:navigation-ui-ktx:2.5.3' + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1' + implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1' + implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3' + implementation 'androidx.navigation:navigation-ui-ktx:2.5.3' + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1" testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' diff --git a/example/src/main/AndroidManifest.xml b/example/src/main/AndroidManifest.xml index 5c2e7b0..e3c2421 100644 --- a/example/src/main/AndroidManifest.xml +++ b/example/src/main/AndroidManifest.xml @@ -3,14 +3,12 @@ package="io.appwrite.android"> - + android:theme="@style/Theme.AppwriteAndroidSDK"> @@ -26,13 +24,6 @@ - - - - - - - \ No newline at end of file diff --git a/example/src/main/java/io/appwrite/android/ui/accounts/AccountsFragment.kt b/example/src/main/java/io/appwrite/android/ui/accounts/AccountsFragment.kt index 7e590d5..a31cced 100644 --- a/example/src/main/java/io/appwrite/android/ui/accounts/AccountsFragment.kt +++ b/example/src/main/java/io/appwrite/android/ui/accounts/AccountsFragment.kt @@ -34,30 +34,34 @@ class AccountsFragment : Fragment() { binding.login.setOnClickListener{ viewModel.onLogin(binding.email.text, binding.password.text) } + binding.signup.setOnClickListener{ viewModel.onSignup(binding.email.text, binding.password.text, binding.name.text) } + binding.getUser.setOnClickListener{ viewModel.getUser() } + binding.oAuth.setOnClickListener{ viewModel.oAuthLogin(activity as ComponentActivity) } + binding.logout.setOnClickListener{ viewModel.logout() } - viewModel.error.observe(viewLifecycleOwner) { event -> - event?.getContentIfNotHandled()?.let { - Toast.makeText(requireContext(), it.message, Toast.LENGTH_SHORT).show() + viewModel.error.observe(viewLifecycleOwner, Observer { event -> + event?.getContentIfNotHandled()?.let { // Only proceed if the event has never been handled + Toast.makeText(requireContext(), it.message , Toast.LENGTH_SHORT).show() } - } + }) - viewModel.response.observe(viewLifecycleOwner) { event -> + viewModel.response.observe(viewLifecycleOwner, Observer { event -> event?.getContentIfNotHandled()?.let { binding.responseTV.setText(it) } - } + }) return binding.root } 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 0e558f1..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 @@ -3,10 +3,8 @@ package io.appwrite.android.ui.accounts import android.text.Editable import androidx.activity.ComponentActivity import androidx.lifecycle.* -import io.appwrite.ID import io.appwrite.android.utils.Client.client import io.appwrite.android.utils.Event -import io.appwrite.enums.OAuthProvider import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.toJson import io.appwrite.services.Account @@ -31,10 +29,7 @@ class AccountsViewModel : ViewModel() { fun onLogin(email: Editable, password: Editable) { viewModelScope.launch { try { - val session = accountService.createEmailPasswordSession( - email.toString(), - password.toString() - ) + val session = accountService.createEmailSession(email.toString(), password.toString()) _response.postValue(Event(session.toJson())) } catch (e: AppwriteException) { _error.postValue(Event(e)) @@ -46,12 +41,8 @@ class AccountsViewModel : ViewModel() { fun onSignup(email: Editable, password: Editable, name: Editable) { viewModelScope.launch { try { - val user = accountService.create( - ID.unique(), - email.toString(), - password.toString(), - name.toString() - ) + val user = + accountService.create(email.toString(), password.toString(), name.toString()) _response.postValue(Event(user.toJson())) } catch (e: AppwriteException) { _error.postValue(Event(e)) @@ -65,7 +56,7 @@ class AccountsViewModel : ViewModel() { try { accountService.createOAuth2Session( activity, - OAuthProvider.FACEBOOK, + "facebook", "appwrite-callback-6070749e6acd4://demo.appwrite.io/auth/oauth2/success", "appwrite-callback-6070749e6acd4://demo.appwrite.io/auth/oauth2/failure" ) diff --git a/example/src/main/java/io/appwrite/android/utils/Client.kt b/example/src/main/java/io/appwrite/android/utils/Client.kt index 027b718..66ce681 100644 --- a/example/src/main/java/io/appwrite/android/utils/Client.kt +++ b/example/src/main/java/io/appwrite/android/utils/Client.kt @@ -8,8 +8,13 @@ object Client { fun create(context: Context) { client = Client(context) - .setEndpoint("http://192.168.4.24/v1") - .setProject("65a8e2b4632c04b1f5da") - .setSelfSigned(true) + .setEndpoint("https://demo.appwrite.io/v1") + .setProject("6070749e6acd4") + + /* Useful when testing locally */ +// client = Client(context) +// .setEndpoint("https://192.168.1.35/v1") +// .setProject("60bdbc911784e") +// .setSelfSigned(true) } } \ No newline at end of file diff --git a/example/src/main/res/layout/fragment_account.xml b/example/src/main/res/layout/fragment_account.xml index 4173be1..2fb34c9 100644 --- a/example/src/main/res/layout/fragment_account.xml +++ b/example/src/main/res/layout/fragment_account.xml @@ -57,7 +57,6 @@ android:layout_height="wrap_content" android:layout_marginTop="16dp" android:hint="name" - android:text="Tester" android:inputType="text" app:layout_constraintStart_toStartOf="@id/password" app:layout_constraintTop_toBottomOf="@id/password" /> diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ebd754f..85e684f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Tue Jun 01 15:55:54 IST 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/library/build.gradle b/library/build.gradle index b361708..3dc0138 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -22,14 +22,8 @@ ext { version PUBLISH_VERSION android { - namespace PUBLISH_GROUP_ID - compileSdkVersion(34) - buildFeatures { - buildConfig true - } - defaultConfig { minSdkVersion(21) targetSdkVersion(34) @@ -49,6 +43,10 @@ android { ) } } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } kotlinOptions { jvmTarget = "1.8" } @@ -56,31 +54,27 @@ android { dependencies { implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version") - api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1") - api("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1") + 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.12.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.10.1") - - api(platform("com.google.firebase:firebase-bom:32.7.0")) - api("com.google.firebase:firebase-messaging") + implementation("com.google.code.gson:gson:2.9.0") - implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0") - implementation("androidx.lifecycle:lifecycle-common-java8:2.7.0") - implementation("androidx.appcompat:appcompat:1.6.1") - implementation("androidx.fragment:fragment-ktx:1.6.2") - implementation("androidx.activity:activity-ktx:1.8.2") - implementation("androidx.browser:browser:1.7.0") - implementation("androidx.core:core-ktx:1.12.0") + implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.5.1") + implementation("androidx.lifecycle:lifecycle-common-java8:2.5.1") + implementation("androidx.appcompat:appcompat:1.6.0") + implementation("androidx.fragment:fragment-ktx:1.5.5") + implementation("androidx.activity:activity-ktx:1.6.1") + implementation("androidx.browser:browser:1.4.0") - testImplementation("junit:junit:4.13.2") - testImplementation("androidx.test.ext:junit-ktx:1.1.5") - testImplementation("androidx.test:core-ktx:1.5.0") - testImplementation("org.robolectric:robolectric:4.5.1") - testApi("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.1") + testImplementation 'junit:junit:4.13.2' + testImplementation "androidx.test.ext:junit-ktx:1.1.5" + testImplementation "androidx.test:core-ktx:1.5.0" + testImplementation "org.robolectric:robolectric:4.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 +apply from: "${rootProject.projectDir}/scripts/publish-module.gradle" diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml index 899321d..b0ab63a 100644 --- a/library/src/main/AndroidManifest.xml +++ b/library/src/main/AndroidManifest.xml @@ -1,7 +1,8 @@ - + - - + \ 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 eeda5ce..94f82b6 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -1,13 +1,13 @@ package io.appwrite import android.content.Context -import android.content.Intent import android.content.pm.PackageManager import com.google.gson.GsonBuilder import com.google.gson.reflect.TypeToken -import io.appwrite.cookies.ListenableCookieJar +import io.appwrite.appwrite.BuildConfig import io.appwrite.cookies.stores.SharedPreferencesCookieStore import io.appwrite.exceptions.AppwriteException +import io.appwrite.extensions.fromJson import io.appwrite.json.PreciseNumberAdapter import io.appwrite.models.InputFile import io.appwrite.models.UploadProgress @@ -30,6 +30,7 @@ import java.net.CookieManager import java.net.CookiePolicy import java.security.SecureRandom import java.security.cert.X509Certificate +import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLContext import javax.net.ssl.SSLSocketFactory import javax.net.ssl.TrustManager @@ -39,15 +40,13 @@ import kotlin.coroutines.resume class Client @JvmOverloads constructor( context: Context, - var endpoint: String = "https://HOSTNAME/v1", - var endpointRealtime: String? = null, + var endPoint: String = "https://HOSTNAME/v1", + var endPointRealtime: String? = null, private var selfSigned: Boolean = false ) : CoroutineScope { companion object { - internal const val CHUNK_SIZE = 5*1024*1024; // 5MB - internal const val GLOBAL_PREFS = "io.appwrite" - internal const val COOKIE_PREFS = "myCookie" + const val CHUNK_SIZE = 5*1024*1024; // 5MB } override val coroutineContext: CoroutineContext @@ -60,16 +59,16 @@ class Client @JvmOverloads constructor( PreciseNumberAdapter() ).create() - internal lateinit var http: OkHttpClient + lateinit var http: OkHttpClient - internal val headers: MutableMap + private val headers: MutableMap val config: MutableMap - internal val cookieJar = ListenableCookieJar(CookieManager( - SharedPreferencesCookieStore(context.getSharedPreferences(COOKIE_PREFS, Context.MODE_PRIVATE)), + private val cookieJar = CookieManager( + SharedPreferencesCookieStore(context, "myCookie"), CookiePolicy.ACCEPT_ALL - )) + ) private val appVersion by lazy { try { @@ -89,18 +88,12 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "5.0.0-rc.1", + "x-sdk-version" to "4.0.1", "x-appwrite-response-format" to "1.4.0" ) config = mutableMapOf() setSelfSigned(selfSigned) - - NotificationHandler.client = this - - context.startService(Intent(context, NotificationHandler::class.java).apply { - action = NotificationHandler.ACTION_CLIENT_INIT - }) } /** @@ -146,21 +139,6 @@ class Client @JvmOverloads constructor( return this } - /** - * Set Session - * - * The user session to authenticate with - * - * @param {string} session - * - * @return this - */ - fun setSession(value: String): Client { - config["session"] = value - addHeader("x-appwrite-session", value) - return this - } - /** * Set self Signed * @@ -173,7 +151,7 @@ class Client @JvmOverloads constructor( val builder = OkHttpClient() .newBuilder() - .cookieJar(cookieJar) + .cookieJar(JavaNetCookieJar(cookieJar)) if (!selfSigned) { http = builder.build() @@ -203,7 +181,7 @@ class Client @JvmOverloads constructor( // Create an ssl socket factory with our all-trusting manager val sslSocketFactory: SSLSocketFactory = sslContext.socketFactory builder.sslSocketFactory(sslSocketFactory, trustAllCerts[0] as X509TrustManager) - builder.hostnameVerifier { _, _ -> true } + builder.hostnameVerifier(HostnameVerifier { _, _ -> true }) http = builder.build() } catch (e: Exception) { @@ -220,11 +198,11 @@ class Client @JvmOverloads constructor( * * @return this */ - fun setEndpoint(endpoint: String): Client { - this.endpoint = endpoint + fun setEndpoint(endPoint: String): Client { + this.endPoint = endPoint - if (this.endpointRealtime == null && endpoint.startsWith("http")) { - this.endpointRealtime = endpoint.replaceFirst("http", "ws") + if (this.endPointRealtime == null && endPoint.startsWith("http")) { + this.endPointRealtime = endPoint.replaceFirst("http", "ws") } return this @@ -237,20 +215,8 @@ class Client @JvmOverloads constructor( * * @return this */ - fun setEndpointRealtime(endpoint: String): Client { - this.endpointRealtime = endpoint - return this - } - - /** - * Set push provider ID - * - * @param endpoint - * - * @return this - */ - fun setPushProviderId(providerId: String): Client { - NotificationHandler.providerId = providerId + fun setEndpointRealtime(endPoint: String): Client { + this.endPointRealtime = endPoint return this } @@ -292,7 +258,7 @@ class Client @JvmOverloads constructor( .addAll(headers.toHeaders()) .build() - val httpBuilder = (endpoint + path).toHttpUrl().newBuilder() + val httpBuilder = (endPoint + path).toHttpUrl().newBuilder() if ("GET" == method) { filteredParams.forEach { @@ -470,14 +436,14 @@ class Client @JvmOverloads constructor( ) offset += CHUNK_SIZE - headers["x-appwrite-id"] = result["\$id"].toString() + headers["x-appwrite-id"] = result!!["\$id"].toString() onProgress?.invoke( UploadProgress( - id = result["\$id"].toString(), + id = result!!["\$id"].toString(), progress = offset.coerceAtMost(size).toDouble() / size * 100, sizeUploaded = offset.coerceAtMost(size), - chunksTotal = result["chunksTotal"].toString().toInt(), - chunksUploaded = result["chunksUploaded"].toString().toInt(), + chunksTotal = result!!["chunksTotal"].toString().toInt(), + chunksUploaded = result!!["chunksUploaded"].toString().toInt(), ) ) } diff --git a/library/src/main/java/io/appwrite/NotificationHandler.kt b/library/src/main/java/io/appwrite/NotificationHandler.kt deleted file mode 100644 index db007b8..0000000 --- a/library/src/main/java/io/appwrite/NotificationHandler.kt +++ /dev/null @@ -1,410 +0,0 @@ -package io.appwrite - -import android.Manifest -import android.app.NotificationChannel -import android.app.NotificationManager -import android.app.PendingIntent -import android.content.Context -import android.content.Intent -import android.content.SharedPreferences -import android.content.pm.PackageManager -import android.os.Build -import android.util.Log -import androidx.annotation.RequiresApi -import androidx.core.app.NotificationCompat -import com.google.android.gms.tasks.OnCompleteListener -import com.google.firebase.messaging.FirebaseMessaging -import com.google.firebase.messaging.FirebaseMessagingService -import com.google.firebase.messaging.RemoteMessage -import io.appwrite.cookies.CookieListener -import io.appwrite.exceptions.AppwriteException -import io.appwrite.extensions.fromJson -import io.appwrite.extensions.onNotificationReceived -import io.appwrite.extensions.toJson -import io.appwrite.models.Notification -import io.appwrite.models.Target -import io.appwrite.models.User -import io.appwrite.services.Account -import kotlinx.coroutines.runBlocking -import kotlinx.coroutines.suspendCancellableCoroutine -import kotlinx.coroutines.sync.Mutex -import kotlinx.coroutines.sync.withLock -import okhttp3.Cookie -import okhttp3.Headers -import okhttp3.MediaType.Companion.toMediaType -import okhttp3.OkHttpClient -import okhttp3.Request -import okhttp3.RequestBody -import okhttp3.RequestBody.Companion.toRequestBody -import okhttp3.internal.cookieToString -import java.io.IOException -import kotlin.properties.Delegates - -class NotificationHandler : FirebaseMessagingService() { - - companion object { - internal const val ACTION_CLIENT_INIT = "io.appwrite.ACTION_CLIENT_INIT" - internal const val LISTENER_KEY = "io.appwrite.NotificationHandler" - - internal val httpClient = OkHttpClient() - - internal var client: Client? = null - internal var account: Account? = null - internal var providerId: String? = null - - internal var cookieListener: CookieListener? = null - - /** - * Should notifications be automatically displayed if the app is in the foreground - */ - var displayForeground = true - - /** - * The icon to display in the notification - */ - var displayIcon by Delegates.notNull() - - /** - * Should the notification be automatically canceled when the user clicks on it - */ - var autoCancel = false - - /** - * The intent to fire when the user clicks on the notification - */ - var contentIntent: PendingIntent? = null - - /** - * The channel id to use for the notification - */ - @RequiresApi(Build.VERSION_CODES.N) - var channelId = "io.appwrite.notifications" - - /** - * The channel name to use for the notification - */ - @RequiresApi(Build.VERSION_CODES.N) - var channelName = "All Notifications" - - /** - * The channel description to use for the notification - */ - @RequiresApi(Build.VERSION_CODES.N) - var channelDescription = "All notifications" - - /** - * The channel importance to use for the notification - */ - @RequiresApi(Build.VERSION_CODES.N) - var channelImportance = NotificationManager.IMPORTANCE_DEFAULT - } - - private lateinit var mutex: Mutex - - private lateinit var globalPrefs: SharedPreferences - - private var existingCookies: List = listOf() - private var newCookies: List = listOf() - - override fun getStartCommandIntent(originalIntent: Intent?): Intent { - if (originalIntent?.action == ACTION_CLIENT_INIT) { - return originalIntent - } - - return super.getStartCommandIntent(originalIntent) - } - - override fun handleIntent(intent: Intent?) { - if (intent?.action == ACTION_CLIENT_INIT) { - onClientInit() - return - } - - super.handleIntent(intent) - } - - override fun onCreate() { - super.onCreate() - - globalPrefs = applicationContext.getSharedPreferences( - Client.GLOBAL_PREFS, Context.MODE_PRIVATE - ) - - displayIcon = resources.getIdentifier( - "ic_launcher_foreground", "drawable", packageName - ) - - mutex = Mutex() - - if (cookieListener == null) { - cookieListener = { existing, new -> - FirebaseMessaging.getInstance().token.addOnCompleteListener(OnCompleteListener { task -> - if (!task.isSuccessful) { - Log.w(javaClass.name, "Fetching FCM registration token failed", task.exception) - return@OnCompleteListener - } - - val token = task.result - if (token.isNullOrEmpty()) { - return@OnCompleteListener - } - - existingCookies = existing - newCookies = new - - onNewToken(token) - }) - } - } - - if (client != null) { - client?.cookieJar?.onSave(LISTENER_KEY, cookieListener!!) - } - } - - override fun onNewToken(token: String) { - runBlocking { - mutex.withLock { - pushToken(token) - } - } - } - - override fun onMessageReceived(message: RemoteMessage) { - super.onMessageReceived(message) - - // Fire callbacks before display so handler can be configured if needed - onNotificationReceived( - Notification( - title = message.notification?.title ?: "", - body = message.notification?.body ?: "", - clickAction = message.notification?.clickAction ?: "", - color = message.notification?.color ?: "", - icon = message.notification?.icon ?: "", - imageURL = message.notification?.imageUrl?.toString() ?: "", - sound = message.notification?.sound ?: "", - data = message.data - ) - ) - - val notificationManager = - getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - val channel = NotificationChannel( - channelId, channelName, channelImportance - ).apply { - description = channelDescription - } - - // Recreate is a no-op if the channel already exists - notificationManager.createNotificationChannel(channel) - } - - if (message.notification != null && displayForeground) { - val builder = NotificationCompat.Builder(this, "io.appwrite.notifications") - .setContentTitle(message.notification?.title) - .setContentText(message.notification?.body) - .setPriority(NotificationCompat.PRIORITY_DEFAULT).setAutoCancel(autoCancel) - .setContentIntent(contentIntent) - - if (displayIcon != 0) { - builder.setSmallIcon(displayIcon) - } - - val notification = builder.build() - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - val hasPermission = packageManager.checkPermission( - Manifest.permission.POST_NOTIFICATIONS, - packageName - ) == PackageManager.PERMISSION_GRANTED - - if (!hasPermission) { - Log.w(javaClass.name, "Permission denied, make sure you have requested the POST_NOTIFICATIONS permission") - } - } - - notificationManager.notify(message.hashCode(), notification) - } - } - - private fun onClientInit() { - if (client == null) { - return - } - - if (account == null) { - account = Account(client!!) - } - - client?.cookieJar?.onSave(LISTENER_KEY, cookieListener!!) - } - - private suspend fun pushToken(token: String) { - if (client == null) { - return - } - - val currentToken = globalPrefs.getString("fcmToken", "") ?: "" - var currentTargetId = globalPrefs.getString("targetId", "") ?: "" - val existingUser: User>? - try { - existingUser = if (existingCookies.isEmpty() && newCookies.isNotEmpty()) { - request( - "GET", - "/account", - mapOf("cookie" to newCookies.joinToString("; ") { - cookieToString(it, true) - }) - ) - } else if (existingCookies.isNotEmpty()) { - request( - "GET", - "/account", - mapOf("cookie" to existingCookies.joinToString("; ") { - cookieToString(it, true) - }) - ) - } else { - account?.get() - } - } catch (ex: AppwriteException) { - Log.d(javaClass.name, "No existing user") - return - } - - if (existingUser == null) { - Log.d(javaClass.name, "No existing user") - return - } - - var newUser: User>? = null - if (newCookies.isNotEmpty()) { - newUser = request( - "GET", - "/account", - mapOf("cookie" to newCookies.joinToString("; ") { - cookieToString(it, true) - }) - ) - Log.d(javaClass.name, "New user: ${newUser!!.id}") - } - - if ( - token == currentToken - && (existingCookies.isNotEmpty() && existingUser.id == newUser?.id) - ) { - Log.d(javaClass.name, "Token and user are the same") - return - } - - globalPrefs.edit().putString("fcmToken", token).apply() - - try { - if (existingCookies.isNotEmpty() && existingUser.id != newUser?.id) { - Log.d(javaClass.name, "User has changed") - if (currentTargetId.isNotEmpty()) { - Log.d(javaClass.name, "Deleting existing target") - request( - "DELETE", - "/account/targets/$currentTargetId/push", - mapOf("cookie" to existingCookies.joinToString("; ") { - cookieToString(it, true) - }) - ) - globalPrefs.edit().remove("targetId").apply() - currentTargetId = "" - } - } - } catch (ex: AppwriteException) { - Log.e(javaClass.name, "Failed to delete existing target", ex) - } - - try { - val target: Target? - - if ((currentTargetId.isEmpty() && existingCookies.isEmpty()) || existingUser.id != newUser?.id) { - Log.d(javaClass.name, "Creating new target") - val params = mutableMapOf( - "targetId" to ID.unique(), - "identifier" to token - ) - if (providerId != null) { - params["providerId"] = providerId!! - } - target = request( - "POST", - "/account/targets/push", - mapOf("cookie" to newCookies.joinToString("; ") { - cookieToString(it, true) - }), - params.toJson().toRequestBody("application/json".toMediaType()) - ) - Log.d(javaClass.name, "New target: ${target?.id}") - } else { - Log.d(javaClass.name, "Updating existing target") - target = account?.updatePushTarget(currentTargetId, token) - Log.d(javaClass.name, "Updated target: ${target?.id}") - } - - globalPrefs.edit().putString("targetId", target?.id).apply() - } catch (ex: AppwriteException) { - Log.e(javaClass.name, "Failed to push token", ex) - } - - existingCookies = emptyList() - newCookies = emptyList() - Log.d(javaClass.name, "Token pushed") - } - - private suspend inline fun request( - method: String, - path: String, - headers: Map, - body: RequestBody? = null - ): T? { - val headerBuilder = Headers.Builder() - - for ((key, value) in client?.headers ?: mapOf()) { - headerBuilder.add(key, value) - } - - for ((key, value) in headers) { - headerBuilder.add(key, value) - } - - val request = Request.Builder() - .method(method, body) - .url(client?.endpoint + path) - .headers(headerBuilder.build()) - .build() - - try { - return suspendCancellableCoroutine { - httpClient - .newCall(request) - .enqueue(object : okhttp3.Callback { - override fun onFailure(call: okhttp3.Call, e: IOException) { - Log.e(javaClass.name, "Request failed", e) - it.resumeWith(Result.failure(e)) - } - override fun onResponse( - call: okhttp3.Call, - response: okhttp3.Response - ) { - if (response.isSuccessful) { - val bodyString = response.body?.string() - - it.resumeWith(Result.success(bodyString?.fromJson())) - } else { - it.resumeWith(Result.failure(IOException("Request failed with code ${response.code}"))) - } - } - }) - } - } catch (ex: IOException) { - return null - } - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/Query.kt b/library/src/main/java/io/appwrite/Query.kt index 6efbb11..7957865 100644 --- a/library/src/main/java/io/appwrite/Query.kt +++ b/library/src/main/java/io/appwrite/Query.kt @@ -1,65 +1,60 @@ package io.appwrite -import io.appwrite.extensions.toJson -import io.appwrite.extensions.fromJson +class Query { + companion object { + fun equal(attribute: String, value: Any) = addQuery(attribute, "equal", value) -class Query( - val method: String, - val attribute: String? = null, - val values: List? = null, -) { - override fun toString() = this.toJson() + fun notEqual(attribute: String, value: Any) = Query.addQuery(attribute, "notEqual", value) - companion object { - fun equal(attribute: String, value: Any) = Query("equal", attribute, parseValue(value)).toJson() + fun lessThan(attribute: String, value: Any) = Query.addQuery(attribute, "lessThan", value) - fun notEqual(attribute: String, value: Any) = Query("notEqual", attribute, parseValue(value)).toJson() + fun lessThanEqual(attribute: String, value: Any) = Query.addQuery(attribute, "lessThanEqual", value) - fun lessThan(attribute: String, value: Any) = Query("lessThan", attribute, parseValue(value)).toJson() + fun greaterThan(attribute: String, value: Any) = Query.addQuery(attribute, "greaterThan", value) - fun lessThanEqual(attribute: String, value: Any) = Query("lessThanEqual", attribute, parseValue(value)).toJson() + fun greaterThanEqual(attribute: String, value: Any) = Query.addQuery(attribute, "greaterThanEqual", value) + + fun search(attribute: String, value: String) = Query.addQuery(attribute, "search", value) - fun greaterThan(attribute: String, value: Any) = Query("greaterThan", attribute, parseValue(value)).toJson() + fun isNull(attribute: String) = "isNull(\"${attribute}\")" - fun greaterThanEqual(attribute: String, value: Any) = Query("greaterThanEqual", attribute, parseValue(value)).toJson() + fun isNotNull(attribute: String) = "isNotNull(\"${attribute}\")" - fun search(attribute: String, value: String) = Query("search", attribute, listOf(value)).toJson() + fun between(attribute: String, start: Int, end: Int) = "between(\"${attribute}\", ${start}, ${end})" - fun isNull(attribute: String) = Query("isNull", attribute).toJson() + fun between(attribute: String, start: Double, end: Double) = "between(\"${attribute}\", ${start}, ${end})" - fun isNotNull(attribute: String) = Query("isNotNull", attribute).toJson() + fun between(attribute: String, start: String, end: String) = "between(\"${attribute}\", \"${start}\", \"${end}\")" - fun between(attribute: String, start: Any, end: Any) = Query("between", attribute, listOf(start, end)).toJson() + fun startsWith(attribute: String, value: String) = Query.addQuery(attribute, "startsWith", value) - fun startsWith(attribute: String, value: String) = Query("startsWith", attribute, listOf(value)).toJson() + fun endsWith(attribute: String, value: String) = Query.addQuery(attribute, "endsWith", value) - fun endsWith(attribute: String, value: String) = Query("endsWith", attribute, listOf(value)).toJson() + fun select(attributes: List) = "select([${attributes.joinToString(",") { "\"$it\"" }}])" - fun select(attributes: List) = Query("select", null, attributes).toJson() + fun orderAsc(attribute: String) = "orderAsc(\"${attribute}\")" - fun orderAsc(attribute: String) = Query("orderAsc", attribute).toJson() + fun orderDesc(attribute: String) = "orderDesc(\"${attribute}\")" - fun orderDesc(attribute: String) = Query("orderDesc", attribute).toJson() + fun cursorBefore(documentId: String) = "cursorBefore(\"${documentId}\")" - fun cursorBefore(documentId: String) = Query("cursorBefore", null, listOf(documentId)).toJson() + fun cursorAfter(documentId: String) = "cursorAfter(\"${documentId}\")" - fun cursorAfter(documentId: String) = Query("cursorAfter", null, listOf(documentId)).toJson() + fun limit(limit: Int) = "limit(${limit})" - fun limit(limit: Int) = Query("limit", null, listOf(limit)).toJson() + fun offset(offset: Int) = "offset(${offset})" - fun offset(offset: Int) = Query("offset", null, listOf(offset)).toJson() - - fun contains(attribute: String, value: Any) = Query("contains", attribute, parseValue(value)).toJson() - - fun or(queries: List) = Query("or", null, queries.map { it.fromJson() }).toJson() - - fun and(queries: List) = Query("and", null, queries.map { it.fromJson() }).toJson() - - private fun parseValue(value: Any): List { - return when (value) { - is List<*> -> value as List - else -> listOf(value) - } - } + private fun addQuery(attribute: String, method: String, value: Any): String { + return when (value) { + is List<*> -> "${method}(\"${attribute}\", [${value.map{it -> parseValues(it!!)}.joinToString(",")}])" + else -> "${method}(\"${attribute}\", [${Query.parseValues(value)}])" + } + } + private fun parseValues(value: Any): String { + return when (value) { + is String -> "\"${value}\"" + else -> "${value}" + } } -} \ No newline at end of file + } +} diff --git a/library/src/main/java/io/appwrite/cookies/ListenableCookieJar.kt b/library/src/main/java/io/appwrite/cookies/ListenableCookieJar.kt deleted file mode 100644 index 863eb42..0000000 --- a/library/src/main/java/io/appwrite/cookies/ListenableCookieJar.kt +++ /dev/null @@ -1,119 +0,0 @@ -package io.appwrite.cookies - -import okhttp3.Cookie -import okhttp3.CookieJar -import okhttp3.HttpUrl -import okhttp3.internal.cookieToString -import okhttp3.internal.delimiterOffset -import okhttp3.internal.platform.Platform -import okhttp3.internal.trimSubstring -import java.io.IOException -import java.net.CookieHandler -import java.net.HttpCookie -import java.util.Collections - -typealias CookieListener = (existing: List, new: List) -> Unit - -class ListenableCookieJar(private val cookieHandler: CookieHandler) : CookieJar { - - private val listeners: MutableMap = mutableMapOf() - - fun onSave(key: String, listener: CookieListener) { - listeners[key.hashCode()] = listener - } - - override fun saveFromResponse(url: HttpUrl, cookies: List) { - val existingCookies = loadForRequest(url) - - listeners.values.forEach { it(existingCookies, cookies) } - - val cookieStrings = mutableListOf() - for (cookie in cookies) { - cookieStrings.add(cookieToString(cookie, true)) - } - val multimap = mapOf("Set-Cookie" to cookieStrings) - try { - cookieHandler.put(url.toUri(), multimap) - } catch (e: IOException) { - Platform.get().log( - "Saving cookies failed for " + url.resolve("/...")!!, - Platform.WARN, e - ) - } - } - - override fun loadForRequest(url: HttpUrl): List { - val cookieHeaders = try { - cookieHandler.get(url.toUri(), emptyMap>()) - } catch (e: IOException) { - Platform.get().log( - "Loading cookies failed for " + url.resolve("/...")!!, - Platform.WARN, e - ) - return emptyList() - } - - var cookies: MutableList? = null - for ((key, value) in cookieHeaders) { - if (("Cookie".equals(key, ignoreCase = true) || "Cookie2".equals( - key, - ignoreCase = true - )) && - value.isNotEmpty() - ) { - for (header in value) { - if (cookies == null) cookies = mutableListOf() - cookies.addAll(decodeHeaderAsJavaNetCookies(url, header)) - } - } - } - - return if (cookies != null) { - Collections.unmodifiableList(cookies) - } else { - emptyList() - } - } - - /** - * Convert a request header to OkHttp's cookies via [HttpCookie]. That extra step handles - * multiple cookies in a single request header, which [Cookie.parse] doesn't support. - */ - private fun decodeHeaderAsJavaNetCookies(url: HttpUrl, header: String): List { - val result = mutableListOf() - var pos = 0 - val limit = header.length - var pairEnd: Int - while (pos < limit) { - pairEnd = header.delimiterOffset(";,", pos, limit) - val equalsSign = header.delimiterOffset('=', pos, pairEnd) - val name = header.trimSubstring(pos, equalsSign) - if (name.startsWith("$")) { - pos = pairEnd + 1 - continue - } - - // We have either name=value or just a name. - var value = if (equalsSign < pairEnd) { - header.trimSubstring(equalsSign + 1, pairEnd) - } else { - "" - } - - // If the value is "quoted", drop the quotes. - if (value.startsWith("\"") && value.endsWith("\"")) { - value = value.substring(1, value.length - 1) - } - - result.add( - Cookie.Builder() - .name(name) - .value(value) - .domain(url.host) - .build() - ) - pos = pairEnd + 1 - } - return result - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/cookies/stores/InMemoryCookieStore.kt b/library/src/main/java/io/appwrite/cookies/stores/InMemoryCookieStore.kt index 1f2b536..7de9ec9 100644 --- a/library/src/main/java/io/appwrite/cookies/stores/InMemoryCookieStore.kt +++ b/library/src/main/java/io/appwrite/cookies/stores/InMemoryCookieStore.kt @@ -6,9 +6,10 @@ import java.net.CookieStore import java.net.HttpCookie import java.net.URI import java.net.URISyntaxException +import java.util.Collections import java.util.concurrent.locks.ReentrantLock -open class InMemoryCookieStore : CookieStore { +open class InMemoryCookieStore(private val name: String) : CookieStore { internal val uriIndex = mutableMapOf>() private val lock = ReentrantLock(false) @@ -28,7 +29,7 @@ open class InMemoryCookieStore : CookieStore { if (cookie == null) { Log.i( javaClass.simpleName, - "Tried to add null cookie in cookie store. Doing nothing." + "tried to add null cookie in cookie store named $name. Doing nothing." ) return } @@ -36,7 +37,7 @@ open class InMemoryCookieStore : CookieStore { if (uri == null) { Log.i( javaClass.simpleName, - "Tried to add null URI in cookie store. Doing nothing." + "tried to add null URI in cookie store named $name. Doing nothing." ) return } @@ -88,7 +89,7 @@ open class InMemoryCookieStore : CookieStore { if (cookie == null) { Log.i( javaClass.simpleName, - "Tried to remove null cookie from cookie store. Doing nothing." + "tried to remove null cookie from cookie store named $name. Doing nothing." ) return true } @@ -96,7 +97,7 @@ open class InMemoryCookieStore : CookieStore { if (uri == null) { Log.i( javaClass.simpleName, - "Tried to remove null URI from cookie store. Doing nothing." + "tried to remove null URI from cookie store named $name. Doing nothing." ) return true } @@ -121,7 +122,7 @@ open class InMemoryCookieStore : CookieStore { if (uri == null) { Log.i( javaClass.simpleName, - "Getting cookies from cookie store for null URI results in empty list" + "getting cookies from cookie store named $name for null URI results in empty list" ) return emptyList() } diff --git a/library/src/main/java/io/appwrite/cookies/stores/SharedPreferencesCookieStore.kt b/library/src/main/java/io/appwrite/cookies/stores/SharedPreferencesCookieStore.kt index 0c0b760..83c677d 100644 --- a/library/src/main/java/io/appwrite/cookies/stores/SharedPreferencesCookieStore.kt +++ b/library/src/main/java/io/appwrite/cookies/stores/SharedPreferencesCookieStore.kt @@ -1,7 +1,7 @@ package io.appwrite.cookies.stores import io.appwrite.cookies.InternalCookie -import android.content.SharedPreferences +import android.content.Context import android.os.Build import android.util.Log import com.google.gson.Gson @@ -10,9 +10,11 @@ import java.net.HttpCookie import java.net.URI open class SharedPreferencesCookieStore( - private val preferences: SharedPreferences, -) : InMemoryCookieStore() { + context: Context, + private val name: String +) : InMemoryCookieStore(name) { + private val preferences = context.getSharedPreferences(name, Context.MODE_PRIVATE) private val gson = Gson() init { @@ -28,7 +30,7 @@ open class SharedPreferencesCookieStore( } catch (exception: Throwable) { Log.e( javaClass.simpleName, - "Error while loading key = $key, value = $value from cookie store", + "Error while loading key = $key, value = $value from cookie store named $name", exception ) } diff --git a/library/src/main/java/io/appwrite/enums/AuthenticatorFactor.kt b/library/src/main/java/io/appwrite/enums/AuthenticatorFactor.kt deleted file mode 100644 index 1e0a0c4..0000000 --- a/library/src/main/java/io/appwrite/enums/AuthenticatorFactor.kt +++ /dev/null @@ -1,7 +0,0 @@ -package io.appwrite.enums - -enum class AuthenticatorFactor(val value: String) { - TOTP("totp"); - - override fun toString() = value -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/AuthenticatorProvider.kt b/library/src/main/java/io/appwrite/enums/AuthenticatorProvider.kt deleted file mode 100644 index 7757f8e..0000000 --- a/library/src/main/java/io/appwrite/enums/AuthenticatorProvider.kt +++ /dev/null @@ -1,7 +0,0 @@ -package io.appwrite.enums - -enum class AuthenticatorProvider(val value: String) { - TOTP("totp"); - - override fun toString() = value -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/Browser.kt b/library/src/main/java/io/appwrite/enums/Browser.kt deleted file mode 100644 index 99f598e..0000000 --- a/library/src/main/java/io/appwrite/enums/Browser.kt +++ /dev/null @@ -1,20 +0,0 @@ -package io.appwrite.enums - -enum class Browser(val value: String) { - AVANT_BROWSER("aa"), - ANDROID_WEB_VIEW_BETA("an"), - GOOGLE_CHROME("ch"), - GOOGLE_CHROMEI_OS("ci"), - GOOGLE_CHROME_MOBILE("cm"), - CHROMIUM("cr"), - MOZILLA_FIREFOX("ff"), - SAFARI("sf"), - MOBILE_SAFARI("mf"), - MICROSOFT_EDGE("ps"), - MICROSOFT_EDGEI_OS("oi"), - OPERA_MINI("om"), - OPERA("op"), - OPERA_NEXT("on"); - - override fun toString() = value -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/CreditCard.kt b/library/src/main/java/io/appwrite/enums/CreditCard.kt deleted file mode 100644 index e99519b..0000000 --- a/library/src/main/java/io/appwrite/enums/CreditCard.kt +++ /dev/null @@ -1,22 +0,0 @@ -package io.appwrite.enums - -enum class CreditCard(val value: String) { - AMERICAN_EXPRESS("amex"), - ARGENCARD("argencard"), - CABAL("cabal"), - CONSOSUD("censosud"), - DINERS_CLUB("diners"), - DISCOVER("discover"), - ELO("elo"), - HIPERCARD("hipercard"), - JCB("jcb"), - MASTERCARD("mastercard"), - NARANJA("naranja"), - TARJETA_SHOPPING("targeta-shopping"), - UNION_CHINA_PAY("union-china-pay"), - VISA("visa"), - MIR("mir"), - MAESTRO("maestro"); - - override fun toString() = value -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/ExecutionMethod.kt b/library/src/main/java/io/appwrite/enums/ExecutionMethod.kt deleted file mode 100644 index edeb66b..0000000 --- a/library/src/main/java/io/appwrite/enums/ExecutionMethod.kt +++ /dev/null @@ -1,12 +0,0 @@ -package io.appwrite.enums - -enum class ExecutionMethod(val value: String) { - GET("GET"), - POST("POST"), - PUT("PUT"), - PATCH("PATCH"), - DELETE("DELETE"), - OPTIONS("OPTIONS"); - - override fun toString() = value -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/Flag.kt b/library/src/main/java/io/appwrite/enums/Flag.kt deleted file mode 100644 index 4fcdd88..0000000 --- a/library/src/main/java/io/appwrite/enums/Flag.kt +++ /dev/null @@ -1,200 +0,0 @@ -package io.appwrite.enums - -enum class Flag(val value: String) { - AFGHANISTAN("af"), - ANGOLA("ao"), - ALBANIA("al"), - ANDORRA("ad"), - UNITED_ARAB_EMIRATES("ae"), - ARGENTINA("ar"), - ARMENIA("am"), - ANTIGUAAND_BARBUDA("ag"), - AUSTRALIA("au"), - AUSTRIA("at"), - AZERBAIJAN("az"), - BURUNDI("bi"), - BELGIUM("be"), - BENIN("bj"), - BURKINA_FASO("bf"), - BANGLADESH("bd"), - BULGARIA("bg"), - BAHRAIN("bh"), - BAHAMAS("bs"), - BOSNIAAND_HERZEGOVINA("ba"), - BELARUS("by"), - BELIZE("bz"), - BOLIVIA("bo"), - BRAZIL("br"), - BARBADOS("bb"), - BRUNEI_DARUSSALAM("bn"), - BHUTAN("bt"), - BOTSWANA("bw"), - CENTRAL_AFRICAN_REPUBLIC("cf"), - CANADA("ca"), - SWITZERLAND("ch"), - CHILE("cl"), - CHINA("cn"), - CTED_IVOIRE("ci"), - CAMEROON("cm"), - DEMOCRATIC_REPUBLICOFTHE_CONGO("cd"), - REPUBLICOFTHE_CONGO("cg"), - COLOMBIA("co"), - COMOROS("km"), - CAPE_VERDE("cv"), - COSTA_RICA("cr"), - CUBA("cu"), - CYPRUS("cy"), - CZECH_REPUBLIC("cz"), - GERMANY("de"), - DJIBOUTI("dj"), - DOMINICA("dm"), - DENMARK("dk"), - DOMINICAN_REPUBLIC("do"), - ALGERIA("dz"), - ECUADOR("ec"), - EGYPT("eg"), - ERITREA("er"), - SPAIN("es"), - ESTONIA("ee"), - ETHIOPIA("et"), - FINLAND("fi"), - FIJI("fj"), - FRANCE("fr"), - MICRONESIA_FEDERATED_STATESOF("fm"), - GABON("ga"), - UNITED_KINGDOM("gb"), - GEORGIA("ge"), - GHANA("gh"), - GUINEA("gn"), - GAMBIA("gm"), - GUINEA_BISSAU("gw"), - EQUATORIAL_GUINEA("gq"), - GREECE("gr"), - GRENADA("gd"), - GUATEMALA("gt"), - GUYANA("gy"), - HONDURAS("hn"), - CROATIA("hr"), - HAITI("ht"), - HUNGARY("hu"), - INDONESIA("id"), - INDIA("in"), - IRELAND("ie"), - IRAN_ISLAMIC_REPUBLICOF("ir"), - IRAQ("iq"), - ICELAND("is"), - ISRAEL("il"), - ITALY("it"), - JAMAICA("jm"), - JORDAN("jo"), - JAPAN("jp"), - KAZAKHSTAN("kz"), - KENYA("ke"), - KYRGYZSTAN("kg"), - CAMBODIA("kh"), - KIRIBATI("ki"), - SAINT_KITTSAND_NEVIS("kn"), - SOUTH_KOREA("kr"), - KUWAIT("kw"), - LAO_PEOPLES_DEMOCRATIC_REPUBLIC("la"), - LEBANON("lb"), - LIBERIA("lr"), - LIBYA("ly"), - SAINT_LUCIA("lc"), - LIECHTENSTEIN("li"), - SRI_LANKA("lk"), - LESOTHO("ls"), - LITHUANIA("lt"), - LUXEMBOURG("lu"), - LATVIA("lv"), - MOROCCO("ma"), - MONACO("mc"), - MOLDOVA("md"), - MADAGASCAR("mg"), - MALDIVES("mv"), - MEXICO("mx"), - MARSHALL_ISLANDS("mh"), - NORTH_MACEDONIA("mk"), - MALI("ml"), - MALTA("mt"), - MYANMAR("mm"), - MONTENEGRO("me"), - MONGOLIA("mn"), - MOZAMBIQUE("mz"), - MAURITANIA("mr"), - MAURITIUS("mu"), - MALAWI("mw"), - MALAYSIA("my"), - NAMIBIA("na"), - NIGER("ne"), - NIGERIA("ng"), - NICARAGUA("ni"), - NETHERLANDS("nl"), - NORWAY("no"), - NEPAL("np"), - NAURU("nr"), - NEW_ZEALAND("nz"), - OMAN("om"), - PAKISTAN("pk"), - PANAMA("pa"), - PERU("pe"), - PHILIPPINES("ph"), - PALAU("pw"), - PAPUA_NEW_GUINEA("pg"), - POLAND("pl"), - NORTH_KOREA("kp"), - PORTUGAL("pt"), - PARAGUAY("py"), - QATAR("qa"), - ROMANIA("ro"), - RUSSIA("ru"), - RWANDA("rw"), - SAUDI_ARABIA("sa"), - SUDAN("sd"), - SENEGAL("sn"), - SINGAPORE("sg"), - SOLOMON_ISLANDS("sb"), - SIERRA_LEONE("sl"), - EL_SALVADOR("sv"), - SAN_MARINO("sm"), - SOMALIA("so"), - SERBIA("rs"), - SOUTH_SUDAN("ss"), - SAO_TOMEAND_PRINCIPE("st"), - SURINAME("sr"), - SLOVAKIA("sk"), - SLOVENIA("si"), - SWEDEN("se"), - ESWATINI("sz"), - SEYCHELLES("sc"), - SYRIA("sy"), - CHAD("td"), - TOGO("tg"), - THAILAND("th"), - TAJIKISTAN("tj"), - TURKMENISTAN("tm"), - TIMOR_LESTE("tl"), - TONGA("to"), - TRINIDADAND_TOBAGO("tt"), - TUNISIA("tn"), - TURKEY("tr"), - TUVALU("tv"), - TANZANIA("tz"), - UGANDA("ug"), - UKRAINE("ua"), - URUGUAY("uy"), - UNITED_STATES("us"), - UZBEKISTAN("uz"), - VATICAN_CITY("va"), - SAINT_VINCENTANDTHE_GRENADINES("vc"), - VENEZUELA("ve"), - VIETNAM("vn"), - VANUATU("vu"), - SAMOA("ws"), - YEMEN("ye"), - SOUTH_AFRICA("za"), - ZAMBIA("zm"), - ZIMBABWE("zw"); - - override fun toString() = value -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/ImageFormat.kt b/library/src/main/java/io/appwrite/enums/ImageFormat.kt deleted file mode 100644 index 6a4c422..0000000 --- a/library/src/main/java/io/appwrite/enums/ImageFormat.kt +++ /dev/null @@ -1,11 +0,0 @@ -package io.appwrite.enums - -enum class ImageFormat(val value: String) { - JPG("jpg"), - JPEG("jpeg"), - GIF("gif"), - PNG("png"), - WEBP("webp"); - - override fun toString() = value -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/ImageGravity.kt b/library/src/main/java/io/appwrite/enums/ImageGravity.kt deleted file mode 100644 index a8fa441..0000000 --- a/library/src/main/java/io/appwrite/enums/ImageGravity.kt +++ /dev/null @@ -1,15 +0,0 @@ -package io.appwrite.enums - -enum class ImageGravity(val value: String) { - CENTER("center"), - TOPLEFT("top-left"), - TOP("top"), - TOPRIGHT("top-right"), - LEFT("left"), - RIGHT("right"), - BOTTOMLEFT("bottom-left"), - BOTTOM("bottom"), - BOTTOMRIGHT("bottom-right"); - - override fun toString() = value -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/OAuthProvider.kt b/library/src/main/java/io/appwrite/enums/OAuthProvider.kt deleted file mode 100644 index 4a38a2e..0000000 --- a/library/src/main/java/io/appwrite/enums/OAuthProvider.kt +++ /dev/null @@ -1,45 +0,0 @@ -package io.appwrite.enums - -enum class OAuthProvider(val value: String) { - AMAZON("amazon"), - APPLE("apple"), - AUTH0("auth0"), - AUTHENTIK("authentik"), - AUTODESK("autodesk"), - BITBUCKET("bitbucket"), - BITLY("bitly"), - BOX("box"), - DAILYMOTION("dailymotion"), - DISCORD("discord"), - DISQUS("disqus"), - DROPBOX("dropbox"), - ETSY("etsy"), - FACEBOOK("facebook"), - GITHUB("github"), - GITLAB("gitlab"), - GOOGLE("google"), - LINKEDIN("linkedin"), - MICROSOFT("microsoft"), - NOTION("notion"), - OIDC("oidc"), - OKTA("okta"), - PAYPAL("paypal"), - PAYPAL_SANDBOX("paypalSandbox"), - PODIO("podio"), - SALESFORCE("salesforce"), - SLACK("slack"), - SPOTIFY("spotify"), - STRIPE("stripe"), - TRADESHIFT("tradeshift"), - TRADESHIFT_BOX("tradeshiftBox"), - TWITCH("twitch"), - WORDPRESS("wordpress"), - YAHOO("yahoo"), - YAMMER("yammer"), - YANDEX("yandex"), - ZOHO("zoho"), - ZOOM("zoom"), - MOCK("mock"); - - override fun toString() = value -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/extensions/ActivityExtensions.kt b/library/src/main/java/io/appwrite/extensions/ActivityExtensions.kt deleted file mode 100644 index b5164b8..0000000 --- a/library/src/main/java/io/appwrite/extensions/ActivityExtensions.kt +++ /dev/null @@ -1,46 +0,0 @@ -package io.appwrite.extensions - -import android.Manifest -import android.content.pm.PackageManager -import android.os.Build -import androidx.activity.result.contract.ActivityResultContracts -import androidx.appcompat.app.AppCompatActivity -import androidx.core.content.ContextCompat - -fun AppCompatActivity.requestNotificationPermission( - onGranted: () -> Unit, - onDenied: () -> Unit, - onShowRationale: () -> Unit, -) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) { - onGranted() - return - } - - if (ContextCompat.checkSelfPermission( - this, - Manifest.permission.POST_NOTIFICATIONS - ) == PackageManager.PERMISSION_GRANTED) { - onGranted() - } else if (shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS)) { - onShowRationale() - } else { - requestPermissionLauncher( - onGranted, - onDenied - ).launch(Manifest.permission.POST_NOTIFICATIONS) - } -} - -private fun AppCompatActivity.requestPermissionLauncher( - onGranted: () -> Unit, - onDenied: () -> Unit, -) = registerForActivityResult( - ActivityResultContracts.RequestPermission(), -) { isGranted: Boolean -> - if (isGranted) { - onGranted() - } else { - onDenied() - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/extensions/MessagingExtensions.kt b/library/src/main/java/io/appwrite/extensions/MessagingExtensions.kt deleted file mode 100644 index 515ef51..0000000 --- a/library/src/main/java/io/appwrite/extensions/MessagingExtensions.kt +++ /dev/null @@ -1,14 +0,0 @@ -package io.appwrite.extensions - -import io.appwrite.models.Notification -import io.appwrite.services.Messaging - -private val callbacks: MutableList<(Notification) -> Unit> = mutableListOf() - -internal fun onNotificationReceived(notification: Notification) { - callbacks.forEach { it(notification) } -} - -fun Messaging.onNotificationReceived(callback: (Notification) -> Unit) { - callbacks.add(callback) -} \ 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 index e699a54..2674b99 100644 --- a/library/src/main/java/io/appwrite/extensions/TypeExtensions.kt +++ b/library/src/main/java/io/appwrite/extensions/TypeExtensions.kt @@ -4,6 +4,5 @@ import kotlin.reflect.KClass import kotlin.reflect.typeOf inline fun classOf(): Class { - @Suppress("UNCHECKED_CAST") return (typeOf().classifier!! as KClass).java } \ 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 17ab303..96a364f 100644 --- a/library/src/main/java/io/appwrite/models/Membership.kt +++ b/library/src/main/java/io/appwrite/models/Membership.kt @@ -73,12 +73,6 @@ data class Membership( @SerializedName("confirm") val confirm: Boolean, - /** - * Multi factor authentication status, true if the user has MFA enabled or false otherwise. - */ - @SerializedName("mfa") - val mfa: Boolean, - /** * User list of roles */ @@ -98,7 +92,6 @@ data class Membership( "invited" to invited as Any, "joined" to joined as Any, "confirm" to confirm as Any, - "mfa" to mfa as Any, "roles" to roles as Any, ) @@ -119,7 +112,6 @@ data class Membership( invited = map["invited"] as String, joined = map["joined"] as String, confirm = map["confirm"] as Boolean, - mfa = map["mfa"] as Boolean, roles = map["roles"] as List, ) } diff --git a/library/src/main/java/io/appwrite/models/MfaChallenge.kt b/library/src/main/java/io/appwrite/models/MfaChallenge.kt deleted file mode 100644 index 82b1d18..0000000 --- a/library/src/main/java/io/appwrite/models/MfaChallenge.kt +++ /dev/null @@ -1,54 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * MFA Challenge - */ -data class MfaChallenge( - /** - * 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 expiration date in ISO 8601 format. - */ - @SerializedName("expire") - val expire: String, - -) { - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "\$createdAt" to createdAt as Any, - "userId" to userId as Any, - "expire" to expire as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = MfaChallenge( - id = map["\$id"] as String, - createdAt = map["\$createdAt"] as String, - userId = map["userId"] as String, - expire = map["expire"] as String, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/MfaProvider.kt b/library/src/main/java/io/appwrite/models/MfaProvider.kt deleted file mode 100644 index 330f98a..0000000 --- a/library/src/main/java/io/appwrite/models/MfaProvider.kt +++ /dev/null @@ -1,46 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * MFAProvider - */ -data class MfaProvider( - /** - * Backup codes. - */ - @SerializedName("backups") - val backups: List, - - /** - * Secret token used for TOTP factor. - */ - @SerializedName("secret") - val secret: String, - - /** - * URI for authenticator apps. - */ - @SerializedName("uri") - val uri: String, - -) { - fun toMap(): Map = mapOf( - "backups" to backups as Any, - "secret" to secret as Any, - "uri" to uri as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = MfaProvider( - backups = map["backups"] as List, - secret = map["secret"] as String, - uri = map["uri"] as String, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/MfaProviders.kt b/library/src/main/java/io/appwrite/models/MfaProviders.kt deleted file mode 100644 index cb16f91..0000000 --- a/library/src/main/java/io/appwrite/models/MfaProviders.kt +++ /dev/null @@ -1,46 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * MFAProviders - */ -data class MfaProviders( - /** - * TOTP - */ - @SerializedName("totp") - val totp: Boolean, - - /** - * Phone - */ - @SerializedName("phone") - val phone: Boolean, - - /** - * Email - */ - @SerializedName("email") - val email: Boolean, - -) { - fun toMap(): Map = mapOf( - "totp" to totp as Any, - "phone" to phone as Any, - "email" to email as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = MfaProviders( - totp = map["totp"] as Boolean, - phone = map["phone"] as Boolean, - email = map["email"] as Boolean, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Notification.kt b/library/src/main/java/io/appwrite/models/Notification.kt deleted file mode 100644 index f5b5f38..0000000 --- a/library/src/main/java/io/appwrite/models/Notification.kt +++ /dev/null @@ -1,12 +0,0 @@ -package io.appwrite.models - -data class Notification( - val title: String = "", - val body: String = "", - val clickAction: String = "", - val color: String = "", - val icon: String = "", - val imageURL: String = "", - val sound: String = "", - val data: Map = mapOf(), -) \ 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 da71926..7674d72 100644 --- a/library/src/main/java/io/appwrite/models/Session.kt +++ b/library/src/main/java/io/appwrite/models/Session.kt @@ -157,18 +157,6 @@ data class Session( @SerializedName("current") val current: Boolean, - /** - * Returns a list of active session factors. - */ - @SerializedName("factors") - val factors: List, - - /** - * Secret used to authenticate the user. Only included if the request was made with an API key - */ - @SerializedName("secret") - val secret: String, - ) { fun toMap(): Map = mapOf( "\$id" to id as Any, @@ -196,8 +184,6 @@ data class Session( "countryCode" to countryCode as Any, "countryName" to countryName as Any, "current" to current as Any, - "factors" to factors as Any, - "secret" to secret as Any, ) companion object { @@ -231,8 +217,6 @@ data class Session( countryCode = map["countryCode"] as String, countryName = map["countryName"] as String, current = map["current"] as Boolean, - factors = map["factors"] as List, - secret = map["secret"] as String, ) } } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Subscriber.kt b/library/src/main/java/io/appwrite/models/Subscriber.kt deleted file mode 100644 index 1920691..0000000 --- a/library/src/main/java/io/appwrite/models/Subscriber.kt +++ /dev/null @@ -1,94 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * Subscriber - */ -data class Subscriber( - /** - * Subscriber ID. - */ - @SerializedName("\$id") - val id: String, - - /** - * Subscriber creation time in ISO 8601 format. - */ - @SerializedName("\$createdAt") - val createdAt: String, - - /** - * Subscriber update date in ISO 8601 format. - */ - @SerializedName("\$updatedAt") - val updatedAt: String, - - /** - * Target ID. - */ - @SerializedName("targetId") - val targetId: String, - - /** - * Target. - */ - @SerializedName("target") - val target: Target, - - /** - * Topic ID. - */ - @SerializedName("userId") - val userId: String, - - /** - * User Name. - */ - @SerializedName("userName") - val userName: String, - - /** - * Topic ID. - */ - @SerializedName("topicId") - val topicId: String, - - /** - * The target provider type. Can be one of the following: `email`, `sms` or `push`. - */ - @SerializedName("providerType") - val providerType: String, - -) { - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "\$createdAt" to createdAt as Any, - "\$updatedAt" to updatedAt as Any, - "targetId" to targetId as Any, - "target" to target.toMap() as Any, - "userId" to userId as Any, - "userName" to userName as Any, - "topicId" to topicId as Any, - "providerType" to providerType as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = Subscriber( - id = map["\$id"] as String, - createdAt = map["\$createdAt"] as String, - updatedAt = map["\$updatedAt"] as String, - targetId = map["targetId"] as String, - target = Target.from(map = map["target"] as Map), - userId = map["userId"] as String, - userName = map["userName"] as String, - topicId = map["topicId"] as String, - providerType = map["providerType"] as String, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Target.kt b/library/src/main/java/io/appwrite/models/Target.kt deleted file mode 100644 index bd4d207..0000000 --- a/library/src/main/java/io/appwrite/models/Target.kt +++ /dev/null @@ -1,86 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * Target - */ -data class Target( - /** - * Target ID. - */ - @SerializedName("\$id") - val id: String, - - /** - * Target creation time in ISO 8601 format. - */ - @SerializedName("\$createdAt") - val createdAt: String, - - /** - * Target update date in ISO 8601 format. - */ - @SerializedName("\$updatedAt") - val updatedAt: String, - - /** - * Target Name. - */ - @SerializedName("name") - val name: String, - - /** - * User ID. - */ - @SerializedName("userId") - val userId: String, - - /** - * Provider ID. - */ - @SerializedName("providerId") - var providerId: String?, - - /** - * The target provider type. Can be one of the following: `email`, `sms` or `push`. - */ - @SerializedName("providerType") - val providerType: String, - - /** - * The target identifier. - */ - @SerializedName("identifier") - val identifier: String, - -) { - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "\$createdAt" to createdAt as Any, - "\$updatedAt" to updatedAt as Any, - "name" to name as Any, - "userId" to userId as Any, - "providerId" to providerId as Any, - "providerType" to providerType as Any, - "identifier" to identifier as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = Target( - id = map["\$id"] as String, - createdAt = map["\$createdAt"] as String, - updatedAt = map["\$updatedAt"] as String, - name = map["name"] as String, - userId = map["userId"] as String, - providerId = map["providerId"] as? String?, - providerType = map["providerType"] as String, - identifier = map["identifier"] as String, - ) - } -} \ 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 e36d060..8c0f0e0 100644 --- a/library/src/main/java/io/appwrite/models/Token.kt +++ b/library/src/main/java/io/appwrite/models/Token.kt @@ -37,12 +37,6 @@ data class Token( @SerializedName("expire") val expire: String, - /** - * Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. - */ - @SerializedName("phrase") - val phrase: String, - ) { fun toMap(): Map = mapOf( "\$id" to id as Any, @@ -50,7 +44,6 @@ data class Token( "userId" to userId as Any, "secret" to secret as Any, "expire" to expire as Any, - "phrase" to phrase as Any, ) companion object { @@ -64,7 +57,6 @@ data class Token( userId = map["userId"] as String, secret = map["secret"] as String, expire = map["expire"] as String, - phrase = map["phrase"] as String, ) } } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/User.kt b/library/src/main/java/io/appwrite/models/User.kt index 4c776b9..9bf7eb4 100644 --- a/library/src/main/java/io/appwrite/models/User.kt +++ b/library/src/main/java/io/appwrite/models/User.kt @@ -97,30 +97,12 @@ data class User( @SerializedName("phoneVerification") val phoneVerification: Boolean, - /** - * Multi factor authentication status. - */ - @SerializedName("mfa") - val mfa: Boolean, - - /** - * TOTP status. - */ - @SerializedName("totp") - val totp: Boolean, - /** * User preferences as a key-value object */ @SerializedName("prefs") val prefs: Preferences, - /** - * A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. - */ - @SerializedName("targets") - val targets: List, - /** * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. */ @@ -144,10 +126,7 @@ data class User( "phone" to phone as Any, "emailVerification" to emailVerification as Any, "phoneVerification" to phoneVerification as Any, - "mfa" to mfa as Any, - "totp" to totp as Any, "prefs" to prefs.toMap() as Any, - "targets" to targets.map { it.toMap() } as Any, "accessedAt" to accessedAt as Any, ) @@ -168,10 +147,7 @@ data class User( phone: String, emailVerification: Boolean, phoneVerification: Boolean, - mfa: Boolean, - totp: Boolean, prefs: Preferences>, - targets: List, accessedAt: String, ) = User>( id, @@ -189,10 +165,7 @@ data class User( phone, emailVerification, phoneVerification, - mfa, - totp, prefs, - targets, accessedAt, ) @@ -216,10 +189,7 @@ data class User( phone = map["phone"] as String, emailVerification = map["emailVerification"] as Boolean, phoneVerification = map["phoneVerification"] as Boolean, - mfa = map["mfa"] as Boolean, - totp = map["totp"] as Boolean, prefs = Preferences.from(map = map["prefs"] as Map, nestedType), - targets = (map["targets"] as List>).map { Target.from(map = it) }, accessedAt = map["accessedAt"] as String, ) } diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 1e12e94..3c9cca1 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -3,7 +3,6 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client import io.appwrite.models.* -import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import io.appwrite.WebAuthComponent @@ -16,7 +15,9 @@ import java.io.File /** * The Account service allows you to authenticate and manage a user account. **/ -class Account(client: Client) : Service(client) { +class Account : Service { + + public constructor (client: Client) : super(client) { } /** * Get account @@ -36,7 +37,6 @@ class Account(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( @@ -67,9 +67,9 @@ class Account(client: Client) : Service(client) { * * Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). * - * @param userId User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 a custom ID or generate a random ID with `ID.unique()`. 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 New user password. Must be between 8 and 256 chars. + * @param password New user password. Must be at least 8 chars. * @param name User name. Max length: 128 chars. * @return [io.appwrite.models.User] */ @@ -93,7 +93,6 @@ class Account(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( @@ -111,9 +110,9 @@ class Account(client: Client) : Service(client) { * * Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). * - * @param userId User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 a custom ID or generate a random ID with `ID.unique()`. 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 New user password. Must be between 8 and 256 chars. + * @param password New user password. Must be at least 8 chars. * @param name User name. Max length: 128 chars. * @return [io.appwrite.models.User] */ @@ -156,7 +155,6 @@ class Account(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( @@ -198,7 +196,7 @@ class Account(client: Client) : Service(client) { */ @JvmOverloads suspend fun listIdentities( - queries: List? = null, + queries: String? = null, ): io.appwrite.models.IdentityList { val apiPath = "/account/identities" @@ -209,7 +207,6 @@ class Account(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.IdentityList = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.IdentityList.from(map = it as Map) } return client.call( @@ -224,7 +221,7 @@ class Account(client: Client) : Service(client) { /** - * Delete identity + * Delete Identity * * Delete an identity by its unique ID. * @@ -269,7 +266,6 @@ class Account(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Jwt = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Jwt.from(map = it as Map) } return client.call( @@ -304,7 +300,6 @@ class Account(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LogList = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.LogList.from(map = it as Map) } return client.call( @@ -318,299 +313,6 @@ class Account(client: Client) : Service(client) { } - /** - * Update MFA - * - * - * - * @param mfa Enable or disable MFA. - * @return [io.appwrite.models.User] - */ - suspend fun updateMFA( - mfa: Boolean, - nestedType: Class, - ): io.appwrite.models.User { - val apiPath = "/account/mfa" - - val apiParams = mutableMapOf( - "mfa" to mfa, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.User = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.User.from(map = it as Map, nestedType) - } - return client.call( - "PATCH", - apiPath, - apiHeaders, - apiParams, - responseType = classOf(), - converter, - ) - } - - /** - * Update MFA - * - * - * - * @param mfa Enable or disable MFA. - * @return [io.appwrite.models.User] - */ - @Throws(AppwriteException::class) - suspend fun updateMFA( - mfa: Boolean, - ): io.appwrite.models.User> = updateMFA( - mfa, - nestedType = classOf(), - ) - - /** - * Create MFA Challenge - * - * - * - * @param provider provider. - * @return [io.appwrite.models.MfaChallenge] - */ - suspend fun createChallenge( - provider: AuthenticatorProvider, - ): io.appwrite.models.MfaChallenge { - val apiPath = "/account/mfa/challenge" - - val apiParams = mutableMapOf( - "provider" to provider, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.MfaChallenge = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.MfaChallenge.from(map = it as Map) - } - return client.call( - "POST", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.MfaChallenge::class.java, - converter, - ) - } - - - /** - * Create MFA Challenge (confirmation) - * - * - * - * @param challengeId Valid verification token. - * @param otp Valid verification token. - * @return [Any] - */ - suspend fun updateChallenge( - challengeId: String, - otp: String, - ): Any { - val apiPath = "/account/mfa/challenge" - - val apiParams = mutableMapOf( - "challengeId" to challengeId, - "otp" to otp, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - return client.call( - "PUT", - apiPath, - apiHeaders, - apiParams, - responseType = Any::class.java, - ) - } - - - /** - * List Factors - * - * Get the currently logged in user. - * - * @return [io.appwrite.models.MfaProviders] - */ - suspend fun listFactors( - ): io.appwrite.models.MfaProviders { - val apiPath = "/account/mfa/factors" - - val apiParams = mutableMapOf( - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.MfaProviders = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.MfaProviders.from(map = it as Map) - } - return client.call( - "GET", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.MfaProviders::class.java, - converter, - ) - } - - - /** - * Add Authenticator - * - * - * - * @param factor Factor. - * @return [io.appwrite.models.MfaProvider] - */ - suspend fun addAuthenticator( - factor: AuthenticatorFactor, - ): io.appwrite.models.MfaProvider { - val apiPath = "/account/mfa/{factor}" - .replace("{factor}", factor.value) - - val apiParams = mutableMapOf( - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.MfaProvider = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.MfaProvider.from(map = it as Map) - } - return client.call( - "POST", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.MfaProvider::class.java, - converter, - ) - } - - - /** - * Verify Authenticator - * - * - * - * @param factor Factor. - * @param otp Valid verification token. - * @return [io.appwrite.models.User] - */ - suspend fun verifyAuthenticator( - factor: AuthenticatorFactor, - otp: String, - nestedType: Class, - ): io.appwrite.models.User { - val apiPath = "/account/mfa/{factor}" - .replace("{factor}", factor.value) - - val apiParams = mutableMapOf( - "otp" to otp, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.User = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.User.from(map = it as Map, nestedType) - } - return client.call( - "PUT", - apiPath, - apiHeaders, - apiParams, - responseType = classOf(), - converter, - ) - } - - /** - * Verify Authenticator - * - * - * - * @param factor Factor. - * @param otp Valid verification token. - * @return [io.appwrite.models.User] - */ - @Throws(AppwriteException::class) - suspend fun verifyAuthenticator( - factor: AuthenticatorFactor, - otp: String, - ): io.appwrite.models.User> = verifyAuthenticator( - factor, - otp, - nestedType = classOf(), - ) - - /** - * Delete Authenticator - * - * - * - * @param provider Provider. - * @param otp Valid verification token. - * @return [io.appwrite.models.User] - */ - suspend fun deleteAuthenticator( - provider: AuthenticatorProvider, - otp: String, - nestedType: Class, - ): io.appwrite.models.User { - val apiPath = "/account/mfa/{provider}" - .replace("{provider}", provider.value) - - val apiParams = mutableMapOf( - "otp" to otp, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.User = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.User.from(map = it as Map, nestedType) - } - return client.call( - "DELETE", - apiPath, - apiHeaders, - apiParams, - responseType = classOf(), - converter, - ) - } - - /** - * Delete Authenticator - * - * - * - * @param provider Provider. - * @param otp Valid verification token. - * @return [io.appwrite.models.User] - */ - @Throws(AppwriteException::class) - suspend fun deleteAuthenticator( - provider: AuthenticatorProvider, - otp: String, - ): io.appwrite.models.User> = deleteAuthenticator( - provider, - otp, - nestedType = classOf(), - ) - /** * Update name * @@ -632,7 +334,6 @@ class Account(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( @@ -686,7 +387,6 @@ class Account(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( @@ -743,7 +443,6 @@ class Account(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( @@ -793,7 +492,6 @@ class Account(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Preferences.from(map = it as Map, nestedType) } return client.call( @@ -840,7 +538,6 @@ class Account(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( @@ -892,7 +589,6 @@ class Account(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } return client.call( @@ -913,13 +609,15 @@ class Account(client: Client) : Service(client) { * * @param userId User ID. * @param secret Valid reset token. - * @param password New user password. Must be between 8 and 256 chars. + * @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] */ suspend fun updateRecovery( userId: String, secret: String, password: String, + passwordAgain: String, ): io.appwrite.models.Token { val apiPath = "/account/recovery" @@ -927,12 +625,12 @@ class Account(client: Client) : Service(client) { "userId" to userId, "secret" to secret, "password" to password, + "passwordAgain" to passwordAgain, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } return client.call( @@ -963,7 +661,6 @@ class Account(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.SessionList = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.SessionList.from(map = it as Map) } return client.call( @@ -1020,7 +717,6 @@ class Account(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } return client.call( @@ -1035,7 +731,7 @@ class Account(client: Client) : Service(client) { /** - * Create email password session + * 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.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * @@ -1043,7 +739,7 @@ class Account(client: Client) : Service(client) { * @param password User password. Must be at least 8 chars. * @return [io.appwrite.models.Session] */ - suspend fun createEmailPasswordSession( + suspend fun createEmailSession( email: String, password: String, ): io.appwrite.models.Session { @@ -1057,7 +753,6 @@ class Account(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } return client.call( @@ -1072,11 +767,51 @@ class Account(client: Client) : Service(client) { /** - * Create session (deprecated) + * Create magic URL session + * + * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [PUT /account/sessions/magic-url](https://appwrite.io/docs/references/cloud/client-web/account#updateMagicURLSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * + * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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] + */ + @JvmOverloads + suspend fun createMagicURLSession( + userId: String, + email: String, + url: String? = null, + ): io.appwrite.models.Token { + val apiPath = "/account/sessions/magic-url" + + val apiParams = mutableMapOf( + "userId" to userId, + "email" to email, + "url" to url, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Token::class.java, + converter, + ) + } + + + /** + * Create magic URL session (confirmation) * - * Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. + * 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](https://appwrite.io/docs/references/cloud/client-web/account#createMagicURLSession) 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. Choose a custom ID or generate a random ID with `ID.unique()`. 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 User ID. * @param secret Valid verification token. * @return [io.appwrite.models.Session] */ @@ -1094,7 +829,6 @@ class Account(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } return client.call( @@ -1113,28 +847,25 @@ class Account(client: Client) : Service(client) { * * 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](https://appwrite.io/docs/authentication-security#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, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom. + * @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, oidc, 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's 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's 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 token Include token credentials in the final redirect, useful for server-side integrations, or when cookies are not available. * @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 suspend fun createOAuth2Session( activity: ComponentActivity, - provider: OAuthProvider, + provider: String, success: String? = null, failure: String? = null, - token: Boolean? = null, scopes: List? = null, ) { val apiPath = "/account/sessions/oauth2/{provider}" - .replace("{provider}", provider.value) + .replace("{provider}", provider) val apiParams = mutableMapOf( "success" to success, "failure" to failure, - "token" to token, "scopes" to scopes, "project" to client.config["project"], ) @@ -1153,7 +884,7 @@ class Account(client: Client) : Service(client) { } } - val apiUrl = Uri.parse("${client.endpoint}${apiPath}?${apiQuery.joinToString("&")}") + val apiUrl = Uri.parse("${client.endPoint}${apiPath}?${apiQuery.joinToString("&")}") val callbackUrlScheme = "appwrite-callback-${client.config["project"]}" WebAuthComponent.authenticate(activity, apiUrl, callbackUrlScheme) { @@ -1171,12 +902,12 @@ class Account(client: Client) : Service(client) { val cookie = Cookie.Builder() .name(key) .value(secret) - .domain(Uri.parse(client.endpoint).host!!) + .domain(Uri.parse(client.endPoint).host!!) .httpOnly() .build() client.http.cookieJar.saveFromResponse( - client.endpoint.toHttpUrl(), + client.endPoint.toHttpUrl(), listOf(cookie) ) } @@ -1184,19 +915,55 @@ class Account(client: Client) : Service(client) { /** - * Create session + * Create phone session * - * Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. + * 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](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * - * @param userId User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 secret Secret of a token generated by login methods. For example, the `createMagicURLToken` or `createPhoneToken` methods. + * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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] + */ + suspend fun createPhoneSession( + userId: String, + phone: String, + ): io.appwrite.models.Token { + val apiPath = "/account/sessions/phone" + + val apiParams = mutableMapOf( + "userId" to userId, + "phone" to phone, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Token::class.java, + converter, + ) + } + + + /** + * Create phone session (confirmation) + * + * Use this endpoint to complete creating a session with SMS. Use the **userId** from the [createPhoneSession](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneSession) 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] */ - suspend fun createSession( + suspend fun updatePhoneSession( userId: String, secret: String, ): io.appwrite.models.Session { - val apiPath = "/account/sessions/token" + val apiPath = "/account/sessions/phone" val apiParams = mutableMapOf( "userId" to userId, @@ -1206,11 +973,10 @@ class Account(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } return client.call( - "POST", + "PUT", apiPath, apiHeaders, apiParams, @@ -1240,7 +1006,6 @@ class Account(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } return client.call( @@ -1255,9 +1020,9 @@ class Account(client: Client) : Service(client) { /** - * Update (or renew) a session + * Update OAuth session (refresh tokens) * - * Extend session's expiry to increase it's lifespan. Extending a session is useful when session length is short such as 5 minutes. + * 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] @@ -1274,7 +1039,6 @@ class Account(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } return client.call( @@ -1335,7 +1099,6 @@ class Account(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( @@ -1361,235 +1124,6 @@ class Account(client: Client) : Service(client) { nestedType = classOf(), ) - /** - * Create a push target - * - * - * - * @param targetId Target ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 identifier The target identifier (token, email, phone etc.) - * @param providerId Provider ID. Message will be sent to this target from the specified provider ID. If no provider ID is set the first setup provider will be used. - * @return [io.appwrite.models.Target] - */ - @JvmOverloads - suspend fun createPushTarget( - targetId: String, - identifier: String, - providerId: String? = null, - ): io.appwrite.models.Target { - val apiPath = "/account/targets/push" - - val apiParams = mutableMapOf( - "targetId" to targetId, - "identifier" to identifier, - "providerId" to providerId, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Target = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.Target.from(map = it as Map) - } - return client.call( - "POST", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.Target::class.java, - converter, - ) - } - - - /** - * Update a push target - * - * - * - * @param targetId Target ID. - * @param identifier The target identifier (token, email, phone etc.) - * @return [io.appwrite.models.Target] - */ - suspend fun updatePushTarget( - targetId: String, - identifier: String, - ): io.appwrite.models.Target { - val apiPath = "/account/targets/{targetId}/push" - .replace("{targetId}", targetId) - - val apiParams = mutableMapOf( - "identifier" to identifier, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Target = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.Target.from(map = it as Map) - } - return client.call( - "PUT", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.Target::class.java, - converter, - ) - } - - - /** - * Delete a push target - * - * - * - * @param targetId Target ID. - * @return [Any] - */ - suspend fun deletePushTarget( - targetId: String, - ): Any { - val apiPath = "/account/targets/{targetId}/push" - .replace("{targetId}", targetId) - - val apiParams = mutableMapOf( - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - return client.call( - "DELETE", - apiPath, - apiHeaders, - apiParams, - responseType = Any::class.java, - ) - } - - - /** - * Create email token (OTP) - * - * Sends the user an email with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's email is valid for 15 minutes.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). - * - * @param userId User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 phrase Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. - * @return [io.appwrite.models.Token] - */ - @JvmOverloads - suspend fun createEmailToken( - userId: String, - email: String, - phrase: Boolean? = null, - ): io.appwrite.models.Token { - val apiPath = "/account/tokens/email" - - val apiParams = mutableMapOf( - "userId" to userId, - "email" to email, - "phrase" to phrase, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Token = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.Token.from(map = it as Map) - } - return client.call( - "POST", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.Token::class.java, - converter, - ) - } - - - /** - * Create magic URL token - * - * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). - * - * @param userId User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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. - * @param phrase Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. - * @return [io.appwrite.models.Token] - */ - @JvmOverloads - suspend fun createMagicURLToken( - userId: String, - email: String, - url: String? = null, - phrase: Boolean? = null, - ): io.appwrite.models.Token { - val apiPath = "/account/tokens/magic-url" - - val apiParams = mutableMapOf( - "userId" to userId, - "email" to email, - "url" to url, - "phrase" to phrase, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Token = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.Token.from(map = it as Map) - } - return client.call( - "POST", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.Token::class.java, - converter, - ) - } - - - /** - * Create phone token - * - * Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). - * - * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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] - */ - suspend fun createPhoneToken( - userId: String, - phone: String, - ): io.appwrite.models.Token { - val apiPath = "/account/tokens/phone" - - val apiParams = mutableMapOf( - "userId" to userId, - "phone" to phone, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Token = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.Token.from(map = it as Map) - } - return client.call( - "POST", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.Token::class.java, - converter, - ) - } - - /** * Create email verification * @@ -1610,7 +1144,6 @@ class Account(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } return client.call( @@ -1647,7 +1180,6 @@ class Account(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } return client.call( @@ -1678,7 +1210,6 @@ class Account(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } return client.call( @@ -1715,7 +1246,6 @@ class Account(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } return client.call( diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt index bdf97ae..27b7cde 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -3,7 +3,6 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client import io.appwrite.models.* -import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import okhttp3.Cookie @@ -14,7 +13,9 @@ import java.io.File /** * The Avatars service aims to help you complete everyday tasks related to your app image, icons, and avatars. **/ -class Avatars(client: Client) : Service(client) { +class Avatars : Service { + + public constructor (client: Client) : super(client) { } /** * Get browser icon @@ -29,13 +30,13 @@ class Avatars(client: Client) : Service(client) { */ @JvmOverloads suspend fun getBrowser( - code: Browser, + code: String, width: Long? = null, height: Long? = null, quality: Long? = null, ): ByteArray { val apiPath = "/avatars/browsers/{code}" - .replace("{code}", code.value) + .replace("{code}", code) val apiParams = mutableMapOf( "width" to width, @@ -65,13 +66,13 @@ class Avatars(client: Client) : Service(client) { */ @JvmOverloads suspend fun getCreditCard( - code: CreditCard, + code: String, width: Long? = null, height: Long? = null, quality: Long? = null, ): ByteArray { val apiPath = "/avatars/credit-cards/{code}" - .replace("{code}", code.value) + .replace("{code}", code) val apiParams = mutableMapOf( "width" to width, @@ -127,13 +128,13 @@ class Avatars(client: Client) : Service(client) { */ @JvmOverloads suspend fun getFlag( - code: Flag, + code: String, width: Long? = null, height: Long? = null, quality: Long? = null, ): ByteArray { val apiPath = "/avatars/flags/{code}" - .replace("{code}", code.value) + .replace("{code}", code) val apiParams = mutableMapOf( "width" to width, diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index b95d6cc..4329b35 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -3,7 +3,6 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client import io.appwrite.models.* -import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import okhttp3.Cookie @@ -12,7 +11,9 @@ import java.io.File /** * The Databases service allows you to create structured collections of documents, query and filter lists of documents **/ -class Databases(client: Client) : Service(client) { +class Databases : Service { + + public constructor (client: Client) : super(client) { } /** * List documents @@ -42,7 +43,6 @@ class Databases(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.DocumentList = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.DocumentList.from(map = it as Map, nestedType) } return client.call( @@ -112,7 +112,6 @@ class Databases(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Document.from(map = it as Map, nestedType) } return client.call( @@ -162,7 +161,7 @@ class Databases(client: Client) : Service(client) { * @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. - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @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 method allowed is select. * @return [io.appwrite.models.Document] */ @JvmOverloads @@ -185,7 +184,6 @@ class Databases(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Document.from(map = it as Map, nestedType) } return client.call( @@ -206,7 +204,7 @@ class Databases(client: Client) : Service(client) { * @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. - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @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 method allowed is select. * @return [io.appwrite.models.Document] */ @JvmOverloads @@ -258,7 +256,6 @@ class Databases(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Document.from(map = it as Map, nestedType) } return client.call( diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index 286ec5d..257a130 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -3,7 +3,6 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client import io.appwrite.models.* -import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import okhttp3.Cookie @@ -12,7 +11,9 @@ import java.io.File /** * The Functions Service allows you view, create and manage your Cloud Functions. **/ -class Functions(client: Client) : Service(client) { +class Functions : Service { + + public constructor (client: Client) : super(client) { } /** * List executions @@ -41,7 +42,6 @@ class Functions(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.ExecutionList = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.ExecutionList.from(map = it as Map) } return client.call( @@ -74,7 +74,7 @@ class Functions(client: Client) : Service(client) { body: String? = null, async: Boolean? = null, path: String? = null, - method: ExecutionMethod? = null, + method: String? = null, headers: Any? = null, ): io.appwrite.models.Execution { val apiPath = "/functions/{functionId}/executions" @@ -91,7 +91,6 @@ class Functions(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Execution = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Execution.from(map = it as Map) } return client.call( @@ -128,7 +127,6 @@ class Functions(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Execution = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Execution.from(map = it as Map) } return client.call( diff --git a/library/src/main/java/io/appwrite/services/Graphql.kt b/library/src/main/java/io/appwrite/services/Graphql.kt index b1a8254..3a925d5 100644 --- a/library/src/main/java/io/appwrite/services/Graphql.kt +++ b/library/src/main/java/io/appwrite/services/Graphql.kt @@ -3,7 +3,6 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client import io.appwrite.models.* -import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import okhttp3.Cookie @@ -12,7 +11,9 @@ import java.io.File /** * The GraphQL API allows you to query and mutate your Appwrite server using GraphQL. **/ -class Graphql(client: Client) : Service(client) { +class Graphql : Service { + + public constructor (client: Client) : super(client) { } /** * GraphQL endpoint diff --git a/library/src/main/java/io/appwrite/services/Locale.kt b/library/src/main/java/io/appwrite/services/Locale.kt index ee26888..510f451 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -3,7 +3,6 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client import io.appwrite.models.* -import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import okhttp3.Cookie @@ -12,7 +11,9 @@ import java.io.File /** * The Locale service allows you to customize your app based on your users' location. **/ -class Locale(client: Client) : Service(client) { +class Locale : Service { + + public constructor (client: Client) : super(client) { } /** * Get user locale @@ -31,7 +32,6 @@ class Locale(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Locale = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Locale.from(map = it as Map) } return client.call( @@ -62,7 +62,6 @@ class Locale(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LocaleCodeList = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.LocaleCodeList.from(map = it as Map) } return client.call( @@ -93,7 +92,6 @@ class Locale(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.ContinentList = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.ContinentList.from(map = it as Map) } return client.call( @@ -124,7 +122,6 @@ class Locale(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CountryList = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.CountryList.from(map = it as Map) } return client.call( @@ -155,7 +152,6 @@ class Locale(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CountryList = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.CountryList.from(map = it as Map) } return client.call( @@ -186,7 +182,6 @@ class Locale(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.PhoneList = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.PhoneList.from(map = it as Map) } return client.call( @@ -217,7 +212,6 @@ class Locale(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CurrencyList = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.CurrencyList.from(map = it as Map) } return client.call( @@ -248,7 +242,6 @@ class Locale(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LanguageList = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.LanguageList.from(map = it as Map) } return client.call( diff --git a/library/src/main/java/io/appwrite/services/Messaging.kt b/library/src/main/java/io/appwrite/services/Messaging.kt deleted file mode 100644 index 2035dbf..0000000 --- a/library/src/main/java/io/appwrite/services/Messaging.kt +++ /dev/null @@ -1,89 +0,0 @@ -package io.appwrite.services - -import android.net.Uri -import io.appwrite.Client -import io.appwrite.models.* -import io.appwrite.enums.* -import io.appwrite.exceptions.AppwriteException -import io.appwrite.extensions.classOf -import okhttp3.Cookie -import java.io.File - -/** - * The Messaging service allows you to send messages to any provider type (SMTP, push notification, SMS, etc.). -**/ -class Messaging(client: Client) : Service(client) { - - /** - * Create a subscriber. - * - * - * - * @param topicId Topic ID. The topic ID to subscribe to. - * @param subscriberId Subscriber ID. Choose a custom Subscriber ID or a new Subscriber ID. - * @param targetId Target ID. The target ID to link to the specified Topic ID. - * @return [io.appwrite.models.Subscriber] - */ - suspend fun createSubscriber( - topicId: String, - subscriberId: String, - targetId: String, - ): io.appwrite.models.Subscriber { - val apiPath = "/messaging/topics/{topicId}/subscribers" - .replace("{topicId}", topicId) - - val apiParams = mutableMapOf( - "subscriberId" to subscriberId, - "targetId" to targetId, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Subscriber = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.Subscriber.from(map = it as Map) - } - return client.call( - "POST", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.Subscriber::class.java, - converter, - ) - } - - - /** - * Delete a subscriber. - * - * - * - * @param topicId Topic ID. The topic ID subscribed to. - * @param subscriberId Subscriber ID. - * @return [Any] - */ - suspend fun deleteSubscriber( - topicId: String, - subscriberId: String, - ): Any { - val apiPath = "/messaging/topics/{topicId}/subscribers/{subscriberId}" - .replace("{topicId}", topicId) - .replace("{subscriberId}", subscriberId) - - val apiParams = mutableMapOf( - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - return client.call( - "DELETE", - apiPath, - apiHeaders, - apiParams, - responseType = Any::class.java, - ) - } - - -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Realtime.kt b/library/src/main/java/io/appwrite/services/Realtime.kt index e3709e5..316054a 100644 --- a/library/src/main/java/io/appwrite/services/Realtime.kt +++ b/library/src/main/java/io/appwrite/services/Realtime.kt @@ -55,7 +55,7 @@ class Realtime(client: Client) : Service(client), CoroutineScope { } val request = Request.Builder() - .url("${client.endpointRealtime}/realtime?$queryParamBuilder") + .url("${client.endPointRealtime}/realtime?$queryParamBuilder") .build() if (socket != null) { diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index 3830e20..2b49f56 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -3,7 +3,6 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client import io.appwrite.models.* -import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import okhttp3.Cookie @@ -14,7 +13,9 @@ import java.io.File /** * The Storage service allows you to manage your project files. **/ -class Storage(client: Client) : Service(client) { +class Storage : Service { + + public constructor (client: Client) : super(client) { } /** * List files @@ -43,7 +44,6 @@ class Storage(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.FileList = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.FileList.from(map = it as Map) } return client.call( @@ -88,7 +88,6 @@ class Storage(client: Client) : Service(client) { "content-type" to "multipart/form-data", ) val converter: (Any) -> io.appwrite.models.File = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.File.from(map = it as Map) } val idParamName: String? = "fileId" @@ -129,7 +128,6 @@ class Storage(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.File = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.File.from(map = it as Map) } return client.call( @@ -173,7 +171,6 @@ class Storage(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.File = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.File.from(map = it as Map) } return client.call( @@ -274,7 +271,7 @@ class Storage(client: Client) : Service(client) { fileId: String, width: Long? = null, height: Long? = null, - gravity: ImageGravity? = null, + gravity: String? = null, quality: Long? = null, borderWidth: Long? = null, borderColor: String? = null, @@ -282,7 +279,7 @@ class Storage(client: Client) : Service(client) { opacity: Double? = null, rotation: Long? = null, background: String? = null, - output: ImageFormat? = null, + output: String? = null, ): ByteArray { val apiPath = "/storage/buckets/{bucketId}/files/{fileId}/preview" .replace("{bucketId}", bucketId) diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 8c89184..7f303ab 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -3,7 +3,6 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client import io.appwrite.models.* -import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import okhttp3.Cookie @@ -12,14 +11,16 @@ 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(client: Client) : Service(client) { +class Teams : Service { + + public constructor (client: Client) : super(client) { } /** * 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. * - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total, billingPlan + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). 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] */ @@ -39,7 +40,6 @@ class Teams(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.TeamList = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.TeamList.from(map = it as Map, nestedType) } return client.call( @@ -57,7 +57,7 @@ class Teams(client: Client) : Service(client) { * * 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/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total, billingPlan + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). 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] */ @@ -100,7 +100,6 @@ class Teams(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Team = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Team.from(map = it as Map, nestedType) } return client.call( @@ -157,7 +156,6 @@ class Teams(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Team = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Team.from(map = it as Map, nestedType) } return client.call( @@ -210,7 +208,6 @@ class Teams(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Team = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Team.from(map = it as Map, nestedType) } return client.call( @@ -298,7 +295,6 @@ class Teams(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MembershipList = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.MembershipList.from(map = it as Map) } return client.call( @@ -351,7 +347,6 @@ class Teams(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Membership.from(map = it as Map) } return client.call( @@ -388,7 +383,6 @@ class Teams(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Membership.from(map = it as Map) } return client.call( @@ -428,7 +422,6 @@ class Teams(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Membership.from(map = it as Map) } return client.call( @@ -503,7 +496,6 @@ class Teams(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Membership.from(map = it as Map) } return client.call( @@ -538,7 +530,6 @@ class Teams(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Preferences.from(map = it as Map, nestedType) } return client.call( @@ -591,7 +582,6 @@ class Teams(client: Client) : Service(client) { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { - @Suppress("UNCHECKED_CAST") io.appwrite.models.Preferences.from(map = it as Map, nestedType) } return client.call( diff --git a/scripts/publish-module.gradle b/scripts/publish-module.gradle index 96b31b2..e32ff84 100644 --- a/scripts/publish-module.gradle +++ b/scripts/publish-module.gradle @@ -63,8 +63,7 @@ publishing { configurations .getByName("releaseCompileClasspath") .resolvedConfiguration - .firstLevelModuleDependencies - .forEach { + .firstLevelModuleDependencies.forEach { def dependency = dependencies.appendNode("dependency") dependency.appendNode("groupId", it.moduleGroup) dependency.appendNode("artifactId", it.moduleName) diff --git a/settings.gradle b/settings.gradle index 423c64e..73c359b 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,4 @@ rootProject.name = "Appwrite Android SDK" include ':example' -include ':library' \ No newline at end of file +include ':library' +include ':example-java' \ No newline at end of file From 9b5e2855c10b9763eba27e2153461cc5783d9a43 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 16 Feb 2024 23:02:41 +1300 Subject: [PATCH 062/118] Release candidate for 1.5.x --- README.md | 6 +- build.gradle | 11 +- .../java/account/add-authenticator.md | 22 + .../java/account/create-anonymous-session.md | 2 +- .../account/create-email-password-session.md | 22 + ...u-r-l-session.md => create-email-token.md} | 4 +- docs/examples/java/account/create-j-w-t.md | 2 +- ...session.md => create-magic-u-r-l-token.md} | 6 +- .../java/account/create-o-auth2session.md | 5 +- ...phone-session.md => create-phone-token.md} | 6 +- .../java/account/create-phone-verification.md | 2 +- .../java/account/create-push-target.md | 22 + docs/examples/java/account/create-recovery.md | 4 +- ...ate-phone-session.md => create-session.md} | 6 +- .../java/account/create-verification.md | 4 +- docs/examples/java/account/create.md | 2 +- .../java/account/create2f-a-challenge.md | 22 + .../java/account/delete-authenticator.md | 23 + docs/examples/java/account/delete-identity.md | 4 +- .../java/account/delete-push-target.md | 21 + docs/examples/java/account/delete-session.md | 4 +- docs/examples/java/account/delete-sessions.md | 2 +- docs/examples/java/account/get-prefs.md | 2 +- docs/examples/java/account/get-session.md | 4 +- docs/examples/java/account/get.md | 2 +- docs/examples/java/account/list-factors.md | 18 + docs/examples/java/account/list-identities.md | 2 +- docs/examples/java/account/list-logs.md | 2 +- docs/examples/java/account/list-sessions.md | 2 +- .../examples/java/account/update-challenge.md | 22 + docs/examples/java/account/update-email.md | 4 +- docs/examples/java/account/update-m-f-a.md | 21 + .../account/update-magic-u-r-l-session.md | 4 +- docs/examples/java/account/update-name.md | 4 +- docs/examples/java/account/update-password.md | 2 +- .../java/account/update-phone-verification.md | 4 +- docs/examples/java/account/update-phone.md | 4 +- docs/examples/java/account/update-prefs.md | 4 +- .../java/account/update-push-target.md | 22 + docs/examples/java/account/update-recovery.md | 5 +- docs/examples/java/account/update-session.md | 4 +- docs/examples/java/account/update-status.md | 2 +- .../java/account/update-verification.md | 4 +- .../java/account/verify-authenticator.md | 23 + docs/examples/java/avatars/get-browser.md | 5 +- docs/examples/java/avatars/get-credit-card.md | 5 +- docs/examples/java/avatars/get-favicon.md | 4 +- docs/examples/java/avatars/get-flag.md | 5 +- docs/examples/java/avatars/get-image.md | 2 +- docs/examples/java/avatars/get-initials.md | 2 +- docs/examples/java/avatars/get-q-r.md | 2 +- .../java/databases/create-document.md | 2 +- .../java/databases/delete-document.md | 4 +- docs/examples/java/databases/get-document.md | 2 +- .../examples/java/databases/list-documents.md | 2 +- .../java/databases/update-document.md | 2 +- .../java/functions/create-execution.md | 2 +- docs/examples/java/functions/get-execution.md | 4 +- .../java/functions/list-executions.md | 2 +- docs/examples/java/graphql/mutation.md | 4 +- docs/examples/java/graphql/query.md | 4 +- docs/examples/java/locale/get.md | 2 +- docs/examples/java/locale/list-codes.md | 2 +- docs/examples/java/locale/list-continents.md | 2 +- .../java/locale/list-countries-e-u.md | 2 +- .../java/locale/list-countries-phones.md | 2 +- docs/examples/java/locale/list-countries.md | 2 +- docs/examples/java/locale/list-currencies.md | 2 +- docs/examples/java/locale/list-languages.md | 2 +- .../java/messaging/create-subscriber.md | 23 + .../java/messaging/delete-subscriber.md | 22 + docs/examples/java/storage/create-file.md | 2 +- docs/examples/java/storage/delete-file.md | 4 +- .../java/storage/get-file-download.md | 4 +- .../examples/java/storage/get-file-preview.md | 2 +- docs/examples/java/storage/get-file-view.md | 4 +- docs/examples/java/storage/get-file.md | 4 +- docs/examples/java/storage/list-files.md | 2 +- docs/examples/java/storage/update-file.md | 2 +- docs/examples/java/teams/create-membership.md | 2 +- docs/examples/java/teams/create.md | 2 +- docs/examples/java/teams/delete-membership.md | 4 +- docs/examples/java/teams/delete.md | 4 +- docs/examples/java/teams/get-membership.md | 4 +- docs/examples/java/teams/get-prefs.md | 4 +- docs/examples/java/teams/get.md | 4 +- docs/examples/java/teams/list-memberships.md | 2 +- docs/examples/java/teams/list.md | 2 +- .../java/teams/update-membership-status.md | 4 +- docs/examples/java/teams/update-membership.md | 4 +- docs/examples/java/teams/update-name.md | 4 +- docs/examples/java/teams/update-prefs.md | 4 +- .../kotlin/account/add-authenticator.md | 14 + .../account/create-anonymous-session.md | 1 + .../account/create-email-password-session.md | 14 + ...u-r-l-session.md => create-email-token.md} | 5 +- docs/examples/kotlin/account/create-j-w-t.md | 1 + ...session.md => create-magic-u-r-l-token.md} | 7 +- .../kotlin/account/create-o-auth2session.md | 6 +- .../kotlin/account/create-phone-token.md | 14 + .../account/create-phone-verification.md | 1 + .../kotlin/account/create-push-target.md | 14 + .../kotlin/account/create-recovery.md | 5 +- .../examples/kotlin/account/create-session.md | 14 + .../kotlin/account/create-verification.md | 5 +- docs/examples/kotlin/account/create.md | 3 +- .../kotlin/account/create2f-a-challenge.md | 14 + .../kotlin/account/delete-authenticator.md | 15 + .../kotlin/account/delete-identity.md | 5 +- .../kotlin/account/delete-push-target.md | 13 + .../examples/kotlin/account/delete-session.md | 5 +- .../kotlin/account/delete-sessions.md | 1 + docs/examples/kotlin/account/get-prefs.md | 1 + docs/examples/kotlin/account/get-session.md | 5 +- docs/examples/kotlin/account/get.md | 1 + ...pdate-phone-session.md => list-factors.md} | 6 +- .../kotlin/account/list-identities.md | 3 +- docs/examples/kotlin/account/list-logs.md | 3 +- docs/examples/kotlin/account/list-sessions.md | 1 + .../kotlin/account/update-challenge.md | 14 + docs/examples/kotlin/account/update-email.md | 5 +- ...reate-phone-session.md => update-m-f-a.md} | 8 +- .../account/update-magic-u-r-l-session.md | 5 +- docs/examples/kotlin/account/update-name.md | 5 +- .../kotlin/account/update-password.md | 3 +- .../account/update-phone-verification.md | 5 +- docs/examples/kotlin/account/update-phone.md | 5 +- docs/examples/kotlin/account/update-prefs.md | 5 +- .../kotlin/account/update-push-target.md | 14 + .../kotlin/account/update-recovery.md | 6 +- .../examples/kotlin/account/update-session.md | 5 +- docs/examples/kotlin/account/update-status.md | 1 + .../kotlin/account/update-verification.md | 5 +- .../kotlin/account/verify-authenticator.md | 15 + docs/examples/kotlin/avatars/get-browser.md | 8 +- .../kotlin/avatars/get-credit-card.md | 8 +- docs/examples/kotlin/avatars/get-favicon.md | 7 +- docs/examples/kotlin/avatars/get-flag.md | 8 +- docs/examples/kotlin/avatars/get-image.md | 5 +- docs/examples/kotlin/avatars/get-initials.md | 5 +- docs/examples/kotlin/avatars/get-q-r.md | 5 +- .../kotlin/databases/create-document.md | 3 +- .../kotlin/databases/delete-document.md | 5 +- .../examples/kotlin/databases/get-document.md | 3 +- .../kotlin/databases/list-documents.md | 3 +- .../kotlin/databases/update-document.md | 3 +- .../kotlin/functions/create-execution.md | 3 +- .../kotlin/functions/get-execution.md | 5 +- .../kotlin/functions/list-executions.md | 3 +- docs/examples/kotlin/graphql/mutation.md | 5 +- docs/examples/kotlin/graphql/query.md | 5 +- docs/examples/kotlin/locale/get.md | 1 + docs/examples/kotlin/locale/list-codes.md | 1 + .../examples/kotlin/locale/list-continents.md | 1 + .../kotlin/locale/list-countries-e-u.md | 1 + .../kotlin/locale/list-countries-phones.md | 1 + docs/examples/kotlin/locale/list-countries.md | 1 + .../examples/kotlin/locale/list-currencies.md | 1 + docs/examples/kotlin/locale/list-languages.md | 1 + .../kotlin/messaging/create-subscriber.md | 15 + .../kotlin/messaging/delete-subscriber.md | 14 + docs/examples/kotlin/storage/create-file.md | 3 +- docs/examples/kotlin/storage/delete-file.md | 5 +- .../kotlin/storage/get-file-download.md | 7 +- .../kotlin/storage/get-file-preview.md | 5 +- docs/examples/kotlin/storage/get-file-view.md | 7 +- docs/examples/kotlin/storage/get-file.md | 5 +- docs/examples/kotlin/storage/list-files.md | 3 +- docs/examples/kotlin/storage/update-file.md | 3 +- .../kotlin/teams/create-membership.md | 3 +- docs/examples/kotlin/teams/create.md | 3 +- .../kotlin/teams/delete-membership.md | 5 +- docs/examples/kotlin/teams/delete.md | 5 +- docs/examples/kotlin/teams/get-membership.md | 5 +- docs/examples/kotlin/teams/get-prefs.md | 5 +- docs/examples/kotlin/teams/get.md | 5 +- .../examples/kotlin/teams/list-memberships.md | 3 +- docs/examples/kotlin/teams/list.md | 3 +- .../kotlin/teams/update-membership-status.md | 5 +- .../kotlin/teams/update-membership.md | 5 +- docs/examples/kotlin/teams/update-name.md | 5 +- docs/examples/kotlin/teams/update-prefs.md | 5 +- example-java/.gitignore | 1 - example-java/build.gradle | 39 - example-java/src/main/AndroidManifest.xml | 21 - .../appwrite/example_java/MainActivity.java | 34 - .../res/drawable/ic_launcher_background.xml | 170 ----- .../res/drawable/ic_launcher_foreground.xml | 30 - .../src/main/res/layout/activity_main.xml | 18 - .../res/mipmap-anydpi-v26/ic_launcher.xml | 5 - .../mipmap-anydpi-v26/ic_launcher_round.xml | 5 - example-java/src/main/res/values/colors.xml | 10 - example-java/src/main/res/values/strings.xml | 3 - example-java/src/main/res/values/themes.xml | 16 - example/build.gradle | 49 +- example/src/main/AndroidManifest.xml | 13 +- .../android/services/MessagingService.kt | 37 + .../android/ui/accounts/AccountsFragment.kt | 43 +- .../android/ui/accounts/AccountsViewModel.kt | 62 +- .../java/io/appwrite/android/utils/Client.kt | 11 +- .../src/main/res/layout/fragment_account.xml | 1 + gradle/wrapper/gradle-wrapper.properties | 2 +- library/build.gradle | 39 +- library/src/main/AndroidManifest.xml | 7 +- library/src/main/java/io/appwrite/Client.kt | 90 +-- library/src/main/java/io/appwrite/OS.kt | 52 ++ library/src/main/java/io/appwrite/Query.kt | 79 +- .../io/appwrite/{services => }/Service.kt | 2 +- .../appwrite/cookies/ListenableCookieJar.kt | 119 +++ .../cookies/stores/InMemoryCookieStore.kt | 13 +- .../stores/SharedPreferencesCookieStore.kt | 10 +- .../main/java/io/appwrite/enums/Browser.kt | 20 + .../main/java/io/appwrite/enums/CreditCard.kt | 22 + .../java/io/appwrite/enums/ExecutionMethod.kt | 12 + .../src/main/java/io/appwrite/enums/Factor.kt | 9 + .../src/main/java/io/appwrite/enums/Flag.kt | 200 +++++ .../java/io/appwrite/enums/ImageFormat.kt | 11 + .../java/io/appwrite/enums/ImageGravity.kt | 15 + .../java/io/appwrite/enums/OAuthProvider.kt | 45 ++ .../src/main/java/io/appwrite/enums/Type.kt | 7 + .../io/appwrite/extensions/JsonExtensions.kt | 10 +- .../io/appwrite/extensions/TypeExtensions.kt | 1 + .../io/appwrite/json/PreciseNumberAdapter.kt | 64 -- .../java/io/appwrite/models/Membership.kt | 8 + .../java/io/appwrite/models/MfaChallenge.kt | 54 ++ .../java/io/appwrite/models/MfaFactors.kt | 46 ++ .../main/java/io/appwrite/models/MfaType.kt | 46 ++ .../main/java/io/appwrite/models/Session.kt | 16 + .../java/io/appwrite/models/Subscriber.kt | 94 +++ .../main/java/io/appwrite/models/Target.kt | 86 +++ .../src/main/java/io/appwrite/models/Token.kt | 8 + .../src/main/java/io/appwrite/models/User.kt | 30 + .../main/java/io/appwrite/services/Account.kt | 689 +++++++++++++++--- .../main/java/io/appwrite/services/Avatars.kt | 18 +- .../java/io/appwrite/services/Databases.kt | 14 +- .../java/io/appwrite/services/Functions.kt | 11 +- .../main/java/io/appwrite/services/Graphql.kt | 6 +- .../main/java/io/appwrite/services/Locale.kt | 14 +- .../java/io/appwrite/services/Messaging.kt | 90 +++ .../java/io/appwrite/services/Realtime.kt | 3 +- .../main/java/io/appwrite/services/Storage.kt | 14 +- .../main/java/io/appwrite/services/Teams.kt | 21 +- scripts/publish-module.gradle | 3 +- settings.gradle | 3 +- 244 files changed, 2720 insertions(+), 990 deletions(-) create mode 100644 docs/examples/java/account/add-authenticator.md create mode 100644 docs/examples/java/account/create-email-password-session.md rename docs/examples/java/account/{create-magic-u-r-l-session.md => create-email-token.md} (94%) rename docs/examples/java/account/{create-email-session.md => create-magic-u-r-l-token.md} (91%) rename docs/examples/java/account/{create-phone-session.md => create-phone-token.md} (91%) create mode 100644 docs/examples/java/account/create-push-target.md rename docs/examples/java/account/{update-phone-session.md => create-session.md} (92%) create mode 100644 docs/examples/java/account/create2f-a-challenge.md create mode 100644 docs/examples/java/account/delete-authenticator.md create mode 100644 docs/examples/java/account/delete-push-target.md create mode 100644 docs/examples/java/account/list-factors.md create mode 100644 docs/examples/java/account/update-challenge.md create mode 100644 docs/examples/java/account/update-m-f-a.md create mode 100644 docs/examples/java/account/update-push-target.md create mode 100644 docs/examples/java/account/verify-authenticator.md create mode 100644 docs/examples/java/messaging/create-subscriber.md create mode 100644 docs/examples/java/messaging/delete-subscriber.md create mode 100644 docs/examples/kotlin/account/add-authenticator.md create mode 100644 docs/examples/kotlin/account/create-email-password-session.md rename docs/examples/kotlin/account/{create-magic-u-r-l-session.md => create-email-token.md} (77%) rename docs/examples/kotlin/account/{create-email-session.md => create-magic-u-r-l-token.md} (70%) create mode 100644 docs/examples/kotlin/account/create-phone-token.md create mode 100644 docs/examples/kotlin/account/create-push-target.md create mode 100644 docs/examples/kotlin/account/create-session.md create mode 100644 docs/examples/kotlin/account/create2f-a-challenge.md create mode 100644 docs/examples/kotlin/account/delete-authenticator.md create mode 100644 docs/examples/kotlin/account/delete-push-target.md rename docs/examples/kotlin/account/{update-phone-session.md => list-factors.md} (72%) create mode 100644 docs/examples/kotlin/account/update-challenge.md rename docs/examples/kotlin/account/{create-phone-session.md => update-m-f-a.md} (71%) create mode 100644 docs/examples/kotlin/account/update-push-target.md create mode 100644 docs/examples/kotlin/account/verify-authenticator.md create mode 100644 docs/examples/kotlin/messaging/create-subscriber.md create mode 100644 docs/examples/kotlin/messaging/delete-subscriber.md delete mode 100644 example-java/.gitignore delete mode 100644 example-java/build.gradle delete mode 100644 example-java/src/main/AndroidManifest.xml delete mode 100644 example-java/src/main/java/io/appwrite/example_java/MainActivity.java delete mode 100644 example-java/src/main/res/drawable/ic_launcher_background.xml delete mode 100644 example-java/src/main/res/drawable/ic_launcher_foreground.xml delete mode 100644 example-java/src/main/res/layout/activity_main.xml delete mode 100644 example-java/src/main/res/mipmap-anydpi-v26/ic_launcher.xml delete mode 100644 example-java/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml delete mode 100644 example-java/src/main/res/values/colors.xml delete mode 100644 example-java/src/main/res/values/strings.xml delete mode 100644 example-java/src/main/res/values/themes.xml create mode 100644 example/src/main/java/io/appwrite/android/services/MessagingService.kt create mode 100644 library/src/main/java/io/appwrite/OS.kt rename library/src/main/java/io/appwrite/{services => }/Service.kt (71%) create mode 100644 library/src/main/java/io/appwrite/cookies/ListenableCookieJar.kt create mode 100644 library/src/main/java/io/appwrite/enums/Browser.kt create mode 100644 library/src/main/java/io/appwrite/enums/CreditCard.kt create mode 100644 library/src/main/java/io/appwrite/enums/ExecutionMethod.kt create mode 100644 library/src/main/java/io/appwrite/enums/Factor.kt create mode 100644 library/src/main/java/io/appwrite/enums/Flag.kt create mode 100644 library/src/main/java/io/appwrite/enums/ImageFormat.kt create mode 100644 library/src/main/java/io/appwrite/enums/ImageGravity.kt create mode 100644 library/src/main/java/io/appwrite/enums/OAuthProvider.kt create mode 100644 library/src/main/java/io/appwrite/enums/Type.kt delete mode 100644 library/src/main/java/io/appwrite/json/PreciseNumberAdapter.kt create mode 100644 library/src/main/java/io/appwrite/models/MfaChallenge.kt create mode 100644 library/src/main/java/io/appwrite/models/MfaFactors.kt create mode 100644 library/src/main/java/io/appwrite/models/MfaType.kt create mode 100644 library/src/main/java/io/appwrite/models/Subscriber.kt create mode 100644 library/src/main/java/io/appwrite/models/Target.kt create mode 100644 library/src/main/java/io/appwrite/services/Messaging.kt diff --git a/README.md b/README.md index 464c725..f381415 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 1.4.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).** +**This SDK is compatible with Appwrite server version 1.5.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-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:4.0.1") +implementation("io.appwrite:sdk-for-android:5.0.0-rc.2") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 4.0.1 + 5.0.0-rc.2 ``` diff --git a/build.gradle b/build.gradle index f2080e6..0b0c86c 100644 --- a/build.gradle +++ b/build.gradle @@ -2,20 +2,19 @@ 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.8.0" + ext.kotlin_version = "1.9.10" + version System.getenv("SDK_VERSION") + repositories { maven { url "https://plugins.gradle.org/m2/" } google() mavenCentral() } dependencies { - classpath "com.android.tools.build:gradle:4.2.2" + classpath "com.android.tools.build:gradle:8.2.2" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath 'io.github.gradle-nexus:publish-plugin:1.1.0' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files + classpath "io.github.gradle-nexus:publish-plugin:1.3.0" } } diff --git a/docs/examples/java/account/add-authenticator.md b/docs/examples/java/account/add-authenticator.md new file mode 100644 index 0000000..ebb7d12 --- /dev/null +++ b/docs/examples/java/account/add-authenticator.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; +import io.appwrite.enums.Type; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.addAuthenticator( + type.TOTP, + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file diff --git a/docs/examples/java/account/create-anonymous-session.md b/docs/examples/java/account/create-anonymous-session.md index 59c7630..46ae275 100644 --- a/docs/examples/java/account/create-anonymous-session.md +++ b/docs/examples/java/account/create-anonymous-session.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.createAnonymousSession(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/account/create-email-password-session.md b/docs/examples/java/account/create-email-password-session.md new file mode 100644 index 0000000..e3cd353 --- /dev/null +++ b/docs/examples/java/account/create-email-password-session.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.createEmailPasswordSession( + "email@example.com", + "password", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file diff --git a/docs/examples/java/account/create-magic-u-r-l-session.md b/docs/examples/java/account/create-email-token.md similarity index 94% rename from docs/examples/java/account/create-magic-u-r-l-session.md rename to docs/examples/java/account/create-email-token.md index 0ed43dc..f032eb6 100644 --- a/docs/examples/java/account/create-magic-u-r-l-session.md +++ b/docs/examples/java/account/create-email-token.md @@ -8,7 +8,7 @@ Client client = new Client(context) Account account = new Account(client); -account.createMagicURLSession( +account.createEmailToken( "[USER_ID]", "email@example.com", new CoroutineCallback<>((result, error) -> { @@ -19,4 +19,4 @@ account.createMagicURLSession( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/create-j-w-t.md b/docs/examples/java/account/create-j-w-t.md index c312386..13e6e49 100644 --- a/docs/examples/java/account/create-j-w-t.md +++ b/docs/examples/java/account/create-j-w-t.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.createJWT(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/account/create-email-session.md b/docs/examples/java/account/create-magic-u-r-l-token.md similarity index 91% rename from docs/examples/java/account/create-email-session.md rename to docs/examples/java/account/create-magic-u-r-l-token.md index e3e6fdd..48a8b9b 100644 --- a/docs/examples/java/account/create-email-session.md +++ b/docs/examples/java/account/create-magic-u-r-l-token.md @@ -8,9 +8,9 @@ Client client = new Client(context) Account account = new Account(client); -account.createEmailSession( +account.createMagicURLToken( + "[USER_ID]", "email@example.com", - "password" new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.createEmailSession( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/create-o-auth2session.md b/docs/examples/java/account/create-o-auth2session.md index cb9386a..1389673 100644 --- a/docs/examples/java/account/create-o-auth2session.md +++ b/docs/examples/java/account/create-o-auth2session.md @@ -1,6 +1,7 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; +import io.appwrite.enums.OAuthProvider; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -9,7 +10,7 @@ Client client = new Client(context) Account account = new Account(client); account.createOAuth2Session( - "amazon", + OAuthProvider.AMAZON, new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +19,4 @@ account.createOAuth2Session( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/create-phone-session.md b/docs/examples/java/account/create-phone-token.md similarity index 91% rename from docs/examples/java/account/create-phone-session.md rename to docs/examples/java/account/create-phone-token.md index df5bc86..a839e81 100644 --- a/docs/examples/java/account/create-phone-session.md +++ b/docs/examples/java/account/create-phone-token.md @@ -8,9 +8,9 @@ Client client = new Client(context) Account account = new Account(client); -account.createPhoneSession( +account.createPhoneToken( "[USER_ID]", - "+12065550100" + "+12065550100", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.createPhoneSession( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/create-phone-verification.md b/docs/examples/java/account/create-phone-verification.md index 1545d0f..ef14ce8 100644 --- a/docs/examples/java/account/create-phone-verification.md +++ b/docs/examples/java/account/create-phone-verification.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.createPhoneVerification(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/account/create-push-target.md b/docs/examples/java/account/create-push-target.md new file mode 100644 index 0000000..18a5e76 --- /dev/null +++ b/docs/examples/java/account/create-push-target.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.createPushTarget( + "[TARGET_ID]", + "[IDENTIFIER]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file diff --git a/docs/examples/java/account/create-recovery.md b/docs/examples/java/account/create-recovery.md index 5e8584f..f167af2 100644 --- a/docs/examples/java/account/create-recovery.md +++ b/docs/examples/java/account/create-recovery.md @@ -10,7 +10,7 @@ Account account = new Account(client); account.createRecovery( "email@example.com", - "https://example.com" + "https://example.com", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.createRecovery( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/update-phone-session.md b/docs/examples/java/account/create-session.md similarity index 92% rename from docs/examples/java/account/update-phone-session.md rename to docs/examples/java/account/create-session.md index 589e4ff..d853209 100644 --- a/docs/examples/java/account/update-phone-session.md +++ b/docs/examples/java/account/create-session.md @@ -8,9 +8,9 @@ Client client = new Client(context) Account account = new Account(client); -account.updatePhoneSession( +account.createSession( "[USER_ID]", - "[SECRET]" + "[SECRET]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.updatePhoneSession( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/create-verification.md b/docs/examples/java/account/create-verification.md index fcea98f..eb7a537 100644 --- a/docs/examples/java/account/create-verification.md +++ b/docs/examples/java/account/create-verification.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.createVerification( - "https://example.com" + "https://example.com", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ account.createVerification( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/create.md b/docs/examples/java/account/create.md index e08731f..a16d2c7 100644 --- a/docs/examples/java/account/create.md +++ b/docs/examples/java/account/create.md @@ -20,4 +20,4 @@ account.create( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/create2f-a-challenge.md b/docs/examples/java/account/create2f-a-challenge.md new file mode 100644 index 0000000..47fa615 --- /dev/null +++ b/docs/examples/java/account/create2f-a-challenge.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; +import io.appwrite.enums.Factor; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.create2FAChallenge( + factor.TOTP, + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file diff --git a/docs/examples/java/account/delete-authenticator.md b/docs/examples/java/account/delete-authenticator.md new file mode 100644 index 0000000..ba690b3 --- /dev/null +++ b/docs/examples/java/account/delete-authenticator.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; +import io.appwrite.enums.Type; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.deleteAuthenticator( + type.TOTP, + "[OTP]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file diff --git a/docs/examples/java/account/delete-identity.md b/docs/examples/java/account/delete-identity.md index 0d92d04..f33c29a 100644 --- a/docs/examples/java/account/delete-identity.md +++ b/docs/examples/java/account/delete-identity.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.deleteIdentity( - "[IDENTITY_ID]" + "[IDENTITY_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ account.deleteIdentity( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/delete-push-target.md b/docs/examples/java/account/delete-push-target.md new file mode 100644 index 0000000..77b21d6 --- /dev/null +++ b/docs/examples/java/account/delete-push-target.md @@ -0,0 +1,21 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.deletePushTarget( + "[TARGET_ID]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file diff --git a/docs/examples/java/account/delete-session.md b/docs/examples/java/account/delete-session.md index 28009d0..2b8d228 100644 --- a/docs/examples/java/account/delete-session.md +++ b/docs/examples/java/account/delete-session.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.deleteSession( - "[SESSION_ID]" + "[SESSION_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ account.deleteSession( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/delete-sessions.md b/docs/examples/java/account/delete-sessions.md index 6bdc840..147523e 100644 --- a/docs/examples/java/account/delete-sessions.md +++ b/docs/examples/java/account/delete-sessions.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.deleteSessions(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/account/get-prefs.md b/docs/examples/java/account/get-prefs.md index 9911ad3..bfa3c1a 100644 --- a/docs/examples/java/account/get-prefs.md +++ b/docs/examples/java/account/get-prefs.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.getPrefs(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/account/get-session.md b/docs/examples/java/account/get-session.md index fecb543..dd9c89c 100644 --- a/docs/examples/java/account/get-session.md +++ b/docs/examples/java/account/get-session.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.getSession( - "[SESSION_ID]" + "[SESSION_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ account.getSession( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/get.md b/docs/examples/java/account/get.md index 2e5f40a..9006cb8 100644 --- a/docs/examples/java/account/get.md +++ b/docs/examples/java/account/get.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.get(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/account/list-factors.md b/docs/examples/java/account/list-factors.md new file mode 100644 index 0000000..e2d92b5 --- /dev/null +++ b/docs/examples/java/account/list-factors.md @@ -0,0 +1,18 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.listFactors(new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/account/list-identities.md b/docs/examples/java/account/list-identities.md index d1f6a48..08d4c19 100644 --- a/docs/examples/java/account/list-identities.md +++ b/docs/examples/java/account/list-identities.md @@ -17,4 +17,4 @@ account.listIdentities( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/list-logs.md b/docs/examples/java/account/list-logs.md index d2ce790..f4c39fb 100644 --- a/docs/examples/java/account/list-logs.md +++ b/docs/examples/java/account/list-logs.md @@ -17,4 +17,4 @@ account.listLogs( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/list-sessions.md b/docs/examples/java/account/list-sessions.md index 7fd587e..9e70f0d 100644 --- a/docs/examples/java/account/list-sessions.md +++ b/docs/examples/java/account/list-sessions.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.listSessions(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/account/update-challenge.md b/docs/examples/java/account/update-challenge.md new file mode 100644 index 0000000..d972a14 --- /dev/null +++ b/docs/examples/java/account/update-challenge.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.updateChallenge( + "[CHALLENGE_ID]", + "[OTP]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file diff --git a/docs/examples/java/account/update-email.md b/docs/examples/java/account/update-email.md index 8034ada..a7cb414 100644 --- a/docs/examples/java/account/update-email.md +++ b/docs/examples/java/account/update-email.md @@ -10,7 +10,7 @@ Account account = new Account(client); account.updateEmail( "email@example.com", - "password" + "password", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.updateEmail( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/update-m-f-a.md b/docs/examples/java/account/update-m-f-a.md new file mode 100644 index 0000000..16f6973 --- /dev/null +++ b/docs/examples/java/account/update-m-f-a.md @@ -0,0 +1,21 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.updateMFA( + false, + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file 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 0f8f2b3..f46422b 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 @@ -10,7 +10,7 @@ Account account = new Account(client); account.updateMagicURLSession( "[USER_ID]", - "[SECRET]" + "[SECRET]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.updateMagicURLSession( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/update-name.md b/docs/examples/java/account/update-name.md index 5940f93..8b27389 100644 --- a/docs/examples/java/account/update-name.md +++ b/docs/examples/java/account/update-name.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.updateName( - "[NAME]" + "[NAME]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ account.updateName( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/update-password.md b/docs/examples/java/account/update-password.md index d942632..430ab7e 100644 --- a/docs/examples/java/account/update-password.md +++ b/docs/examples/java/account/update-password.md @@ -18,4 +18,4 @@ account.updatePassword( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/update-phone-verification.md b/docs/examples/java/account/update-phone-verification.md index 81785f9..7d66fd9 100644 --- a/docs/examples/java/account/update-phone-verification.md +++ b/docs/examples/java/account/update-phone-verification.md @@ -10,7 +10,7 @@ Account account = new Account(client); account.updatePhoneVerification( "[USER_ID]", - "[SECRET]" + "[SECRET]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.updatePhoneVerification( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/update-phone.md b/docs/examples/java/account/update-phone.md index a8572f9..c958911 100644 --- a/docs/examples/java/account/update-phone.md +++ b/docs/examples/java/account/update-phone.md @@ -10,7 +10,7 @@ Account account = new Account(client); account.updatePhone( "+12065550100", - "password" + "password", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.updatePhone( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/update-prefs.md b/docs/examples/java/account/update-prefs.md index ffd5ef0..5d2e75d 100644 --- a/docs/examples/java/account/update-prefs.md +++ b/docs/examples/java/account/update-prefs.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.updatePrefs( - mapOf( "a" to "b" ) + mapOf( "a" to "b" ), new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ account.updatePrefs( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/update-push-target.md b/docs/examples/java/account/update-push-target.md new file mode 100644 index 0000000..10efbad --- /dev/null +++ b/docs/examples/java/account/update-push-target.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.updatePushTarget( + "[TARGET_ID]", + "[IDENTIFIER]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file diff --git a/docs/examples/java/account/update-recovery.md b/docs/examples/java/account/update-recovery.md index 7b0f392..313eaa5 100644 --- a/docs/examples/java/account/update-recovery.md +++ b/docs/examples/java/account/update-recovery.md @@ -11,8 +11,7 @@ Account account = new Account(client); account.updateRecovery( "[USER_ID]", "[SECRET]", - "password", - "password" + "", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -21,4 +20,4 @@ account.updateRecovery( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/update-session.md b/docs/examples/java/account/update-session.md index 27b8f00..66eda54 100644 --- a/docs/examples/java/account/update-session.md +++ b/docs/examples/java/account/update-session.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.updateSession( - "[SESSION_ID]" + "[SESSION_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ account.updateSession( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/update-status.md b/docs/examples/java/account/update-status.md index 1e18ded..61cb944 100644 --- a/docs/examples/java/account/update-status.md +++ b/docs/examples/java/account/update-status.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.updateStatus(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/account/update-verification.md b/docs/examples/java/account/update-verification.md index d852dbf..9beb1bd 100644 --- a/docs/examples/java/account/update-verification.md +++ b/docs/examples/java/account/update-verification.md @@ -10,7 +10,7 @@ Account account = new Account(client); account.updateVerification( "[USER_ID]", - "[SECRET]" + "[SECRET]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ account.updateVerification( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/account/verify-authenticator.md b/docs/examples/java/account/verify-authenticator.md new file mode 100644 index 0000000..0d10030 --- /dev/null +++ b/docs/examples/java/account/verify-authenticator.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; +import io.appwrite.enums.Type; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.verifyAuthenticator( + type.TOTP, + "[OTP]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file diff --git a/docs/examples/java/avatars/get-browser.md b/docs/examples/java/avatars/get-browser.md index f072110..0652a47 100644 --- a/docs/examples/java/avatars/get-browser.md +++ b/docs/examples/java/avatars/get-browser.md @@ -1,6 +1,7 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Avatars; +import io.appwrite.enums.Browser; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -9,7 +10,7 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); avatars.getBrowser( - "aa", + Browser.AVANT_BROWSER, new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +19,4 @@ avatars.getBrowser( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/avatars/get-credit-card.md b/docs/examples/java/avatars/get-credit-card.md index 0a73312..0f0541a 100644 --- a/docs/examples/java/avatars/get-credit-card.md +++ b/docs/examples/java/avatars/get-credit-card.md @@ -1,6 +1,7 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Avatars; +import io.appwrite.enums.CreditCard; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -9,7 +10,7 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); avatars.getCreditCard( - "amex", + CreditCard.AMERICAN_EXPRESS, new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +19,4 @@ avatars.getCreditCard( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/avatars/get-favicon.md b/docs/examples/java/avatars/get-favicon.md index e0c1cb6..cef5b08 100644 --- a/docs/examples/java/avatars/get-favicon.md +++ b/docs/examples/java/avatars/get-favicon.md @@ -9,7 +9,7 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); avatars.getFavicon( - "https://example.com" + "https://example.com", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ avatars.getFavicon( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/avatars/get-flag.md b/docs/examples/java/avatars/get-flag.md index a5f4790..c931336 100644 --- a/docs/examples/java/avatars/get-flag.md +++ b/docs/examples/java/avatars/get-flag.md @@ -1,6 +1,7 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Avatars; +import io.appwrite.enums.Flag; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -9,7 +10,7 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); avatars.getFlag( - "af", + Flag.AFGHANISTAN, new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +19,4 @@ avatars.getFlag( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/avatars/get-image.md b/docs/examples/java/avatars/get-image.md index cdc8ac7..8ae4df1 100644 --- a/docs/examples/java/avatars/get-image.md +++ b/docs/examples/java/avatars/get-image.md @@ -18,4 +18,4 @@ avatars.getImage( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/avatars/get-initials.md b/docs/examples/java/avatars/get-initials.md index c02490c..36757c4 100644 --- a/docs/examples/java/avatars/get-initials.md +++ b/docs/examples/java/avatars/get-initials.md @@ -17,4 +17,4 @@ avatars.getInitials( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/avatars/get-q-r.md b/docs/examples/java/avatars/get-q-r.md index 2532f20..4894433 100644 --- a/docs/examples/java/avatars/get-q-r.md +++ b/docs/examples/java/avatars/get-q-r.md @@ -18,4 +18,4 @@ avatars.getQR( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index 715e4cd..c26a142 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -21,4 +21,4 @@ databases.createDocument( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/databases/delete-document.md b/docs/examples/java/databases/delete-document.md index 1387f48..d59266b 100644 --- a/docs/examples/java/databases/delete-document.md +++ b/docs/examples/java/databases/delete-document.md @@ -11,7 +11,7 @@ Databases databases = new Databases(client); databases.deleteDocument( "[DATABASE_ID]", "[COLLECTION_ID]", - "[DOCUMENT_ID]" + "[DOCUMENT_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -20,4 +20,4 @@ databases.deleteDocument( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/databases/get-document.md b/docs/examples/java/databases/get-document.md index b1a7161..a63836e 100644 --- a/docs/examples/java/databases/get-document.md +++ b/docs/examples/java/databases/get-document.md @@ -20,4 +20,4 @@ databases.getDocument( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/databases/list-documents.md b/docs/examples/java/databases/list-documents.md index 62dc2c7..6f577ef 100644 --- a/docs/examples/java/databases/list-documents.md +++ b/docs/examples/java/databases/list-documents.md @@ -19,4 +19,4 @@ databases.listDocuments( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/databases/update-document.md b/docs/examples/java/databases/update-document.md index d1ed59d..ae4d539 100644 --- a/docs/examples/java/databases/update-document.md +++ b/docs/examples/java/databases/update-document.md @@ -20,4 +20,4 @@ databases.updateDocument( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/functions/create-execution.md b/docs/examples/java/functions/create-execution.md index 3cce1c3..985d502 100644 --- a/docs/examples/java/functions/create-execution.md +++ b/docs/examples/java/functions/create-execution.md @@ -18,4 +18,4 @@ functions.createExecution( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/functions/get-execution.md b/docs/examples/java/functions/get-execution.md index 459d743..c066540 100644 --- a/docs/examples/java/functions/get-execution.md +++ b/docs/examples/java/functions/get-execution.md @@ -10,7 +10,7 @@ Functions functions = new Functions(client); functions.getExecution( "[FUNCTION_ID]", - "[EXECUTION_ID]" + "[EXECUTION_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ functions.getExecution( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/functions/list-executions.md b/docs/examples/java/functions/list-executions.md index c1f982b..53f45ca 100644 --- a/docs/examples/java/functions/list-executions.md +++ b/docs/examples/java/functions/list-executions.md @@ -18,4 +18,4 @@ functions.listExecutions( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/graphql/mutation.md b/docs/examples/java/graphql/mutation.md index 262e513..5d140d6 100644 --- a/docs/examples/java/graphql/mutation.md +++ b/docs/examples/java/graphql/mutation.md @@ -9,7 +9,7 @@ Client client = new Client(context) Graphql graphql = new Graphql(client); graphql.mutation( - mapOf( "a" to "b" ) + mapOf( "a" to "b" ), new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ graphql.mutation( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/graphql/query.md b/docs/examples/java/graphql/query.md index 4291b47..de693fa 100644 --- a/docs/examples/java/graphql/query.md +++ b/docs/examples/java/graphql/query.md @@ -9,7 +9,7 @@ Client client = new Client(context) Graphql graphql = new Graphql(client); graphql.query( - mapOf( "a" to "b" ) + mapOf( "a" to "b" ), new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ graphql.query( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/locale/get.md b/docs/examples/java/locale/get.md index 4d14be6..cc37896 100644 --- a/docs/examples/java/locale/get.md +++ b/docs/examples/java/locale/get.md @@ -9,7 +9,7 @@ Client client = new Client(context) Locale locale = new Locale(client); locale.get(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/locale/list-codes.md b/docs/examples/java/locale/list-codes.md index 599070e..3fbdf85 100644 --- a/docs/examples/java/locale/list-codes.md +++ b/docs/examples/java/locale/list-codes.md @@ -9,7 +9,7 @@ Client client = new Client(context) Locale locale = new Locale(client); locale.listCodes(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/locale/list-continents.md b/docs/examples/java/locale/list-continents.md index 6abe97a..296eade 100644 --- a/docs/examples/java/locale/list-continents.md +++ b/docs/examples/java/locale/list-continents.md @@ -9,7 +9,7 @@ Client client = new Client(context) Locale locale = new Locale(client); locale.listContinents(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/locale/list-countries-e-u.md b/docs/examples/java/locale/list-countries-e-u.md index 3c5ca3a..f674ac5 100644 --- a/docs/examples/java/locale/list-countries-e-u.md +++ b/docs/examples/java/locale/list-countries-e-u.md @@ -9,7 +9,7 @@ Client client = new Client(context) Locale locale = new Locale(client); locale.listCountriesEU(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/locale/list-countries-phones.md b/docs/examples/java/locale/list-countries-phones.md index 81ef94d..6280cbb 100644 --- a/docs/examples/java/locale/list-countries-phones.md +++ b/docs/examples/java/locale/list-countries-phones.md @@ -9,7 +9,7 @@ Client client = new Client(context) Locale locale = new Locale(client); locale.listCountriesPhones(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/locale/list-countries.md b/docs/examples/java/locale/list-countries.md index dc0d5f5..eab9ae2 100644 --- a/docs/examples/java/locale/list-countries.md +++ b/docs/examples/java/locale/list-countries.md @@ -9,7 +9,7 @@ Client client = new Client(context) Locale locale = new Locale(client); locale.listCountries(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/locale/list-currencies.md b/docs/examples/java/locale/list-currencies.md index 7a327b3..662e025 100644 --- a/docs/examples/java/locale/list-currencies.md +++ b/docs/examples/java/locale/list-currencies.md @@ -9,7 +9,7 @@ Client client = new Client(context) Locale locale = new Locale(client); locale.listCurrencies(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/locale/list-languages.md b/docs/examples/java/locale/list-languages.md index 0688614..dd68bf2 100644 --- a/docs/examples/java/locale/list-languages.md +++ b/docs/examples/java/locale/list-languages.md @@ -9,7 +9,7 @@ Client client = new Client(context) Locale locale = new Locale(client); locale.listLanguages(new CoroutineCallback<>((result, error) -> { - if (error != null) + if (error != null) { error.printStackTrace(); return; } diff --git a/docs/examples/java/messaging/create-subscriber.md b/docs/examples/java/messaging/create-subscriber.md new file mode 100644 index 0000000..d071008 --- /dev/null +++ b/docs/examples/java/messaging/create-subscriber.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Messaging; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Messaging messaging = new Messaging(client); + +messaging.createSubscriber( + "[TOPIC_ID]", + "[SUBSCRIBER_ID]", + "[TARGET_ID]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file diff --git a/docs/examples/java/messaging/delete-subscriber.md b/docs/examples/java/messaging/delete-subscriber.md new file mode 100644 index 0000000..a1d5686 --- /dev/null +++ b/docs/examples/java/messaging/delete-subscriber.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Messaging; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Messaging messaging = new Messaging(client); + +messaging.deleteSubscriber( + "[TOPIC_ID]", + "[SUBSCRIBER_ID]", + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); \ No newline at end of file diff --git a/docs/examples/java/storage/create-file.md b/docs/examples/java/storage/create-file.md index 732b302..b99312b 100644 --- a/docs/examples/java/storage/create-file.md +++ b/docs/examples/java/storage/create-file.md @@ -21,4 +21,4 @@ storage.createFile( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/storage/delete-file.md b/docs/examples/java/storage/delete-file.md index 69a0f0f..9ac7f2e 100644 --- a/docs/examples/java/storage/delete-file.md +++ b/docs/examples/java/storage/delete-file.md @@ -10,7 +10,7 @@ Storage storage = new Storage(client); storage.deleteFile( "[BUCKET_ID]", - "[FILE_ID]" + "[FILE_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ storage.deleteFile( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/storage/get-file-download.md b/docs/examples/java/storage/get-file-download.md index 2ab30dc..7428cc0 100644 --- a/docs/examples/java/storage/get-file-download.md +++ b/docs/examples/java/storage/get-file-download.md @@ -10,7 +10,7 @@ Storage storage = new Storage(client); storage.getFileDownload( "[BUCKET_ID]", - "[FILE_ID]" + "[FILE_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ storage.getFileDownload( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/storage/get-file-preview.md b/docs/examples/java/storage/get-file-preview.md index 483f2fc..6de0abf 100644 --- a/docs/examples/java/storage/get-file-preview.md +++ b/docs/examples/java/storage/get-file-preview.md @@ -19,4 +19,4 @@ storage.getFilePreview( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/storage/get-file-view.md b/docs/examples/java/storage/get-file-view.md index 5614b69..3c0392d 100644 --- a/docs/examples/java/storage/get-file-view.md +++ b/docs/examples/java/storage/get-file-view.md @@ -10,7 +10,7 @@ Storage storage = new Storage(client); storage.getFileView( "[BUCKET_ID]", - "[FILE_ID]" + "[FILE_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ storage.getFileView( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/storage/get-file.md b/docs/examples/java/storage/get-file.md index 4ae0de0..c425758 100644 --- a/docs/examples/java/storage/get-file.md +++ b/docs/examples/java/storage/get-file.md @@ -10,7 +10,7 @@ Storage storage = new Storage(client); storage.getFile( "[BUCKET_ID]", - "[FILE_ID]" + "[FILE_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ storage.getFile( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/storage/list-files.md b/docs/examples/java/storage/list-files.md index dedfb6c..b6d38aa 100644 --- a/docs/examples/java/storage/list-files.md +++ b/docs/examples/java/storage/list-files.md @@ -18,4 +18,4 @@ storage.listFiles( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/storage/update-file.md b/docs/examples/java/storage/update-file.md index 9b4dd92..6aae427 100644 --- a/docs/examples/java/storage/update-file.md +++ b/docs/examples/java/storage/update-file.md @@ -19,4 +19,4 @@ storage.updateFile( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/create-membership.md b/docs/examples/java/teams/create-membership.md index 6073f5b..3091164 100644 --- a/docs/examples/java/teams/create-membership.md +++ b/docs/examples/java/teams/create-membership.md @@ -19,4 +19,4 @@ teams.createMembership( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/create.md b/docs/examples/java/teams/create.md index 263fa57..aa7f567 100644 --- a/docs/examples/java/teams/create.md +++ b/docs/examples/java/teams/create.md @@ -19,4 +19,4 @@ teams.create( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/delete-membership.md b/docs/examples/java/teams/delete-membership.md index 40f28f0..3837fad 100644 --- a/docs/examples/java/teams/delete-membership.md +++ b/docs/examples/java/teams/delete-membership.md @@ -10,7 +10,7 @@ Teams teams = new Teams(client); teams.deleteMembership( "[TEAM_ID]", - "[MEMBERSHIP_ID]" + "[MEMBERSHIP_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ teams.deleteMembership( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/delete.md b/docs/examples/java/teams/delete.md index 5b4c378..75355ae 100644 --- a/docs/examples/java/teams/delete.md +++ b/docs/examples/java/teams/delete.md @@ -9,7 +9,7 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.delete( - "[TEAM_ID]" + "[TEAM_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ teams.delete( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/get-membership.md b/docs/examples/java/teams/get-membership.md index f2f1d99..0ba9c87 100644 --- a/docs/examples/java/teams/get-membership.md +++ b/docs/examples/java/teams/get-membership.md @@ -10,7 +10,7 @@ Teams teams = new Teams(client); teams.getMembership( "[TEAM_ID]", - "[MEMBERSHIP_ID]" + "[MEMBERSHIP_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ teams.getMembership( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/get-prefs.md b/docs/examples/java/teams/get-prefs.md index 6963cb4..e93b482 100644 --- a/docs/examples/java/teams/get-prefs.md +++ b/docs/examples/java/teams/get-prefs.md @@ -9,7 +9,7 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.getPrefs( - "[TEAM_ID]" + "[TEAM_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ teams.getPrefs( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/get.md b/docs/examples/java/teams/get.md index 549af20..f5406a2 100644 --- a/docs/examples/java/teams/get.md +++ b/docs/examples/java/teams/get.md @@ -9,7 +9,7 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.get( - "[TEAM_ID]" + "[TEAM_ID]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,4 @@ teams.get( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/list-memberships.md b/docs/examples/java/teams/list-memberships.md index 3da4e33..b61b0d0 100644 --- a/docs/examples/java/teams/list-memberships.md +++ b/docs/examples/java/teams/list-memberships.md @@ -18,4 +18,4 @@ teams.listMemberships( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/list.md b/docs/examples/java/teams/list.md index b20ad4a..2f21813 100644 --- a/docs/examples/java/teams/list.md +++ b/docs/examples/java/teams/list.md @@ -17,4 +17,4 @@ teams.list( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/update-membership-status.md b/docs/examples/java/teams/update-membership-status.md index 499251f..33bd869 100644 --- a/docs/examples/java/teams/update-membership-status.md +++ b/docs/examples/java/teams/update-membership-status.md @@ -12,7 +12,7 @@ teams.updateMembershipStatus( "[TEAM_ID]", "[MEMBERSHIP_ID]", "[USER_ID]", - "[SECRET]" + "[SECRET]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -21,4 +21,4 @@ teams.updateMembershipStatus( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/update-membership.md b/docs/examples/java/teams/update-membership.md index 6cb3346..48efbe3 100644 --- a/docs/examples/java/teams/update-membership.md +++ b/docs/examples/java/teams/update-membership.md @@ -11,7 +11,7 @@ Teams teams = new Teams(client); teams.updateMembership( "[TEAM_ID]", "[MEMBERSHIP_ID]", - listOf() + listOf(), new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -20,4 +20,4 @@ teams.updateMembership( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/update-name.md b/docs/examples/java/teams/update-name.md index 170ee59..a84ba84 100644 --- a/docs/examples/java/teams/update-name.md +++ b/docs/examples/java/teams/update-name.md @@ -10,7 +10,7 @@ Teams teams = new Teams(client); teams.updateName( "[TEAM_ID]", - "[NAME]" + "[NAME]", new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ teams.updateName( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/java/teams/update-prefs.md b/docs/examples/java/teams/update-prefs.md index a19ad82..874f976 100644 --- a/docs/examples/java/teams/update-prefs.md +++ b/docs/examples/java/teams/update-prefs.md @@ -10,7 +10,7 @@ Teams teams = new Teams(client); teams.updatePrefs( "[TEAM_ID]", - mapOf( "a" to "b" ) + mapOf( "a" to "b" ), new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,4 @@ teams.updatePrefs( Log.d("Appwrite", result.toString()); }) -); +); \ No newline at end of file diff --git a/docs/examples/kotlin/account/add-authenticator.md b/docs/examples/kotlin/account/add-authenticator.md new file mode 100644 index 0000000..96a9c6e --- /dev/null +++ b/docs/examples/kotlin/account/add-authenticator.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account +import io.appwrite.enums.Type + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val response = account.addAuthenticator( + type = type.TOTP, +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-anonymous-session.md b/docs/examples/kotlin/account/create-anonymous-session.md index cdcf401..6d1e632 100644 --- a/docs/examples/kotlin/account/create-anonymous-session.md +++ b/docs/examples/kotlin/account/create-anonymous-session.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) diff --git a/docs/examples/kotlin/account/create-email-password-session.md b/docs/examples/kotlin/account/create-email-password-session.md new file mode 100644 index 0000000..016e73b --- /dev/null +++ b/docs/examples/kotlin/account/create-email-password-session.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val response = account.createEmailPasswordSession( + email = "email@example.com", + password = "password", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-magic-u-r-l-session.md b/docs/examples/kotlin/account/create-email-token.md similarity index 77% rename from docs/examples/kotlin/account/create-magic-u-r-l-session.md rename to docs/examples/kotlin/account/create-email-token.md index 51368b5..6165707 100644 --- a/docs/examples/kotlin/account/create-magic-u-r-l-session.md +++ b/docs/examples/kotlin/account/create-email-token.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -7,7 +8,7 @@ val client = Client(context) val account = Account(client) -val response = account.createMagicURLSession( +val response = account.createEmailToken( userId = "[USER_ID]", email = "email@example.com", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-j-w-t.md b/docs/examples/kotlin/account/create-j-w-t.md index 35e7a6f..c3131e6 100644 --- a/docs/examples/kotlin/account/create-j-w-t.md +++ b/docs/examples/kotlin/account/create-j-w-t.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) diff --git a/docs/examples/kotlin/account/create-email-session.md b/docs/examples/kotlin/account/create-magic-u-r-l-token.md similarity index 70% rename from docs/examples/kotlin/account/create-email-session.md rename to docs/examples/kotlin/account/create-magic-u-r-l-token.md index ab8d581..9d02c96 100644 --- a/docs/examples/kotlin/account/create-email-session.md +++ b/docs/examples/kotlin/account/create-magic-u-r-l-token.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -7,7 +8,7 @@ val client = Client(context) val account = Account(client) -val response = account.createEmailSession( +val response = account.createMagicURLToken( + userId = "[USER_ID]", email = "email@example.com", - password = "password" -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-o-auth2session.md b/docs/examples/kotlin/account/create-o-auth2session.md index 395bfad..ac01fe5 100644 --- a/docs/examples/kotlin/account/create-o-auth2session.md +++ b/docs/examples/kotlin/account/create-o-auth2session.md @@ -1,5 +1,7 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account +import io.appwrite.enums.OAuthProvider val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -8,5 +10,5 @@ val client = Client(context) val account = Account(client) account.createOAuth2Session( - provider = "amazon", -) + provider = OAuthProvider.AMAZON, +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-phone-token.md b/docs/examples/kotlin/account/create-phone-token.md new file mode 100644 index 0000000..abb46c5 --- /dev/null +++ b/docs/examples/kotlin/account/create-phone-token.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val response = account.createPhoneToken( + userId = "[USER_ID]", + phone = "+12065550100", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-phone-verification.md b/docs/examples/kotlin/account/create-phone-verification.md index 12fb9f7..3fb5064 100644 --- a/docs/examples/kotlin/account/create-phone-verification.md +++ b/docs/examples/kotlin/account/create-phone-verification.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) diff --git a/docs/examples/kotlin/account/create-push-target.md b/docs/examples/kotlin/account/create-push-target.md new file mode 100644 index 0000000..30c4d39 --- /dev/null +++ b/docs/examples/kotlin/account/create-push-target.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val response = account.createPushTarget( + targetId = "[TARGET_ID]", + identifier = "[IDENTIFIER]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-recovery.md b/docs/examples/kotlin/account/create-recovery.md index 7d73a67..f678fcf 100644 --- a/docs/examples/kotlin/account/create-recovery.md +++ b/docs/examples/kotlin/account/create-recovery.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -9,5 +10,5 @@ val account = Account(client) val response = account.createRecovery( email = "email@example.com", - url = "https://example.com" -) + url = "https://example.com", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-session.md b/docs/examples/kotlin/account/create-session.md new file mode 100644 index 0000000..ceb7726 --- /dev/null +++ b/docs/examples/kotlin/account/create-session.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val response = account.createSession( + userId = "[USER_ID]", + secret = "[SECRET]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-verification.md b/docs/examples/kotlin/account/create-verification.md index b3dc43a..1832348 100644 --- a/docs/examples/kotlin/account/create-verification.md +++ b/docs/examples/kotlin/account/create-verification.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -8,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.createVerification( - url = "https://example.com" -) + url = "https://example.com", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create.md b/docs/examples/kotlin/account/create.md index c72ae90..8022955 100644 --- a/docs/examples/kotlin/account/create.md +++ b/docs/examples/kotlin/account/create.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -11,4 +12,4 @@ val response = account.create( userId = "[USER_ID]", email = "email@example.com", password = "", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create2f-a-challenge.md b/docs/examples/kotlin/account/create2f-a-challenge.md new file mode 100644 index 0000000..fcc483e --- /dev/null +++ b/docs/examples/kotlin/account/create2f-a-challenge.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account +import io.appwrite.enums.Factor + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val response = account.create2FAChallenge( + factor = factor.TOTP, +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-authenticator.md b/docs/examples/kotlin/account/delete-authenticator.md new file mode 100644 index 0000000..b43fc54 --- /dev/null +++ b/docs/examples/kotlin/account/delete-authenticator.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account +import io.appwrite.enums.Type + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val response = account.deleteAuthenticator( + type = type.TOTP, + otp = "[OTP]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-identity.md b/docs/examples/kotlin/account/delete-identity.md index 440333e..cbf6913 100644 --- a/docs/examples/kotlin/account/delete-identity.md +++ b/docs/examples/kotlin/account/delete-identity.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -8,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.deleteIdentity( - identityId = "[IDENTITY_ID]" -) + identityId = "[IDENTITY_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-push-target.md b/docs/examples/kotlin/account/delete-push-target.md new file mode 100644 index 0000000..ea79749 --- /dev/null +++ b/docs/examples/kotlin/account/delete-push-target.md @@ -0,0 +1,13 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val response = account.deletePushTarget( + targetId = "[TARGET_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-session.md b/docs/examples/kotlin/account/delete-session.md index a98a286..615f218 100644 --- a/docs/examples/kotlin/account/delete-session.md +++ b/docs/examples/kotlin/account/delete-session.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -8,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.deleteSession( - sessionId = "[SESSION_ID]" -) + sessionId = "[SESSION_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-sessions.md b/docs/examples/kotlin/account/delete-sessions.md index c9afbf1..db8e00d 100644 --- a/docs/examples/kotlin/account/delete-sessions.md +++ b/docs/examples/kotlin/account/delete-sessions.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) diff --git a/docs/examples/kotlin/account/get-prefs.md b/docs/examples/kotlin/account/get-prefs.md index bd3f81a..0112f8b 100644 --- a/docs/examples/kotlin/account/get-prefs.md +++ b/docs/examples/kotlin/account/get-prefs.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) diff --git a/docs/examples/kotlin/account/get-session.md b/docs/examples/kotlin/account/get-session.md index d6d6c72..1b15d5b 100644 --- a/docs/examples/kotlin/account/get-session.md +++ b/docs/examples/kotlin/account/get-session.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -8,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.getSession( - sessionId = "[SESSION_ID]" -) + sessionId = "[SESSION_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/get.md b/docs/examples/kotlin/account/get.md index 4c8f0be..6c08a1c 100644 --- a/docs/examples/kotlin/account/get.md +++ b/docs/examples/kotlin/account/get.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) diff --git a/docs/examples/kotlin/account/update-phone-session.md b/docs/examples/kotlin/account/list-factors.md similarity index 72% rename from docs/examples/kotlin/account/update-phone-session.md rename to docs/examples/kotlin/account/list-factors.md index d3b02e0..e30f652 100644 --- a/docs/examples/kotlin/account/update-phone-session.md +++ b/docs/examples/kotlin/account/list-factors.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -7,7 +8,4 @@ val client = Client(context) val account = Account(client) -val response = account.updatePhoneSession( - userId = "[USER_ID]", - secret = "[SECRET]" -) +val response = account.listFactors() diff --git a/docs/examples/kotlin/account/list-identities.md b/docs/examples/kotlin/account/list-identities.md index 3292b35..d87409c 100644 --- a/docs/examples/kotlin/account/list-identities.md +++ b/docs/examples/kotlin/account/list-identities.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -8,4 +9,4 @@ val client = Client(context) val account = Account(client) val response = account.listIdentities( -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/list-logs.md b/docs/examples/kotlin/account/list-logs.md index eb337ca..f4ce74f 100644 --- a/docs/examples/kotlin/account/list-logs.md +++ b/docs/examples/kotlin/account/list-logs.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -8,4 +9,4 @@ val client = Client(context) val account = Account(client) val response = account.listLogs( -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/list-sessions.md b/docs/examples/kotlin/account/list-sessions.md index cd9f63b..2c692b8 100644 --- a/docs/examples/kotlin/account/list-sessions.md +++ b/docs/examples/kotlin/account/list-sessions.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) diff --git a/docs/examples/kotlin/account/update-challenge.md b/docs/examples/kotlin/account/update-challenge.md new file mode 100644 index 0000000..23718d2 --- /dev/null +++ b/docs/examples/kotlin/account/update-challenge.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val response = account.updateChallenge( + challengeId = "[CHALLENGE_ID]", + otp = "[OTP]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-email.md b/docs/examples/kotlin/account/update-email.md index 85a0242..6b3655a 100644 --- a/docs/examples/kotlin/account/update-email.md +++ b/docs/examples/kotlin/account/update-email.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -9,5 +10,5 @@ val account = Account(client) val response = account.updateEmail( email = "email@example.com", - password = "password" -) + password = "password", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-phone-session.md b/docs/examples/kotlin/account/update-m-f-a.md similarity index 71% rename from docs/examples/kotlin/account/create-phone-session.md rename to docs/examples/kotlin/account/update-m-f-a.md index eed6f7a..1bd3fd2 100644 --- a/docs/examples/kotlin/account/create-phone-session.md +++ b/docs/examples/kotlin/account/update-m-f-a.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -7,7 +8,6 @@ val client = Client(context) val account = Account(client) -val response = account.createPhoneSession( - userId = "[USER_ID]", - phone = "+12065550100" -) +val response = account.updateMFA( + mfa = false, +) \ No newline at end of file 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 c7286ba..1f77281 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,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -9,5 +10,5 @@ val account = Account(client) val response = account.updateMagicURLSession( userId = "[USER_ID]", - secret = "[SECRET]" -) + secret = "[SECRET]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-name.md b/docs/examples/kotlin/account/update-name.md index 574f493..5d18e1f 100644 --- a/docs/examples/kotlin/account/update-name.md +++ b/docs/examples/kotlin/account/update-name.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -8,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.updateName( - name = "[NAME]" -) + name = "[NAME]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-password.md b/docs/examples/kotlin/account/update-password.md index c5338b8..45e9556 100644 --- a/docs/examples/kotlin/account/update-password.md +++ b/docs/examples/kotlin/account/update-password.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -9,4 +10,4 @@ val account = Account(client) val response = account.updatePassword( password = "", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-phone-verification.md b/docs/examples/kotlin/account/update-phone-verification.md index 0314f74..c4c0e84 100644 --- a/docs/examples/kotlin/account/update-phone-verification.md +++ b/docs/examples/kotlin/account/update-phone-verification.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -9,5 +10,5 @@ val account = Account(client) val response = account.updatePhoneVerification( userId = "[USER_ID]", - secret = "[SECRET]" -) + secret = "[SECRET]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-phone.md b/docs/examples/kotlin/account/update-phone.md index 76eb8aa..d86e628 100644 --- a/docs/examples/kotlin/account/update-phone.md +++ b/docs/examples/kotlin/account/update-phone.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -9,5 +10,5 @@ val account = Account(client) val response = account.updatePhone( phone = "+12065550100", - password = "password" -) + password = "password", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-prefs.md b/docs/examples/kotlin/account/update-prefs.md index f16e40b..58d5cd0 100644 --- a/docs/examples/kotlin/account/update-prefs.md +++ b/docs/examples/kotlin/account/update-prefs.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -8,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.updatePrefs( - prefs = mapOf( "a" to "b" ) -) + prefs = mapOf( "a" to "b" ), +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-push-target.md b/docs/examples/kotlin/account/update-push-target.md new file mode 100644 index 0000000..ff1e3a1 --- /dev/null +++ b/docs/examples/kotlin/account/update-push-target.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val response = account.updatePushTarget( + targetId = "[TARGET_ID]", + identifier = "[IDENTIFIER]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-recovery.md b/docs/examples/kotlin/account/update-recovery.md index 9682899..6b7a6d0 100644 --- a/docs/examples/kotlin/account/update-recovery.md +++ b/docs/examples/kotlin/account/update-recovery.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -10,6 +11,5 @@ val account = Account(client) val response = account.updateRecovery( userId = "[USER_ID]", secret = "[SECRET]", - password = "password", - passwordAgain = "password" -) + password = "", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-session.md b/docs/examples/kotlin/account/update-session.md index e9e83d0..1257334 100644 --- a/docs/examples/kotlin/account/update-session.md +++ b/docs/examples/kotlin/account/update-session.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -8,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.updateSession( - sessionId = "[SESSION_ID]" -) + sessionId = "[SESSION_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-status.md b/docs/examples/kotlin/account/update-status.md index f7789ea..e822de9 100644 --- a/docs/examples/kotlin/account/update-status.md +++ b/docs/examples/kotlin/account/update-status.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) diff --git a/docs/examples/kotlin/account/update-verification.md b/docs/examples/kotlin/account/update-verification.md index af800c1..0dcd75b 100644 --- a/docs/examples/kotlin/account/update-verification.md +++ b/docs/examples/kotlin/account/update-verification.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) @@ -9,5 +10,5 @@ val account = Account(client) val response = account.updateVerification( userId = "[USER_ID]", - secret = "[SECRET]" -) + secret = "[SECRET]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/verify-authenticator.md b/docs/examples/kotlin/account/verify-authenticator.md new file mode 100644 index 0000000..ec9943c --- /dev/null +++ b/docs/examples/kotlin/account/verify-authenticator.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account +import io.appwrite.enums.Type + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val response = account.verifyAuthenticator( + type = type.TOTP, + otp = "[OTP]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-browser.md b/docs/examples/kotlin/avatars/get-browser.md index b1b2d08..ab7c749 100644 --- a/docs/examples/kotlin/avatars/get-browser.md +++ b/docs/examples/kotlin/avatars/get-browser.md @@ -1,5 +1,7 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars +import io.appwrite.enums.Browser val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -7,6 +9,6 @@ val client = Client(context) val avatars = Avatars(client) -val result = avatars.getBrowser( - code = "aa", -) +val result =avatars.getBrowser( + code = Browser.AVANT_BROWSER, +) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-credit-card.md b/docs/examples/kotlin/avatars/get-credit-card.md index 411e05a..758f70d 100644 --- a/docs/examples/kotlin/avatars/get-credit-card.md +++ b/docs/examples/kotlin/avatars/get-credit-card.md @@ -1,5 +1,7 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars +import io.appwrite.enums.CreditCard val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -7,6 +9,6 @@ val client = Client(context) val avatars = Avatars(client) -val result = avatars.getCreditCard( - code = "amex", -) +val result =avatars.getCreditCard( + code = CreditCard.AMERICAN_EXPRESS, +) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-favicon.md b/docs/examples/kotlin/avatars/get-favicon.md index 1a4b217..1bb1372 100644 --- a/docs/examples/kotlin/avatars/get-favicon.md +++ b/docs/examples/kotlin/avatars/get-favicon.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars val client = Client(context) @@ -7,6 +8,6 @@ val client = Client(context) val avatars = Avatars(client) -val result = avatars.getFavicon( - url = "https://example.com" -) +val result =avatars.getFavicon( + url = "https://example.com", +) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-flag.md b/docs/examples/kotlin/avatars/get-flag.md index 5c882d6..142f626 100644 --- a/docs/examples/kotlin/avatars/get-flag.md +++ b/docs/examples/kotlin/avatars/get-flag.md @@ -1,5 +1,7 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars +import io.appwrite.enums.Flag val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -7,6 +9,6 @@ val client = Client(context) val avatars = Avatars(client) -val result = avatars.getFlag( - code = "af", -) +val result =avatars.getFlag( + code = Flag.AFGHANISTAN, +) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-image.md b/docs/examples/kotlin/avatars/get-image.md index 20d8dff..c1ccd96 100644 --- a/docs/examples/kotlin/avatars/get-image.md +++ b/docs/examples/kotlin/avatars/get-image.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars val client = Client(context) @@ -7,6 +8,6 @@ val client = Client(context) val avatars = Avatars(client) -val result = avatars.getImage( +val result =avatars.getImage( url = "https://example.com", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-initials.md b/docs/examples/kotlin/avatars/get-initials.md index 70ef9b2..62c69c8 100644 --- a/docs/examples/kotlin/avatars/get-initials.md +++ b/docs/examples/kotlin/avatars/get-initials.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars val client = Client(context) @@ -7,5 +8,5 @@ val client = Client(context) val avatars = Avatars(client) -val result = avatars.getInitials( -) +val result =avatars.getInitials( +) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-q-r.md b/docs/examples/kotlin/avatars/get-q-r.md index 92b17e1..85de6d3 100644 --- a/docs/examples/kotlin/avatars/get-q-r.md +++ b/docs/examples/kotlin/avatars/get-q-r.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars val client = Client(context) @@ -7,6 +8,6 @@ val client = Client(context) val avatars = Avatars(client) -val result = avatars.getQR( +val result =avatars.getQR( text = "[TEXT]", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index d7f1991..bc5445a 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Databases val client = Client(context) @@ -12,4 +13,4 @@ val response = databases.createDocument( collectionId = "[COLLECTION_ID]", documentId = "[DOCUMENT_ID]", data = mapOf( "a" to "b" ), -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/delete-document.md b/docs/examples/kotlin/databases/delete-document.md index c5bf2a2..d24db61 100644 --- a/docs/examples/kotlin/databases/delete-document.md +++ b/docs/examples/kotlin/databases/delete-document.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Databases val client = Client(context) @@ -10,5 +11,5 @@ val databases = Databases(client) val response = databases.deleteDocument( databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", - documentId = "[DOCUMENT_ID]" -) + documentId = "[DOCUMENT_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/get-document.md b/docs/examples/kotlin/databases/get-document.md index abdee36..328b801 100644 --- a/docs/examples/kotlin/databases/get-document.md +++ b/docs/examples/kotlin/databases/get-document.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Databases val client = Client(context) @@ -11,4 +12,4 @@ val response = databases.getDocument( databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", documentId = "[DOCUMENT_ID]", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/list-documents.md b/docs/examples/kotlin/databases/list-documents.md index f97d878..b5511d6 100644 --- a/docs/examples/kotlin/databases/list-documents.md +++ b/docs/examples/kotlin/databases/list-documents.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Databases val client = Client(context) @@ -10,4 +11,4 @@ val databases = Databases(client) val response = databases.listDocuments( databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/update-document.md b/docs/examples/kotlin/databases/update-document.md index 3820b89..e2d989e 100644 --- a/docs/examples/kotlin/databases/update-document.md +++ b/docs/examples/kotlin/databases/update-document.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Databases val client = Client(context) @@ -11,4 +12,4 @@ val response = databases.updateDocument( databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", documentId = "[DOCUMENT_ID]", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/create-execution.md b/docs/examples/kotlin/functions/create-execution.md index 77d4587..96dad59 100644 --- a/docs/examples/kotlin/functions/create-execution.md +++ b/docs/examples/kotlin/functions/create-execution.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Functions val client = Client(context) @@ -9,4 +10,4 @@ val functions = Functions(client) val response = functions.createExecution( functionId = "[FUNCTION_ID]", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/get-execution.md b/docs/examples/kotlin/functions/get-execution.md index b576686..e366f4b 100644 --- a/docs/examples/kotlin/functions/get-execution.md +++ b/docs/examples/kotlin/functions/get-execution.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Functions val client = Client(context) @@ -9,5 +10,5 @@ val functions = Functions(client) val response = functions.getExecution( functionId = "[FUNCTION_ID]", - executionId = "[EXECUTION_ID]" -) + executionId = "[EXECUTION_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/list-executions.md b/docs/examples/kotlin/functions/list-executions.md index 14b613f..ba2ff2d 100644 --- a/docs/examples/kotlin/functions/list-executions.md +++ b/docs/examples/kotlin/functions/list-executions.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Functions val client = Client(context) @@ -9,4 +10,4 @@ val functions = Functions(client) val response = functions.listExecutions( functionId = "[FUNCTION_ID]", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/graphql/mutation.md b/docs/examples/kotlin/graphql/mutation.md index dc37a3e..eee3f82 100644 --- a/docs/examples/kotlin/graphql/mutation.md +++ b/docs/examples/kotlin/graphql/mutation.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Graphql val client = Client(context) @@ -8,5 +9,5 @@ val client = Client(context) val graphql = Graphql(client) val response = graphql.mutation( - query = mapOf( "a" to "b" ) -) + query = mapOf( "a" to "b" ), +) \ No newline at end of file diff --git a/docs/examples/kotlin/graphql/query.md b/docs/examples/kotlin/graphql/query.md index d821070..1337d36 100644 --- a/docs/examples/kotlin/graphql/query.md +++ b/docs/examples/kotlin/graphql/query.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Graphql val client = Client(context) @@ -8,5 +9,5 @@ val client = Client(context) val graphql = Graphql(client) val response = graphql.query( - query = mapOf( "a" to "b" ) -) + query = mapOf( "a" to "b" ), +) \ No newline at end of file diff --git a/docs/examples/kotlin/locale/get.md b/docs/examples/kotlin/locale/get.md index a2044c7..ec7f625 100644 --- a/docs/examples/kotlin/locale/get.md +++ b/docs/examples/kotlin/locale/get.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) diff --git a/docs/examples/kotlin/locale/list-codes.md b/docs/examples/kotlin/locale/list-codes.md index b4e949b..e81e106 100644 --- a/docs/examples/kotlin/locale/list-codes.md +++ b/docs/examples/kotlin/locale/list-codes.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) diff --git a/docs/examples/kotlin/locale/list-continents.md b/docs/examples/kotlin/locale/list-continents.md index 610747e..0255e65 100644 --- a/docs/examples/kotlin/locale/list-continents.md +++ b/docs/examples/kotlin/locale/list-continents.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) diff --git a/docs/examples/kotlin/locale/list-countries-e-u.md b/docs/examples/kotlin/locale/list-countries-e-u.md index fa5483f..4cf60d9 100644 --- a/docs/examples/kotlin/locale/list-countries-e-u.md +++ b/docs/examples/kotlin/locale/list-countries-e-u.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) diff --git a/docs/examples/kotlin/locale/list-countries-phones.md b/docs/examples/kotlin/locale/list-countries-phones.md index 6aba463..1f8f75b 100644 --- a/docs/examples/kotlin/locale/list-countries-phones.md +++ b/docs/examples/kotlin/locale/list-countries-phones.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) diff --git a/docs/examples/kotlin/locale/list-countries.md b/docs/examples/kotlin/locale/list-countries.md index c58456b..f221fc6 100644 --- a/docs/examples/kotlin/locale/list-countries.md +++ b/docs/examples/kotlin/locale/list-countries.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) diff --git a/docs/examples/kotlin/locale/list-currencies.md b/docs/examples/kotlin/locale/list-currencies.md index 2cf0644..6e5ab0d 100644 --- a/docs/examples/kotlin/locale/list-currencies.md +++ b/docs/examples/kotlin/locale/list-currencies.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) diff --git a/docs/examples/kotlin/locale/list-languages.md b/docs/examples/kotlin/locale/list-languages.md index afc00b1..97a9eb7 100644 --- a/docs/examples/kotlin/locale/list-languages.md +++ b/docs/examples/kotlin/locale/list-languages.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) diff --git a/docs/examples/kotlin/messaging/create-subscriber.md b/docs/examples/kotlin/messaging/create-subscriber.md new file mode 100644 index 0000000..1da3ed3 --- /dev/null +++ b/docs/examples/kotlin/messaging/create-subscriber.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Messaging + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val messaging = Messaging(client) + +val response = messaging.createSubscriber( + topicId = "[TOPIC_ID]", + subscriberId = "[SUBSCRIBER_ID]", + targetId = "[TARGET_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/messaging/delete-subscriber.md b/docs/examples/kotlin/messaging/delete-subscriber.md new file mode 100644 index 0000000..0096de3 --- /dev/null +++ b/docs/examples/kotlin/messaging/delete-subscriber.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Messaging + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val messaging = Messaging(client) + +val response = messaging.deleteSubscriber( + topicId = "[TOPIC_ID]", + subscriberId = "[SUBSCRIBER_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/create-file.md b/docs/examples/kotlin/storage/create-file.md index 7bb79ac..19eae0f 100644 --- a/docs/examples/kotlin/storage/create-file.md +++ b/docs/examples/kotlin/storage/create-file.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.models.InputFile import io.appwrite.services.Storage @@ -12,4 +13,4 @@ val response = storage.createFile( bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]", file = InputFile.fromPath("file.png"), -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/delete-file.md b/docs/examples/kotlin/storage/delete-file.md index 9430d7e..c64e8dc 100644 --- a/docs/examples/kotlin/storage/delete-file.md +++ b/docs/examples/kotlin/storage/delete-file.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) @@ -9,5 +10,5 @@ val storage = Storage(client) val response = storage.deleteFile( bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]" -) + fileId = "[FILE_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file-download.md b/docs/examples/kotlin/storage/get-file-download.md index 85bd22c..07ebcc0 100644 --- a/docs/examples/kotlin/storage/get-file-download.md +++ b/docs/examples/kotlin/storage/get-file-download.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) @@ -7,7 +8,7 @@ val client = Client(context) val storage = Storage(client) -val result = storage.getFileDownload( +val result =storage.getFileDownload( bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]" -) + fileId = "[FILE_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file-preview.md b/docs/examples/kotlin/storage/get-file-preview.md index c5bbdef..b5995ae 100644 --- a/docs/examples/kotlin/storage/get-file-preview.md +++ b/docs/examples/kotlin/storage/get-file-preview.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) @@ -7,7 +8,7 @@ val client = Client(context) val storage = Storage(client) -val result = storage.getFilePreview( +val result =storage.getFilePreview( bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file-view.md b/docs/examples/kotlin/storage/get-file-view.md index 7e7589c..82b55c2 100644 --- a/docs/examples/kotlin/storage/get-file-view.md +++ b/docs/examples/kotlin/storage/get-file-view.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) @@ -7,7 +8,7 @@ val client = Client(context) val storage = Storage(client) -val result = storage.getFileView( +val result =storage.getFileView( bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]" -) + fileId = "[FILE_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file.md b/docs/examples/kotlin/storage/get-file.md index 8fb6e24..9c1abd4 100644 --- a/docs/examples/kotlin/storage/get-file.md +++ b/docs/examples/kotlin/storage/get-file.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) @@ -9,5 +10,5 @@ val storage = Storage(client) val response = storage.getFile( bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]" -) + fileId = "[FILE_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/list-files.md b/docs/examples/kotlin/storage/list-files.md index 191a3cc..575a8b9 100644 --- a/docs/examples/kotlin/storage/list-files.md +++ b/docs/examples/kotlin/storage/list-files.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) @@ -9,4 +10,4 @@ val storage = Storage(client) val response = storage.listFiles( bucketId = "[BUCKET_ID]", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/update-file.md b/docs/examples/kotlin/storage/update-file.md index 005270f..75585fa 100644 --- a/docs/examples/kotlin/storage/update-file.md +++ b/docs/examples/kotlin/storage/update-file.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) @@ -10,4 +11,4 @@ val storage = Storage(client) val response = storage.updateFile( bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/create-membership.md b/docs/examples/kotlin/teams/create-membership.md index 4d1de49..231a991 100644 --- a/docs/examples/kotlin/teams/create-membership.md +++ b/docs/examples/kotlin/teams/create-membership.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -10,4 +11,4 @@ val teams = Teams(client) val response = teams.createMembership( teamId = "[TEAM_ID]", roles = listOf(), -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/create.md b/docs/examples/kotlin/teams/create.md index 5e70bd8..dd1125c 100644 --- a/docs/examples/kotlin/teams/create.md +++ b/docs/examples/kotlin/teams/create.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -10,4 +11,4 @@ val teams = Teams(client) val response = teams.create( teamId = "[TEAM_ID]", name = "[NAME]", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/delete-membership.md b/docs/examples/kotlin/teams/delete-membership.md index 04ef5d3..3f165a7 100644 --- a/docs/examples/kotlin/teams/delete-membership.md +++ b/docs/examples/kotlin/teams/delete-membership.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -9,5 +10,5 @@ val teams = Teams(client) val response = teams.deleteMembership( teamId = "[TEAM_ID]", - membershipId = "[MEMBERSHIP_ID]" -) + membershipId = "[MEMBERSHIP_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/delete.md b/docs/examples/kotlin/teams/delete.md index 7d58960..756e91f 100644 --- a/docs/examples/kotlin/teams/delete.md +++ b/docs/examples/kotlin/teams/delete.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -8,5 +9,5 @@ val client = Client(context) val teams = Teams(client) val response = teams.delete( - teamId = "[TEAM_ID]" -) + teamId = "[TEAM_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/get-membership.md b/docs/examples/kotlin/teams/get-membership.md index 653bd52..7c5d286 100644 --- a/docs/examples/kotlin/teams/get-membership.md +++ b/docs/examples/kotlin/teams/get-membership.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -9,5 +10,5 @@ val teams = Teams(client) val response = teams.getMembership( teamId = "[TEAM_ID]", - membershipId = "[MEMBERSHIP_ID]" -) + membershipId = "[MEMBERSHIP_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/get-prefs.md b/docs/examples/kotlin/teams/get-prefs.md index bfd8f75..2953dcf 100644 --- a/docs/examples/kotlin/teams/get-prefs.md +++ b/docs/examples/kotlin/teams/get-prefs.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -8,5 +9,5 @@ val client = Client(context) val teams = Teams(client) val response = teams.getPrefs( - teamId = "[TEAM_ID]" -) + teamId = "[TEAM_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/get.md b/docs/examples/kotlin/teams/get.md index 72aea07..63cdd05 100644 --- a/docs/examples/kotlin/teams/get.md +++ b/docs/examples/kotlin/teams/get.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -8,5 +9,5 @@ val client = Client(context) val teams = Teams(client) val response = teams.get( - teamId = "[TEAM_ID]" -) + teamId = "[TEAM_ID]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/list-memberships.md b/docs/examples/kotlin/teams/list-memberships.md index 53bd6f3..c82fa52 100644 --- a/docs/examples/kotlin/teams/list-memberships.md +++ b/docs/examples/kotlin/teams/list-memberships.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -9,4 +10,4 @@ val teams = Teams(client) val response = teams.listMemberships( teamId = "[TEAM_ID]", -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/list.md b/docs/examples/kotlin/teams/list.md index 57c5fe8..f0f4af2 100644 --- a/docs/examples/kotlin/teams/list.md +++ b/docs/examples/kotlin/teams/list.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -8,4 +9,4 @@ val client = Client(context) val teams = Teams(client) val response = teams.list( -) +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-membership-status.md b/docs/examples/kotlin/teams/update-membership-status.md index 33de006..50f04a2 100644 --- a/docs/examples/kotlin/teams/update-membership-status.md +++ b/docs/examples/kotlin/teams/update-membership-status.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -11,5 +12,5 @@ val response = teams.updateMembershipStatus( teamId = "[TEAM_ID]", membershipId = "[MEMBERSHIP_ID]", userId = "[USER_ID]", - secret = "[SECRET]" -) + secret = "[SECRET]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-membership.md b/docs/examples/kotlin/teams/update-membership.md index 40005ed..9990cc4 100644 --- a/docs/examples/kotlin/teams/update-membership.md +++ b/docs/examples/kotlin/teams/update-membership.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -10,5 +11,5 @@ val teams = Teams(client) val response = teams.updateMembership( teamId = "[TEAM_ID]", membershipId = "[MEMBERSHIP_ID]", - roles = listOf() -) + roles = listOf(), +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-name.md b/docs/examples/kotlin/teams/update-name.md index 59c6812..1332fe1 100644 --- a/docs/examples/kotlin/teams/update-name.md +++ b/docs/examples/kotlin/teams/update-name.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -9,5 +10,5 @@ val teams = Teams(client) val response = teams.updateName( teamId = "[TEAM_ID]", - name = "[NAME]" -) + name = "[NAME]", +) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-prefs.md b/docs/examples/kotlin/teams/update-prefs.md index 6a89ac7..5f77c6c 100644 --- a/docs/examples/kotlin/teams/update-prefs.md +++ b/docs/examples/kotlin/teams/update-prefs.md @@ -1,4 +1,5 @@ import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) @@ -9,5 +10,5 @@ val teams = Teams(client) val response = teams.updatePrefs( teamId = "[TEAM_ID]", - prefs = mapOf( "a" to "b" ) -) + prefs = mapOf( "a" to "b" ), +) \ No newline at end of file diff --git a/example-java/.gitignore b/example-java/.gitignore deleted file mode 100644 index 42afabf..0000000 --- a/example-java/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build \ No newline at end of file diff --git a/example-java/build.gradle b/example-java/build.gradle deleted file mode 100644 index 774d3ba..0000000 --- a/example-java/build.gradle +++ /dev/null @@ -1,39 +0,0 @@ -plugins { - id 'com.android.application' -} - -android { - compileSdkVersion 33 - - defaultConfig { - applicationId "io.appwrite.example_java" - minSdkVersion 23 - targetSdkVersion 33 - versionCode 1 - versionName "1.0" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } -} - -dependencies { - implementation project(path: ':library') - - implementation 'androidx.appcompat:appcompat:1.6.0' - implementation 'com.google.android.material:material:1.8.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' -} \ No newline at end of file diff --git a/example-java/src/main/AndroidManifest.xml b/example-java/src/main/AndroidManifest.xml deleted file mode 100644 index 0276c9c..0000000 --- a/example-java/src/main/AndroidManifest.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file 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 deleted file mode 100644 index 04f46b3..0000000 --- a/example-java/src/main/java/io/appwrite/example_java/MainActivity.java +++ /dev/null @@ -1,34 +0,0 @@ -package io.appwrite.example_java; - -import android.os.Bundle; -import android.util.Log; - -import androidx.appcompat.app.AppCompatActivity; - -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -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://demo.appwrite.io/v1") - .setProject("6070749e6acd4"); - - Account account = new Account(client); - - 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-java/src/main/res/drawable/ic_launcher_background.xml b/example-java/src/main/res/drawable/ic_launcher_background.xml deleted file mode 100644 index 07d5da9..0000000 --- a/example-java/src/main/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example-java/src/main/res/drawable/ic_launcher_foreground.xml b/example-java/src/main/res/drawable/ic_launcher_foreground.xml deleted file mode 100644 index 2b068d1..0000000 --- a/example-java/src/main/res/drawable/ic_launcher_foreground.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/example-java/src/main/res/layout/activity_main.xml b/example-java/src/main/res/layout/activity_main.xml deleted file mode 100644 index 4fc2444..0000000 --- a/example-java/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/example-java/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/example-java/src/main/res/mipmap-anydpi-v26/ic_launcher.xml deleted file mode 100644 index eca70cf..0000000 --- a/example-java/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/example-java/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/example-java/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml deleted file mode 100644 index eca70cf..0000000 --- a/example-java/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/example-java/src/main/res/values/colors.xml b/example-java/src/main/res/values/colors.xml deleted file mode 100644 index f8c6127..0000000 --- a/example-java/src/main/res/values/colors.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - #FFBB86FC - #FF6200EE - #FF3700B3 - #FF03DAC5 - #FF018786 - #FF000000 - #FFFFFFFF - \ No newline at end of file diff --git a/example-java/src/main/res/values/strings.xml b/example-java/src/main/res/values/strings.xml deleted file mode 100644 index 71e50b3..0000000 --- a/example-java/src/main/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - Example Java - \ No newline at end of file diff --git a/example-java/src/main/res/values/themes.xml b/example-java/src/main/res/values/themes.xml deleted file mode 100644 index dde245d..0000000 --- a/example-java/src/main/res/values/themes.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - \ No newline at end of file diff --git a/example/build.gradle b/example/build.gradle index 62a34ed..ff37072 100644 --- a/example/build.gradle +++ b/example/build.gradle @@ -1,15 +1,18 @@ plugins { id 'com.android.application' id 'kotlin-android' + id 'kotlin-kapt' } android { - compileSdkVersion 33 + namespace "io.appwrite.android" + + compileSdkVersion 34 defaultConfig { applicationId "io.appwrite.android" minSdkVersion 21 - targetSdkVersion 33 + targetSdkVersion 34 versionCode 1 versionName "1.0" @@ -36,23 +39,27 @@ android { } dependencies { - implementation project(path: ':library') - - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.core:core-ktx:1.9.0' - implementation 'androidx.appcompat:appcompat:1.6.0' - implementation 'com.google.android.material:material:1.8.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3' - implementation "androidx.fragment:fragment-ktx:1.5.5" - implementation 'androidx.navigation:navigation-ui-ktx:2.5.3' - implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1' - implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1' - implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3' - implementation 'androidx.navigation:navigation-ui-ktx:2.5.3' - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1" - testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + implementation(project(path: ':library')) + + implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version") + implementation("androidx.core:core-ktx:1.12.0") + implementation("androidx.appcompat:appcompat:1.6.1") + implementation("com.google.android.material:material:1.11.0") + implementation("androidx.constraintlayout:constraintlayout:2.1.4") + implementation("androidx.navigation:navigation-fragment-ktx:2.7.6") + implementation("androidx.fragment:fragment-ktx:1.6.2") + implementation("androidx.navigation:navigation-ui-ktx:2.7.6") + implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.7.0") + implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0") + implementation("androidx.navigation:navigation-fragment-ktx:2.7.6") + implementation("androidx.navigation:navigation-ui-ktx:2.7.6") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1") + + implementation(platform("com.google.firebase:firebase-bom:32.7.0")) + implementation("com.google.firebase:firebase-messaging") + + testImplementation("junit:junit:4.13.2") + androidTestImplementation("androidx.test.ext:junit:1.1.5") + androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") } \ No newline at end of file diff --git a/example/src/main/AndroidManifest.xml b/example/src/main/AndroidManifest.xml index e3c2421..5c2e7b0 100644 --- a/example/src/main/AndroidManifest.xml +++ b/example/src/main/AndroidManifest.xml @@ -3,12 +3,14 @@ package="io.appwrite.android"> + android:theme="@style/Theme.AppwriteAndroidSDK" + android:usesCleartextTraffic="true"> + @@ -24,6 +26,13 @@ + + + + + + + \ No newline at end of file diff --git a/example/src/main/java/io/appwrite/android/services/MessagingService.kt b/example/src/main/java/io/appwrite/android/services/MessagingService.kt new file mode 100644 index 0000000..8470c66 --- /dev/null +++ b/example/src/main/java/io/appwrite/android/services/MessagingService.kt @@ -0,0 +1,37 @@ +package io.appwrite.android.services + +import com.google.firebase.messaging.FirebaseMessagingService +import io.appwrite.ID +import io.appwrite.services.Account +import kotlinx.coroutines.runBlocking + +class MessagingService : FirebaseMessagingService() { + + companion object { + var account: Account? = null + } + + override fun onNewToken(token: String) { + super.onNewToken(token) + + val prefs = getSharedPreferences("example", MODE_PRIVATE) + + prefs.edit().putString("fcmToken", token).apply() + + if (account == null) { + return + } + + val targetId = prefs.getString("targetId", null) + + runBlocking { + if (targetId == null) { + val target = account!!.createPushTarget(ID.unique(), token) + + prefs.edit().putString("targetId", target.id).apply() + } else { + account!!.updatePushTarget(targetId, token) + } + } + } +} \ No newline at end of file diff --git a/example/src/main/java/io/appwrite/android/ui/accounts/AccountsFragment.kt b/example/src/main/java/io/appwrite/android/ui/accounts/AccountsFragment.kt index a31cced..40c40b5 100644 --- a/example/src/main/java/io/appwrite/android/ui/accounts/AccountsFragment.kt +++ b/example/src/main/java/io/appwrite/android/ui/accounts/AccountsFragment.kt @@ -1,5 +1,6 @@ package io.appwrite.android.ui.accounts +import android.content.Context import android.os.Bundle import android.view.LayoutInflater import android.view.View @@ -9,7 +10,6 @@ import androidx.activity.ComponentActivity import androidx.databinding.DataBindingUtil import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels -import androidx.lifecycle.Observer import io.appwrite.android.R import io.appwrite.android.databinding.FragmentAccountBinding @@ -31,37 +31,54 @@ class AccountsFragment : Fragment() { false ) binding.lifecycleOwner = viewLifecycleOwner + binding.login.setOnClickListener{ - viewModel.onLogin(binding.email.text, binding.password.text) + viewModel.onLogin( + binding.email.text.toString(), + binding.password.text.toString(), + context + ?.getSharedPreferences("example", Context.MODE_PRIVATE) + ?.getString("fcmToken", null) ?: "" + ) } - binding.signup.setOnClickListener{ - viewModel.onSignup(binding.email.text, binding.password.text, binding.name.text) + viewModel.onSignup( + binding.email.text.toString(), + binding.password.text.toString(), + binding.name.text.toString() + ) } - binding.getUser.setOnClickListener{ viewModel.getUser() } - binding.oAuth.setOnClickListener{ viewModel.oAuthLogin(activity as ComponentActivity) } - binding.logout.setOnClickListener{ viewModel.logout() } - viewModel.error.observe(viewLifecycleOwner, Observer { event -> - event?.getContentIfNotHandled()?.let { // Only proceed if the event has never been handled - Toast.makeText(requireContext(), it.message , Toast.LENGTH_SHORT).show() + viewModel.error.observe(viewLifecycleOwner) { event -> + event?.getContentIfNotHandled()?.let { + Toast.makeText(requireContext(), it.message, Toast.LENGTH_SHORT).show() } - }) + } - viewModel.response.observe(viewLifecycleOwner, Observer { event -> + viewModel.response.observe(viewLifecycleOwner) { event -> event?.getContentIfNotHandled()?.let { binding.responseTV.setText(it) } - }) + } + + viewModel.target.observe(viewLifecycleOwner) { event -> + event?.getContentIfNotHandled()?.let { + context + ?.getSharedPreferences("example", Context.MODE_PRIVATE) + ?.edit() + ?.putString("targetId", it.id) + ?.apply() + } + } return binding.root } 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 ede86d3..f53113d 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 @@ -1,35 +1,55 @@ package io.appwrite.android.ui.accounts -import android.text.Editable import androidx.activity.ComponentActivity import androidx.lifecycle.* +import io.appwrite.ID +import io.appwrite.android.services.MessagingService import io.appwrite.android.utils.Client.client import io.appwrite.android.utils.Event +import io.appwrite.enums.OAuthProvider import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.toJson +import io.appwrite.models.Target import io.appwrite.services.Account import kotlinx.coroutines.launch class AccountsViewModel : ViewModel() { - private val _error = MutableLiveData>().apply { - value = null - } + private val _error = MutableLiveData>().apply { value = null } val error: LiveData> = _error - private val _response = MutableLiveData>().apply { - value = null - } + private val _response = MutableLiveData>().apply { value = null } val response: LiveData> = _response - private val accountService by lazy { - Account(client) + private val _target = MutableLiveData>().apply { value = null } + val target: LiveData> = _target + + private val account by lazy { + val account = Account(client) + + MessagingService.account = account + + account } - fun onLogin(email: Editable, password: Editable) { + fun onLogin( + email: String, + password: String, + token: String?, + ) { viewModelScope.launch { try { - val session = accountService.createEmailSession(email.toString(), password.toString()) + val session = account.createEmailPasswordSession( + email, + password + ) + + if (token != null) { + val target = account.createPushTarget(ID.unique(), token) + + _target.postValue(Event(target)) + } + _response.postValue(Event(session.toJson())) } catch (e: AppwriteException) { _error.postValue(Event(e)) @@ -38,11 +58,15 @@ class AccountsViewModel : ViewModel() { } - fun onSignup(email: Editable, password: Editable, name: Editable) { + fun onSignup(email: String, password: String, name: String) { viewModelScope.launch { try { - val user = - accountService.create(email.toString(), password.toString(), name.toString()) + val user = account.create( + ID.unique(), + email, + password, + name + ) _response.postValue(Event(user.toJson())) } catch (e: AppwriteException) { _error.postValue(Event(e)) @@ -54,9 +78,9 @@ class AccountsViewModel : ViewModel() { fun oAuthLogin(activity: ComponentActivity) { viewModelScope.launch { try { - accountService.createOAuth2Session( + account.createOAuth2Session( activity, - "facebook", + OAuthProvider.FACEBOOK, "appwrite-callback-6070749e6acd4://demo.appwrite.io/auth/oauth2/success", "appwrite-callback-6070749e6acd4://demo.appwrite.io/auth/oauth2/failure" ) @@ -71,8 +95,8 @@ class AccountsViewModel : ViewModel() { fun getUser() { viewModelScope.launch { try { - val account = accountService.get() - _response.postValue(Event(account.toJson())) + val user = account.get() + _response.postValue(Event(user.toJson())) } catch (e: AppwriteException) { _error.postValue(Event(e)) } @@ -82,7 +106,7 @@ class AccountsViewModel : ViewModel() { fun logout() { viewModelScope.launch { try { - val result = accountService.deleteSession("current") + val result = account.deleteSession("current") _response.postValue(Event(result.toJson())) } catch (e: AppwriteException) { _error.postValue(Event(e)) diff --git a/example/src/main/java/io/appwrite/android/utils/Client.kt b/example/src/main/java/io/appwrite/android/utils/Client.kt index 66ce681..027b718 100644 --- a/example/src/main/java/io/appwrite/android/utils/Client.kt +++ b/example/src/main/java/io/appwrite/android/utils/Client.kt @@ -8,13 +8,8 @@ object Client { fun create(context: Context) { client = Client(context) - .setEndpoint("https://demo.appwrite.io/v1") - .setProject("6070749e6acd4") - - /* Useful when testing locally */ -// client = Client(context) -// .setEndpoint("https://192.168.1.35/v1") -// .setProject("60bdbc911784e") -// .setSelfSigned(true) + .setEndpoint("http://192.168.4.24/v1") + .setProject("65a8e2b4632c04b1f5da") + .setSelfSigned(true) } } \ No newline at end of file diff --git a/example/src/main/res/layout/fragment_account.xml b/example/src/main/res/layout/fragment_account.xml index 2fb34c9..4173be1 100644 --- a/example/src/main/res/layout/fragment_account.xml +++ b/example/src/main/res/layout/fragment_account.xml @@ -57,6 +57,7 @@ android:layout_height="wrap_content" android:layout_marginTop="16dp" android:hint="name" + android:text="Tester" android:inputType="text" app:layout_constraintStart_toStartOf="@id/password" app:layout_constraintTop_toBottomOf="@id/password" /> diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 85e684f..ebd754f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Tue Jun 01 15:55:54 IST 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/library/build.gradle b/library/build.gradle index 3dc0138..b741c76 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -22,8 +22,14 @@ ext { version PUBLISH_VERSION android { + namespace PUBLISH_GROUP_ID + compileSdkVersion(34) + buildFeatures { + buildConfig true + } + defaultConfig { minSdkVersion(21) targetSdkVersion(34) @@ -43,10 +49,6 @@ android { ) } } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - } kotlinOptions { jvmTarget = "1.8" } @@ -54,27 +56,28 @@ android { dependencies { implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version") - api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1") - api("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1") + api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1") + api("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1") api(platform("com.squareup.okhttp3:okhttp-bom:4.12.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.9.0") + implementation("com.google.code.gson:gson:2.10.1") - implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.5.1") - implementation("androidx.lifecycle:lifecycle-common-java8:2.5.1") - implementation("androidx.appcompat:appcompat:1.6.0") - implementation("androidx.fragment:fragment-ktx:1.5.5") - implementation("androidx.activity:activity-ktx:1.6.1") - implementation("androidx.browser:browser:1.4.0") + implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0") + implementation("androidx.lifecycle:lifecycle-common-java8:2.7.0") + implementation("androidx.appcompat:appcompat:1.6.1") + implementation("androidx.fragment:fragment-ktx:1.6.2") + implementation("androidx.activity:activity-ktx:1.8.2") + implementation("androidx.browser:browser:1.7.0") + implementation("androidx.core:core-ktx:1.12.0") - testImplementation 'junit:junit:4.13.2' - testImplementation "androidx.test.ext:junit-ktx:1.1.5" - testImplementation "androidx.test:core-ktx:1.5.0" - testImplementation "org.robolectric:robolectric:4.5.1" - testApi("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.1") + testImplementation("junit:junit:4.13.2") + testImplementation("androidx.test.ext:junit-ktx:1.1.5") + testImplementation("androidx.test:core-ktx:1.5.0") + testImplementation("org.robolectric:robolectric:4.11.1") + testApi("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.1") } apply from: "${rootProject.projectDir}/scripts/publish-module.gradle" diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml index b0ab63a..899321d 100644 --- a/library/src/main/AndroidManifest.xml +++ b/library/src/main/AndroidManifest.xml @@ -1,8 +1,7 @@ - + - + + \ 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 94f82b6..f04ea23 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -1,14 +1,13 @@ package io.appwrite import android.content.Context +import android.content.Intent import android.content.pm.PackageManager -import com.google.gson.GsonBuilder -import com.google.gson.reflect.TypeToken -import io.appwrite.appwrite.BuildConfig +import io.appwrite.cookies.ListenableCookieJar import io.appwrite.cookies.stores.SharedPreferencesCookieStore import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.fromJson -import io.appwrite.json.PreciseNumberAdapter +import io.appwrite.extensions.toJson import io.appwrite.models.InputFile import io.appwrite.models.UploadProgress import kotlinx.coroutines.CoroutineScope @@ -30,7 +29,6 @@ import java.net.CookieManager import java.net.CookiePolicy import java.security.SecureRandom import java.security.cert.X509Certificate -import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLContext import javax.net.ssl.SSLSocketFactory import javax.net.ssl.TrustManager @@ -40,13 +38,15 @@ import kotlin.coroutines.resume class Client @JvmOverloads constructor( context: Context, - var endPoint: String = "https://HOSTNAME/v1", - var endPointRealtime: String? = null, + var endpoint: String = "https://cloud.appwrite.io/v1", + var endpointRealtime: String? = null, private var selfSigned: Boolean = false ) : CoroutineScope { companion object { - const val CHUNK_SIZE = 5*1024*1024; // 5MB + internal const val CHUNK_SIZE = 5*1024*1024; // 5MB + internal const val GLOBAL_PREFS = "io.appwrite" + internal const val COOKIE_PREFS = "myCookie" } override val coroutineContext: CoroutineContext @@ -54,21 +54,16 @@ class Client @JvmOverloads constructor( private val job = Job() - private val gson = GsonBuilder().registerTypeAdapter( - object : TypeToken>(){}.type, - PreciseNumberAdapter() - ).create() + internal lateinit var http: OkHttpClient - lateinit var http: OkHttpClient - - private val headers: MutableMap + internal val headers: MutableMap val config: MutableMap - private val cookieJar = CookieManager( - SharedPreferencesCookieStore(context, "myCookie"), + internal val cookieJar = ListenableCookieJar(CookieManager( + SharedPreferencesCookieStore(context.getSharedPreferences(COOKIE_PREFS, Context.MODE_PRIVATE)), CookiePolicy.ACCEPT_ALL - ) + )) private val appVersion by lazy { try { @@ -88,7 +83,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "4.0.1", + "x-sdk-version" to "5.0.0-rc.2", "x-appwrite-response-format" to "1.4.0" ) config = mutableMapOf() @@ -139,6 +134,21 @@ class Client @JvmOverloads constructor( return this } + /** + * Set Session + * + * The user session to authenticate with + * + * @param {string} session + * + * @return this + */ + fun setSession(value: String): Client { + config["session"] = value + addHeader("x-appwrite-session", value) + return this + } + /** * Set self Signed * @@ -151,7 +161,7 @@ class Client @JvmOverloads constructor( val builder = OkHttpClient() .newBuilder() - .cookieJar(JavaNetCookieJar(cookieJar)) + .cookieJar(cookieJar) if (!selfSigned) { http = builder.build() @@ -181,7 +191,7 @@ class Client @JvmOverloads constructor( // Create an ssl socket factory with our all-trusting manager val sslSocketFactory: SSLSocketFactory = sslContext.socketFactory builder.sslSocketFactory(sslSocketFactory, trustAllCerts[0] as X509TrustManager) - builder.hostnameVerifier(HostnameVerifier { _, _ -> true }) + builder.hostnameVerifier { _, _ -> true } http = builder.build() } catch (e: Exception) { @@ -198,11 +208,11 @@ class Client @JvmOverloads constructor( * * @return this */ - fun setEndpoint(endPoint: String): Client { - this.endPoint = endPoint + fun setEndpoint(endpoint: String): Client { + this.endpoint = endpoint - if (this.endPointRealtime == null && endPoint.startsWith("http")) { - this.endPointRealtime = endPoint.replaceFirst("http", "ws") + if (this.endpointRealtime == null && endpoint.startsWith("http")) { + this.endpointRealtime = endpoint.replaceFirst("http", "ws") } return this @@ -215,8 +225,8 @@ class Client @JvmOverloads constructor( * * @return this */ - fun setEndpointRealtime(endPoint: String): Client { - this.endPointRealtime = endPoint + fun setEndpointRealtime(endpoint: String): Client { + this.endpointRealtime = endpoint return this } @@ -258,7 +268,7 @@ class Client @JvmOverloads constructor( .addAll(headers.toHeaders()) .build() - val httpBuilder = (endPoint + path).toHttpUrl().newBuilder() + val httpBuilder = (endpoint + path).toHttpUrl().newBuilder() if ("GET" == method) { filteredParams.forEach { @@ -313,7 +323,8 @@ class Client @JvmOverloads constructor( } builder.build() } else { - gson.toJson(filteredParams) + filteredParams + .toJson() .toRequestBody("application/json".toMediaType()) } @@ -436,14 +447,14 @@ class Client @JvmOverloads constructor( ) offset += CHUNK_SIZE - headers["x-appwrite-id"] = result!!["\$id"].toString() + headers["x-appwrite-id"] = result["\$id"].toString() onProgress?.invoke( UploadProgress( - id = result!!["\$id"].toString(), + id = result["\$id"].toString(), progress = offset.coerceAtMost(size).toDouble() / size * 100, sizeUploaded = offset.coerceAtMost(size), - chunksTotal = result!!["chunksTotal"].toString().toInt(), - chunksUploaded = result!!["chunksUploaded"].toString().toInt(), + chunksTotal = result["chunksTotal"].toString().toInt(), + chunksUploaded = result["chunksUploaded"].toString().toInt(), ) ) } @@ -483,10 +494,8 @@ class Client @JvmOverloads constructor( .use(BufferedReader::readText) val error = if (response.headers["content-type"]?.contains("application/json") == true) { - val map = gson.fromJson>( - body, - object : TypeToken>(){}.type - ) + val map = body.fromJson>() + AppwriteException( map["message"] as? String ?: "", (map["code"] as Number).toInt(), @@ -525,10 +534,9 @@ class Client @JvmOverloads constructor( it.resume(true as T) return } - val map = gson.fromJson( - body, - object : TypeToken(){}.type - ) + + val map = body.fromJson() + it.resume( converter?.invoke(map) ?: map as T ) diff --git a/library/src/main/java/io/appwrite/OS.kt b/library/src/main/java/io/appwrite/OS.kt new file mode 100644 index 0000000..7828f02 --- /dev/null +++ b/library/src/main/java/io/appwrite/OS.kt @@ -0,0 +1,52 @@ +package io.appwrite + +import android.Manifest +import android.content.pm.PackageManager +import android.os.Build +import androidx.activity.result.contract.ActivityResultContracts +import androidx.appcompat.app.AppCompatActivity +import androidx.core.content.ContextCompat + +object OS { + fun requestPermission( + activity: AppCompatActivity, + permission: String, + onGranted: () -> Unit = {}, + onDenied: () -> Unit = {}, + onShowRationale: () -> Unit = {}, + ) { + if ( + Build.VERSION.SDK_INT < Build.VERSION_CODES.M || + (permission == Manifest.permission.POST_NOTIFICATIONS && Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) + ) { + onGranted() + return + } + + if (ContextCompat.checkSelfPermission( + activity, + permission + ) == PackageManager.PERMISSION_GRANTED + ) { + onGranted() + } else if (activity.shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS)) { + onShowRationale() + } else { + requestPermissionLauncher(activity, onGranted, onDenied).launch(permission) + } + } + + private fun requestPermissionLauncher( + activity: AppCompatActivity, + onGranted: () -> Unit, + onDenied: () -> Unit, + ) = activity.registerForActivityResult( + ActivityResultContracts.RequestPermission(), + ) { isGranted: Boolean -> + if (isGranted) { + onGranted() + } else { + onDenied() + } + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/Query.kt b/library/src/main/java/io/appwrite/Query.kt index 7957865..6efbb11 100644 --- a/library/src/main/java/io/appwrite/Query.kt +++ b/library/src/main/java/io/appwrite/Query.kt @@ -1,60 +1,65 @@ package io.appwrite -class Query { - companion object { - fun equal(attribute: String, value: Any) = addQuery(attribute, "equal", value) +import io.appwrite.extensions.toJson +import io.appwrite.extensions.fromJson - fun notEqual(attribute: String, value: Any) = Query.addQuery(attribute, "notEqual", value) +class Query( + val method: String, + val attribute: String? = null, + val values: List? = null, +) { + override fun toString() = this.toJson() - fun lessThan(attribute: String, value: Any) = Query.addQuery(attribute, "lessThan", value) + companion object { + fun equal(attribute: String, value: Any) = Query("equal", attribute, parseValue(value)).toJson() - fun lessThanEqual(attribute: String, value: Any) = Query.addQuery(attribute, "lessThanEqual", value) + fun notEqual(attribute: String, value: Any) = Query("notEqual", attribute, parseValue(value)).toJson() - fun greaterThan(attribute: String, value: Any) = Query.addQuery(attribute, "greaterThan", value) + fun lessThan(attribute: String, value: Any) = Query("lessThan", attribute, parseValue(value)).toJson() - fun greaterThanEqual(attribute: String, value: Any) = Query.addQuery(attribute, "greaterThanEqual", value) - - fun search(attribute: String, value: String) = Query.addQuery(attribute, "search", value) + fun lessThanEqual(attribute: String, value: Any) = Query("lessThanEqual", attribute, parseValue(value)).toJson() - fun isNull(attribute: String) = "isNull(\"${attribute}\")" + fun greaterThan(attribute: String, value: Any) = Query("greaterThan", attribute, parseValue(value)).toJson() - fun isNotNull(attribute: String) = "isNotNull(\"${attribute}\")" + fun greaterThanEqual(attribute: String, value: Any) = Query("greaterThanEqual", attribute, parseValue(value)).toJson() - fun between(attribute: String, start: Int, end: Int) = "between(\"${attribute}\", ${start}, ${end})" + fun search(attribute: String, value: String) = Query("search", attribute, listOf(value)).toJson() - fun between(attribute: String, start: Double, end: Double) = "between(\"${attribute}\", ${start}, ${end})" + fun isNull(attribute: String) = Query("isNull", attribute).toJson() - fun between(attribute: String, start: String, end: String) = "between(\"${attribute}\", \"${start}\", \"${end}\")" + fun isNotNull(attribute: String) = Query("isNotNull", attribute).toJson() - fun startsWith(attribute: String, value: String) = Query.addQuery(attribute, "startsWith", value) + fun between(attribute: String, start: Any, end: Any) = Query("between", attribute, listOf(start, end)).toJson() - fun endsWith(attribute: String, value: String) = Query.addQuery(attribute, "endsWith", value) + fun startsWith(attribute: String, value: String) = Query("startsWith", attribute, listOf(value)).toJson() - fun select(attributes: List) = "select([${attributes.joinToString(",") { "\"$it\"" }}])" + fun endsWith(attribute: String, value: String) = Query("endsWith", attribute, listOf(value)).toJson() - fun orderAsc(attribute: String) = "orderAsc(\"${attribute}\")" + fun select(attributes: List) = Query("select", null, attributes).toJson() - fun orderDesc(attribute: String) = "orderDesc(\"${attribute}\")" + fun orderAsc(attribute: String) = Query("orderAsc", attribute).toJson() - fun cursorBefore(documentId: String) = "cursorBefore(\"${documentId}\")" + fun orderDesc(attribute: String) = Query("orderDesc", attribute).toJson() - fun cursorAfter(documentId: String) = "cursorAfter(\"${documentId}\")" + fun cursorBefore(documentId: String) = Query("cursorBefore", null, listOf(documentId)).toJson() - fun limit(limit: Int) = "limit(${limit})" + fun cursorAfter(documentId: String) = Query("cursorAfter", null, listOf(documentId)).toJson() - fun offset(offset: Int) = "offset(${offset})" + fun limit(limit: Int) = Query("limit", null, listOf(limit)).toJson() - private fun addQuery(attribute: String, method: String, value: Any): String { - return when (value) { - is List<*> -> "${method}(\"${attribute}\", [${value.map{it -> parseValues(it!!)}.joinToString(",")}])" - else -> "${method}(\"${attribute}\", [${Query.parseValues(value)}])" - } - } - private fun parseValues(value: Any): String { - return when (value) { - is String -> "\"${value}\"" - else -> "${value}" - } + fun offset(offset: Int) = Query("offset", null, listOf(offset)).toJson() + + fun contains(attribute: String, value: Any) = Query("contains", attribute, parseValue(value)).toJson() + + fun or(queries: List) = Query("or", null, queries.map { it.fromJson() }).toJson() + + fun and(queries: List) = Query("and", null, queries.map { it.fromJson() }).toJson() + + private fun parseValue(value: Any): List { + return when (value) { + is List<*> -> value as List + else -> listOf(value) + } + } } - } -} +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Service.kt b/library/src/main/java/io/appwrite/Service.kt similarity index 71% rename from library/src/main/java/io/appwrite/services/Service.kt rename to library/src/main/java/io/appwrite/Service.kt index 6a00fb1..8efdb9b 100644 --- a/library/src/main/java/io/appwrite/services/Service.kt +++ b/library/src/main/java/io/appwrite/Service.kt @@ -1,4 +1,4 @@ -package io.appwrite.services +package io.appwrite import io.appwrite.Client diff --git a/library/src/main/java/io/appwrite/cookies/ListenableCookieJar.kt b/library/src/main/java/io/appwrite/cookies/ListenableCookieJar.kt new file mode 100644 index 0000000..863eb42 --- /dev/null +++ b/library/src/main/java/io/appwrite/cookies/ListenableCookieJar.kt @@ -0,0 +1,119 @@ +package io.appwrite.cookies + +import okhttp3.Cookie +import okhttp3.CookieJar +import okhttp3.HttpUrl +import okhttp3.internal.cookieToString +import okhttp3.internal.delimiterOffset +import okhttp3.internal.platform.Platform +import okhttp3.internal.trimSubstring +import java.io.IOException +import java.net.CookieHandler +import java.net.HttpCookie +import java.util.Collections + +typealias CookieListener = (existing: List, new: List) -> Unit + +class ListenableCookieJar(private val cookieHandler: CookieHandler) : CookieJar { + + private val listeners: MutableMap = mutableMapOf() + + fun onSave(key: String, listener: CookieListener) { + listeners[key.hashCode()] = listener + } + + override fun saveFromResponse(url: HttpUrl, cookies: List) { + val existingCookies = loadForRequest(url) + + listeners.values.forEach { it(existingCookies, cookies) } + + val cookieStrings = mutableListOf() + for (cookie in cookies) { + cookieStrings.add(cookieToString(cookie, true)) + } + val multimap = mapOf("Set-Cookie" to cookieStrings) + try { + cookieHandler.put(url.toUri(), multimap) + } catch (e: IOException) { + Platform.get().log( + "Saving cookies failed for " + url.resolve("/...")!!, + Platform.WARN, e + ) + } + } + + override fun loadForRequest(url: HttpUrl): List { + val cookieHeaders = try { + cookieHandler.get(url.toUri(), emptyMap>()) + } catch (e: IOException) { + Platform.get().log( + "Loading cookies failed for " + url.resolve("/...")!!, + Platform.WARN, e + ) + return emptyList() + } + + var cookies: MutableList? = null + for ((key, value) in cookieHeaders) { + if (("Cookie".equals(key, ignoreCase = true) || "Cookie2".equals( + key, + ignoreCase = true + )) && + value.isNotEmpty() + ) { + for (header in value) { + if (cookies == null) cookies = mutableListOf() + cookies.addAll(decodeHeaderAsJavaNetCookies(url, header)) + } + } + } + + return if (cookies != null) { + Collections.unmodifiableList(cookies) + } else { + emptyList() + } + } + + /** + * Convert a request header to OkHttp's cookies via [HttpCookie]. That extra step handles + * multiple cookies in a single request header, which [Cookie.parse] doesn't support. + */ + private fun decodeHeaderAsJavaNetCookies(url: HttpUrl, header: String): List { + val result = mutableListOf() + var pos = 0 + val limit = header.length + var pairEnd: Int + while (pos < limit) { + pairEnd = header.delimiterOffset(";,", pos, limit) + val equalsSign = header.delimiterOffset('=', pos, pairEnd) + val name = header.trimSubstring(pos, equalsSign) + if (name.startsWith("$")) { + pos = pairEnd + 1 + continue + } + + // We have either name=value or just a name. + var value = if (equalsSign < pairEnd) { + header.trimSubstring(equalsSign + 1, pairEnd) + } else { + "" + } + + // If the value is "quoted", drop the quotes. + if (value.startsWith("\"") && value.endsWith("\"")) { + value = value.substring(1, value.length - 1) + } + + result.add( + Cookie.Builder() + .name(name) + .value(value) + .domain(url.host) + .build() + ) + pos = pairEnd + 1 + } + return result + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/cookies/stores/InMemoryCookieStore.kt b/library/src/main/java/io/appwrite/cookies/stores/InMemoryCookieStore.kt index 7de9ec9..1f2b536 100644 --- a/library/src/main/java/io/appwrite/cookies/stores/InMemoryCookieStore.kt +++ b/library/src/main/java/io/appwrite/cookies/stores/InMemoryCookieStore.kt @@ -6,10 +6,9 @@ import java.net.CookieStore import java.net.HttpCookie import java.net.URI import java.net.URISyntaxException -import java.util.Collections import java.util.concurrent.locks.ReentrantLock -open class InMemoryCookieStore(private val name: String) : CookieStore { +open class InMemoryCookieStore : CookieStore { internal val uriIndex = mutableMapOf>() private val lock = ReentrantLock(false) @@ -29,7 +28,7 @@ open class InMemoryCookieStore(private val name: String) : CookieStore { if (cookie == null) { Log.i( javaClass.simpleName, - "tried to add null cookie in cookie store named $name. Doing nothing." + "Tried to add null cookie in cookie store. Doing nothing." ) return } @@ -37,7 +36,7 @@ open class InMemoryCookieStore(private val name: String) : CookieStore { if (uri == null) { Log.i( javaClass.simpleName, - "tried to add null URI in cookie store named $name. Doing nothing." + "Tried to add null URI in cookie store. Doing nothing." ) return } @@ -89,7 +88,7 @@ open class InMemoryCookieStore(private val name: String) : CookieStore { if (cookie == null) { Log.i( javaClass.simpleName, - "tried to remove null cookie from cookie store named $name. Doing nothing." + "Tried to remove null cookie from cookie store. Doing nothing." ) return true } @@ -97,7 +96,7 @@ open class InMemoryCookieStore(private val name: String) : CookieStore { if (uri == null) { Log.i( javaClass.simpleName, - "tried to remove null URI from cookie store named $name. Doing nothing." + "Tried to remove null URI from cookie store. Doing nothing." ) return true } @@ -122,7 +121,7 @@ open class InMemoryCookieStore(private val name: String) : CookieStore { if (uri == null) { Log.i( javaClass.simpleName, - "getting cookies from cookie store named $name for null URI results in empty list" + "Getting cookies from cookie store for null URI results in empty list" ) return emptyList() } diff --git a/library/src/main/java/io/appwrite/cookies/stores/SharedPreferencesCookieStore.kt b/library/src/main/java/io/appwrite/cookies/stores/SharedPreferencesCookieStore.kt index 83c677d..0c0b760 100644 --- a/library/src/main/java/io/appwrite/cookies/stores/SharedPreferencesCookieStore.kt +++ b/library/src/main/java/io/appwrite/cookies/stores/SharedPreferencesCookieStore.kt @@ -1,7 +1,7 @@ package io.appwrite.cookies.stores import io.appwrite.cookies.InternalCookie -import android.content.Context +import android.content.SharedPreferences import android.os.Build import android.util.Log import com.google.gson.Gson @@ -10,11 +10,9 @@ import java.net.HttpCookie import java.net.URI open class SharedPreferencesCookieStore( - context: Context, - private val name: String -) : InMemoryCookieStore(name) { + private val preferences: SharedPreferences, +) : InMemoryCookieStore() { - private val preferences = context.getSharedPreferences(name, Context.MODE_PRIVATE) private val gson = Gson() init { @@ -30,7 +28,7 @@ open class SharedPreferencesCookieStore( } catch (exception: Throwable) { Log.e( javaClass.simpleName, - "Error while loading key = $key, value = $value from cookie store named $name", + "Error while loading key = $key, value = $value from cookie store", exception ) } diff --git a/library/src/main/java/io/appwrite/enums/Browser.kt b/library/src/main/java/io/appwrite/enums/Browser.kt new file mode 100644 index 0000000..99f598e --- /dev/null +++ b/library/src/main/java/io/appwrite/enums/Browser.kt @@ -0,0 +1,20 @@ +package io.appwrite.enums + +enum class Browser(val value: String) { + AVANT_BROWSER("aa"), + ANDROID_WEB_VIEW_BETA("an"), + GOOGLE_CHROME("ch"), + GOOGLE_CHROMEI_OS("ci"), + GOOGLE_CHROME_MOBILE("cm"), + CHROMIUM("cr"), + MOZILLA_FIREFOX("ff"), + SAFARI("sf"), + MOBILE_SAFARI("mf"), + MICROSOFT_EDGE("ps"), + MICROSOFT_EDGEI_OS("oi"), + OPERA_MINI("om"), + OPERA("op"), + OPERA_NEXT("on"); + + override fun toString() = value +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/CreditCard.kt b/library/src/main/java/io/appwrite/enums/CreditCard.kt new file mode 100644 index 0000000..e99519b --- /dev/null +++ b/library/src/main/java/io/appwrite/enums/CreditCard.kt @@ -0,0 +1,22 @@ +package io.appwrite.enums + +enum class CreditCard(val value: String) { + AMERICAN_EXPRESS("amex"), + ARGENCARD("argencard"), + CABAL("cabal"), + CONSOSUD("censosud"), + DINERS_CLUB("diners"), + DISCOVER("discover"), + ELO("elo"), + HIPERCARD("hipercard"), + JCB("jcb"), + MASTERCARD("mastercard"), + NARANJA("naranja"), + TARJETA_SHOPPING("targeta-shopping"), + UNION_CHINA_PAY("union-china-pay"), + VISA("visa"), + MIR("mir"), + MAESTRO("maestro"); + + override fun toString() = value +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/ExecutionMethod.kt b/library/src/main/java/io/appwrite/enums/ExecutionMethod.kt new file mode 100644 index 0000000..edeb66b --- /dev/null +++ b/library/src/main/java/io/appwrite/enums/ExecutionMethod.kt @@ -0,0 +1,12 @@ +package io.appwrite.enums + +enum class ExecutionMethod(val value: String) { + GET("GET"), + POST("POST"), + PUT("PUT"), + PATCH("PATCH"), + DELETE("DELETE"), + OPTIONS("OPTIONS"); + + override fun toString() = value +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/Factor.kt b/library/src/main/java/io/appwrite/enums/Factor.kt new file mode 100644 index 0000000..1c705c8 --- /dev/null +++ b/library/src/main/java/io/appwrite/enums/Factor.kt @@ -0,0 +1,9 @@ +package io.appwrite.enums + +enum class Factor(val value: String) { + TOTP("totp"), + PHONE("phone"), + EMAIL("email"); + + override fun toString() = value +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/Flag.kt b/library/src/main/java/io/appwrite/enums/Flag.kt new file mode 100644 index 0000000..4fcdd88 --- /dev/null +++ b/library/src/main/java/io/appwrite/enums/Flag.kt @@ -0,0 +1,200 @@ +package io.appwrite.enums + +enum class Flag(val value: String) { + AFGHANISTAN("af"), + ANGOLA("ao"), + ALBANIA("al"), + ANDORRA("ad"), + UNITED_ARAB_EMIRATES("ae"), + ARGENTINA("ar"), + ARMENIA("am"), + ANTIGUAAND_BARBUDA("ag"), + AUSTRALIA("au"), + AUSTRIA("at"), + AZERBAIJAN("az"), + BURUNDI("bi"), + BELGIUM("be"), + BENIN("bj"), + BURKINA_FASO("bf"), + BANGLADESH("bd"), + BULGARIA("bg"), + BAHRAIN("bh"), + BAHAMAS("bs"), + BOSNIAAND_HERZEGOVINA("ba"), + BELARUS("by"), + BELIZE("bz"), + BOLIVIA("bo"), + BRAZIL("br"), + BARBADOS("bb"), + BRUNEI_DARUSSALAM("bn"), + BHUTAN("bt"), + BOTSWANA("bw"), + CENTRAL_AFRICAN_REPUBLIC("cf"), + CANADA("ca"), + SWITZERLAND("ch"), + CHILE("cl"), + CHINA("cn"), + CTED_IVOIRE("ci"), + CAMEROON("cm"), + DEMOCRATIC_REPUBLICOFTHE_CONGO("cd"), + REPUBLICOFTHE_CONGO("cg"), + COLOMBIA("co"), + COMOROS("km"), + CAPE_VERDE("cv"), + COSTA_RICA("cr"), + CUBA("cu"), + CYPRUS("cy"), + CZECH_REPUBLIC("cz"), + GERMANY("de"), + DJIBOUTI("dj"), + DOMINICA("dm"), + DENMARK("dk"), + DOMINICAN_REPUBLIC("do"), + ALGERIA("dz"), + ECUADOR("ec"), + EGYPT("eg"), + ERITREA("er"), + SPAIN("es"), + ESTONIA("ee"), + ETHIOPIA("et"), + FINLAND("fi"), + FIJI("fj"), + FRANCE("fr"), + MICRONESIA_FEDERATED_STATESOF("fm"), + GABON("ga"), + UNITED_KINGDOM("gb"), + GEORGIA("ge"), + GHANA("gh"), + GUINEA("gn"), + GAMBIA("gm"), + GUINEA_BISSAU("gw"), + EQUATORIAL_GUINEA("gq"), + GREECE("gr"), + GRENADA("gd"), + GUATEMALA("gt"), + GUYANA("gy"), + HONDURAS("hn"), + CROATIA("hr"), + HAITI("ht"), + HUNGARY("hu"), + INDONESIA("id"), + INDIA("in"), + IRELAND("ie"), + IRAN_ISLAMIC_REPUBLICOF("ir"), + IRAQ("iq"), + ICELAND("is"), + ISRAEL("il"), + ITALY("it"), + JAMAICA("jm"), + JORDAN("jo"), + JAPAN("jp"), + KAZAKHSTAN("kz"), + KENYA("ke"), + KYRGYZSTAN("kg"), + CAMBODIA("kh"), + KIRIBATI("ki"), + SAINT_KITTSAND_NEVIS("kn"), + SOUTH_KOREA("kr"), + KUWAIT("kw"), + LAO_PEOPLES_DEMOCRATIC_REPUBLIC("la"), + LEBANON("lb"), + LIBERIA("lr"), + LIBYA("ly"), + SAINT_LUCIA("lc"), + LIECHTENSTEIN("li"), + SRI_LANKA("lk"), + LESOTHO("ls"), + LITHUANIA("lt"), + LUXEMBOURG("lu"), + LATVIA("lv"), + MOROCCO("ma"), + MONACO("mc"), + MOLDOVA("md"), + MADAGASCAR("mg"), + MALDIVES("mv"), + MEXICO("mx"), + MARSHALL_ISLANDS("mh"), + NORTH_MACEDONIA("mk"), + MALI("ml"), + MALTA("mt"), + MYANMAR("mm"), + MONTENEGRO("me"), + MONGOLIA("mn"), + MOZAMBIQUE("mz"), + MAURITANIA("mr"), + MAURITIUS("mu"), + MALAWI("mw"), + MALAYSIA("my"), + NAMIBIA("na"), + NIGER("ne"), + NIGERIA("ng"), + NICARAGUA("ni"), + NETHERLANDS("nl"), + NORWAY("no"), + NEPAL("np"), + NAURU("nr"), + NEW_ZEALAND("nz"), + OMAN("om"), + PAKISTAN("pk"), + PANAMA("pa"), + PERU("pe"), + PHILIPPINES("ph"), + PALAU("pw"), + PAPUA_NEW_GUINEA("pg"), + POLAND("pl"), + NORTH_KOREA("kp"), + PORTUGAL("pt"), + PARAGUAY("py"), + QATAR("qa"), + ROMANIA("ro"), + RUSSIA("ru"), + RWANDA("rw"), + SAUDI_ARABIA("sa"), + SUDAN("sd"), + SENEGAL("sn"), + SINGAPORE("sg"), + SOLOMON_ISLANDS("sb"), + SIERRA_LEONE("sl"), + EL_SALVADOR("sv"), + SAN_MARINO("sm"), + SOMALIA("so"), + SERBIA("rs"), + SOUTH_SUDAN("ss"), + SAO_TOMEAND_PRINCIPE("st"), + SURINAME("sr"), + SLOVAKIA("sk"), + SLOVENIA("si"), + SWEDEN("se"), + ESWATINI("sz"), + SEYCHELLES("sc"), + SYRIA("sy"), + CHAD("td"), + TOGO("tg"), + THAILAND("th"), + TAJIKISTAN("tj"), + TURKMENISTAN("tm"), + TIMOR_LESTE("tl"), + TONGA("to"), + TRINIDADAND_TOBAGO("tt"), + TUNISIA("tn"), + TURKEY("tr"), + TUVALU("tv"), + TANZANIA("tz"), + UGANDA("ug"), + UKRAINE("ua"), + URUGUAY("uy"), + UNITED_STATES("us"), + UZBEKISTAN("uz"), + VATICAN_CITY("va"), + SAINT_VINCENTANDTHE_GRENADINES("vc"), + VENEZUELA("ve"), + VIETNAM("vn"), + VANUATU("vu"), + SAMOA("ws"), + YEMEN("ye"), + SOUTH_AFRICA("za"), + ZAMBIA("zm"), + ZIMBABWE("zw"); + + override fun toString() = value +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/ImageFormat.kt b/library/src/main/java/io/appwrite/enums/ImageFormat.kt new file mode 100644 index 0000000..6a4c422 --- /dev/null +++ b/library/src/main/java/io/appwrite/enums/ImageFormat.kt @@ -0,0 +1,11 @@ +package io.appwrite.enums + +enum class ImageFormat(val value: String) { + JPG("jpg"), + JPEG("jpeg"), + GIF("gif"), + PNG("png"), + WEBP("webp"); + + override fun toString() = value +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/ImageGravity.kt b/library/src/main/java/io/appwrite/enums/ImageGravity.kt new file mode 100644 index 0000000..a8fa441 --- /dev/null +++ b/library/src/main/java/io/appwrite/enums/ImageGravity.kt @@ -0,0 +1,15 @@ +package io.appwrite.enums + +enum class ImageGravity(val value: String) { + CENTER("center"), + TOPLEFT("top-left"), + TOP("top"), + TOPRIGHT("top-right"), + LEFT("left"), + RIGHT("right"), + BOTTOMLEFT("bottom-left"), + BOTTOM("bottom"), + BOTTOMRIGHT("bottom-right"); + + override fun toString() = value +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/OAuthProvider.kt b/library/src/main/java/io/appwrite/enums/OAuthProvider.kt new file mode 100644 index 0000000..4a38a2e --- /dev/null +++ b/library/src/main/java/io/appwrite/enums/OAuthProvider.kt @@ -0,0 +1,45 @@ +package io.appwrite.enums + +enum class OAuthProvider(val value: String) { + AMAZON("amazon"), + APPLE("apple"), + AUTH0("auth0"), + AUTHENTIK("authentik"), + AUTODESK("autodesk"), + BITBUCKET("bitbucket"), + BITLY("bitly"), + BOX("box"), + DAILYMOTION("dailymotion"), + DISCORD("discord"), + DISQUS("disqus"), + DROPBOX("dropbox"), + ETSY("etsy"), + FACEBOOK("facebook"), + GITHUB("github"), + GITLAB("gitlab"), + GOOGLE("google"), + LINKEDIN("linkedin"), + MICROSOFT("microsoft"), + NOTION("notion"), + OIDC("oidc"), + OKTA("okta"), + PAYPAL("paypal"), + PAYPAL_SANDBOX("paypalSandbox"), + PODIO("podio"), + SALESFORCE("salesforce"), + SLACK("slack"), + SPOTIFY("spotify"), + STRIPE("stripe"), + TRADESHIFT("tradeshift"), + TRADESHIFT_BOX("tradeshiftBox"), + TWITCH("twitch"), + WORDPRESS("wordpress"), + YAHOO("yahoo"), + YAMMER("yammer"), + YANDEX("yandex"), + ZOHO("zoho"), + ZOOM("zoom"), + MOCK("mock"); + + override fun toString() = value +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/Type.kt b/library/src/main/java/io/appwrite/enums/Type.kt new file mode 100644 index 0000000..51a06b4 --- /dev/null +++ b/library/src/main/java/io/appwrite/enums/Type.kt @@ -0,0 +1,7 @@ +package io.appwrite.enums + +enum class Type(val value: String) { + TOTP("totp"); + + override fun toString() = value +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/extensions/JsonExtensions.kt b/library/src/main/java/io/appwrite/extensions/JsonExtensions.kt index 444a77d..06d9940 100644 --- a/library/src/main/java/io/appwrite/extensions/JsonExtensions.kt +++ b/library/src/main/java/io/appwrite/extensions/JsonExtensions.kt @@ -1,8 +1,14 @@ package io.appwrite.extensions import com.google.gson.Gson - -val gson = Gson() +import com.google.gson.GsonBuilder +import com.google.gson.ToNumberPolicy +import com.google.gson.reflect.TypeToken + +val gson: Gson = GsonBuilder() + .setNumberToNumberStrategy(ToNumberPolicy.LONG_OR_DOUBLE) + .setObjectToNumberStrategy(ToNumberPolicy.LONG_OR_DOUBLE) + .create() fun Any.toJson(): String = gson.toJson(this) diff --git a/library/src/main/java/io/appwrite/extensions/TypeExtensions.kt b/library/src/main/java/io/appwrite/extensions/TypeExtensions.kt index 2674b99..e699a54 100644 --- a/library/src/main/java/io/appwrite/extensions/TypeExtensions.kt +++ b/library/src/main/java/io/appwrite/extensions/TypeExtensions.kt @@ -4,5 +4,6 @@ import kotlin.reflect.KClass import kotlin.reflect.typeOf inline fun classOf(): Class { + @Suppress("UNCHECKED_CAST") return (typeOf().classifier!! as KClass).java } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/json/PreciseNumberAdapter.kt b/library/src/main/java/io/appwrite/json/PreciseNumberAdapter.kt deleted file mode 100644 index 6d408ac..0000000 --- a/library/src/main/java/io/appwrite/json/PreciseNumberAdapter.kt +++ /dev/null @@ -1,64 +0,0 @@ -package io.appwrite.json - -import com.google.gson.Gson -import com.google.gson.TypeAdapter -import com.google.gson.stream.JsonReader -import com.google.gson.stream.JsonToken.* -import com.google.gson.stream.JsonWriter -import java.io.IOException - -internal class PreciseNumberAdapter : TypeAdapter() { - - private val delegate = Gson() - .getAdapter(Any::class.java) - - @Throws(IOException::class) - override fun write(out: JsonWriter?, value: Any?) { - delegate.write(out, value) - } - - @Throws(IOException::class) - override fun read(input: JsonReader): Any? { - return when (input.peek()) { - BEGIN_ARRAY -> { - val list = mutableListOf() - input.beginArray() - while (input.hasNext()) { - list.add(read(input)) - } - input.endArray() - list - } - BEGIN_OBJECT -> { - val map = mutableMapOf() - input.beginObject() - while (input.hasNext()) { - map[input.nextName()] = read(input) - } - input.endObject() - map - } - STRING -> { - input.nextString() - } - NUMBER -> { - val numberString = input.nextString() - if (numberString.indexOf('.') != -1) { - numberString.toDouble() - } else { - numberString.toLong() - } - } - BOOLEAN -> { - input.nextBoolean() - } - NULL -> { - input.nextNull() - null - } - else -> { - throw IllegalStateException() - } - } - } -} \ 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 96a364f..17ab303 100644 --- a/library/src/main/java/io/appwrite/models/Membership.kt +++ b/library/src/main/java/io/appwrite/models/Membership.kt @@ -73,6 +73,12 @@ data class Membership( @SerializedName("confirm") val confirm: Boolean, + /** + * Multi factor authentication status, true if the user has MFA enabled or false otherwise. + */ + @SerializedName("mfa") + val mfa: Boolean, + /** * User list of roles */ @@ -92,6 +98,7 @@ data class Membership( "invited" to invited as Any, "joined" to joined as Any, "confirm" to confirm as Any, + "mfa" to mfa as Any, "roles" to roles as Any, ) @@ -112,6 +119,7 @@ data class Membership( invited = map["invited"] as String, joined = map["joined"] as String, confirm = map["confirm"] as Boolean, + mfa = map["mfa"] as Boolean, roles = map["roles"] as List, ) } diff --git a/library/src/main/java/io/appwrite/models/MfaChallenge.kt b/library/src/main/java/io/appwrite/models/MfaChallenge.kt new file mode 100644 index 0000000..82b1d18 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/MfaChallenge.kt @@ -0,0 +1,54 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * MFA Challenge + */ +data class MfaChallenge( + /** + * 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 expiration date in ISO 8601 format. + */ + @SerializedName("expire") + val expire: String, + +) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "userId" to userId as Any, + "expire" to expire as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = MfaChallenge( + id = map["\$id"] as String, + createdAt = map["\$createdAt"] as String, + userId = map["userId"] as String, + expire = map["expire"] as String, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/MfaFactors.kt b/library/src/main/java/io/appwrite/models/MfaFactors.kt new file mode 100644 index 0000000..904a10b --- /dev/null +++ b/library/src/main/java/io/appwrite/models/MfaFactors.kt @@ -0,0 +1,46 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * MFAFactors + */ +data class MfaFactors( + /** + * TOTP + */ + @SerializedName("totp") + val totp: Boolean, + + /** + * Phone + */ + @SerializedName("phone") + val phone: Boolean, + + /** + * Email + */ + @SerializedName("email") + val email: Boolean, + +) { + fun toMap(): Map = mapOf( + "totp" to totp as Any, + "phone" to phone as Any, + "email" to email as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = MfaFactors( + totp = map["totp"] as Boolean, + phone = map["phone"] as Boolean, + email = map["email"] as Boolean, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/MfaType.kt b/library/src/main/java/io/appwrite/models/MfaType.kt new file mode 100644 index 0000000..c3d8d53 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/MfaType.kt @@ -0,0 +1,46 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * MFAType + */ +data class MfaType( + /** + * Backup codes. + */ + @SerializedName("backups") + val backups: List, + + /** + * Secret token used for TOTP factor. + */ + @SerializedName("secret") + val secret: String, + + /** + * URI for authenticator apps. + */ + @SerializedName("uri") + val uri: String, + +) { + fun toMap(): Map = mapOf( + "backups" to backups as Any, + "secret" to secret as Any, + "uri" to uri as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = MfaType( + backups = map["backups"] as List, + secret = map["secret"] as String, + uri = map["uri"] as String, + ) + } +} \ 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 7674d72..da71926 100644 --- a/library/src/main/java/io/appwrite/models/Session.kt +++ b/library/src/main/java/io/appwrite/models/Session.kt @@ -157,6 +157,18 @@ data class Session( @SerializedName("current") val current: Boolean, + /** + * Returns a list of active session factors. + */ + @SerializedName("factors") + val factors: List, + + /** + * Secret used to authenticate the user. Only included if the request was made with an API key + */ + @SerializedName("secret") + val secret: String, + ) { fun toMap(): Map = mapOf( "\$id" to id as Any, @@ -184,6 +196,8 @@ data class Session( "countryCode" to countryCode as Any, "countryName" to countryName as Any, "current" to current as Any, + "factors" to factors as Any, + "secret" to secret as Any, ) companion object { @@ -217,6 +231,8 @@ data class Session( countryCode = map["countryCode"] as String, countryName = map["countryName"] as String, current = map["current"] as Boolean, + factors = map["factors"] as List, + secret = map["secret"] as String, ) } } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Subscriber.kt b/library/src/main/java/io/appwrite/models/Subscriber.kt new file mode 100644 index 0000000..1920691 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Subscriber.kt @@ -0,0 +1,94 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Subscriber + */ +data class Subscriber( + /** + * Subscriber ID. + */ + @SerializedName("\$id") + val id: String, + + /** + * Subscriber creation time in ISO 8601 format. + */ + @SerializedName("\$createdAt") + val createdAt: String, + + /** + * Subscriber update date in ISO 8601 format. + */ + @SerializedName("\$updatedAt") + val updatedAt: String, + + /** + * Target ID. + */ + @SerializedName("targetId") + val targetId: String, + + /** + * Target. + */ + @SerializedName("target") + val target: Target, + + /** + * Topic ID. + */ + @SerializedName("userId") + val userId: String, + + /** + * User Name. + */ + @SerializedName("userName") + val userName: String, + + /** + * Topic ID. + */ + @SerializedName("topicId") + val topicId: String, + + /** + * The target provider type. Can be one of the following: `email`, `sms` or `push`. + */ + @SerializedName("providerType") + val providerType: String, + +) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "targetId" to targetId as Any, + "target" to target.toMap() as Any, + "userId" to userId as Any, + "userName" to userName as Any, + "topicId" to topicId as Any, + "providerType" to providerType as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = Subscriber( + id = map["\$id"] as String, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, + targetId = map["targetId"] as String, + target = Target.from(map = map["target"] as Map), + userId = map["userId"] as String, + userName = map["userName"] as String, + topicId = map["topicId"] as String, + providerType = map["providerType"] as String, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Target.kt b/library/src/main/java/io/appwrite/models/Target.kt new file mode 100644 index 0000000..bd4d207 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Target.kt @@ -0,0 +1,86 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Target + */ +data class Target( + /** + * Target ID. + */ + @SerializedName("\$id") + val id: String, + + /** + * Target creation time in ISO 8601 format. + */ + @SerializedName("\$createdAt") + val createdAt: String, + + /** + * Target update date in ISO 8601 format. + */ + @SerializedName("\$updatedAt") + val updatedAt: String, + + /** + * Target Name. + */ + @SerializedName("name") + val name: String, + + /** + * User ID. + */ + @SerializedName("userId") + val userId: String, + + /** + * Provider ID. + */ + @SerializedName("providerId") + var providerId: String?, + + /** + * The target provider type. Can be one of the following: `email`, `sms` or `push`. + */ + @SerializedName("providerType") + val providerType: String, + + /** + * The target identifier. + */ + @SerializedName("identifier") + val identifier: String, + +) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "name" to name as Any, + "userId" to userId as Any, + "providerId" to providerId as Any, + "providerType" to providerType as Any, + "identifier" to identifier as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = Target( + id = map["\$id"] as String, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, + name = map["name"] as String, + userId = map["userId"] as String, + providerId = map["providerId"] as? String?, + providerType = map["providerType"] as String, + identifier = map["identifier"] as String, + ) + } +} \ 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 8c0f0e0..e36d060 100644 --- a/library/src/main/java/io/appwrite/models/Token.kt +++ b/library/src/main/java/io/appwrite/models/Token.kt @@ -37,6 +37,12 @@ data class Token( @SerializedName("expire") val expire: String, + /** + * Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. + */ + @SerializedName("phrase") + val phrase: String, + ) { fun toMap(): Map = mapOf( "\$id" to id as Any, @@ -44,6 +50,7 @@ data class Token( "userId" to userId as Any, "secret" to secret as Any, "expire" to expire as Any, + "phrase" to phrase as Any, ) companion object { @@ -57,6 +64,7 @@ data class Token( userId = map["userId"] as String, secret = map["secret"] as String, expire = map["expire"] as String, + phrase = map["phrase"] as String, ) } } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/User.kt b/library/src/main/java/io/appwrite/models/User.kt index 9bf7eb4..4c776b9 100644 --- a/library/src/main/java/io/appwrite/models/User.kt +++ b/library/src/main/java/io/appwrite/models/User.kt @@ -97,12 +97,30 @@ data class User( @SerializedName("phoneVerification") val phoneVerification: Boolean, + /** + * Multi factor authentication status. + */ + @SerializedName("mfa") + val mfa: Boolean, + + /** + * TOTP status. + */ + @SerializedName("totp") + val totp: Boolean, + /** * User preferences as a key-value object */ @SerializedName("prefs") val prefs: Preferences, + /** + * A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. + */ + @SerializedName("targets") + val targets: List, + /** * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. */ @@ -126,7 +144,10 @@ data class User( "phone" to phone as Any, "emailVerification" to emailVerification as Any, "phoneVerification" to phoneVerification as Any, + "mfa" to mfa as Any, + "totp" to totp as Any, "prefs" to prefs.toMap() as Any, + "targets" to targets.map { it.toMap() } as Any, "accessedAt" to accessedAt as Any, ) @@ -147,7 +168,10 @@ data class User( phone: String, emailVerification: Boolean, phoneVerification: Boolean, + mfa: Boolean, + totp: Boolean, prefs: Preferences>, + targets: List, accessedAt: String, ) = User>( id, @@ -165,7 +189,10 @@ data class User( phone, emailVerification, phoneVerification, + mfa, + totp, prefs, + targets, accessedAt, ) @@ -189,7 +216,10 @@ data class User( phone = map["phone"] as String, emailVerification = map["emailVerification"] as Boolean, phoneVerification = map["phoneVerification"] as Boolean, + mfa = map["mfa"] as Boolean, + totp = map["totp"] as Boolean, prefs = Preferences.from(map = map["prefs"] as Map, nestedType), + targets = (map["targets"] as List>).map { Target.from(map = it) }, accessedAt = map["accessedAt"] as String, ) } diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 3c9cca1..b9a4b96 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -2,7 +2,9 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client +import io.appwrite.Service import io.appwrite.models.* +import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import io.appwrite.WebAuthComponent @@ -15,9 +17,7 @@ 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) { } +class Account(client: Client) : Service(client) { /** * Get account @@ -37,6 +37,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( @@ -67,9 +68,9 @@ class Account : Service { * * Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). * - * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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 User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 New user password. Must be at least 8 chars. + * @param password New user password. Must be between 8 and 256 chars. * @param name User name. Max length: 128 chars. * @return [io.appwrite.models.User] */ @@ -93,6 +94,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( @@ -110,9 +112,9 @@ class Account : Service { * * Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). * - * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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 User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 New user password. Must be at least 8 chars. + * @param password New user password. Must be between 8 and 256 chars. * @param name User name. Max length: 128 chars. * @return [io.appwrite.models.User] */ @@ -155,6 +157,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( @@ -196,7 +199,7 @@ class Account : Service { */ @JvmOverloads suspend fun listIdentities( - queries: String? = null, + queries: List? = null, ): io.appwrite.models.IdentityList { val apiPath = "/account/identities" @@ -207,6 +210,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.IdentityList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.IdentityList.from(map = it as Map) } return client.call( @@ -221,7 +225,7 @@ class Account : Service { /** - * Delete Identity + * Delete identity * * Delete an identity by its unique ID. * @@ -266,6 +270,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Jwt = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Jwt.from(map = it as Map) } return client.call( @@ -300,6 +305,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LogList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.LogList.from(map = it as Map) } return client.call( @@ -313,6 +319,299 @@ class Account : Service { } + /** + * Update MFA + * + * + * + * @param mfa Enable or disable MFA. + * @return [io.appwrite.models.User] + */ + suspend fun updateMFA( + mfa: Boolean, + nestedType: Class, + ): io.appwrite.models.User { + val apiPath = "/account/mfa" + + val apiParams = mutableMapOf( + "mfa" to mfa, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.User.from(map = it as Map, nestedType) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Update MFA + * + * + * + * @param mfa Enable or disable MFA. + * @return [io.appwrite.models.User] + */ + @Throws(AppwriteException::class) + suspend fun updateMFA( + mfa: Boolean, + ): io.appwrite.models.User> = updateMFA( + mfa, + nestedType = classOf(), + ) + + /** + * Create 2FA Challenge + * + * + * + * @param factor Factor used for verification. + * @return [io.appwrite.models.MfaChallenge] + */ + suspend fun create2FAChallenge( + factor: Factor, + ): io.appwrite.models.MfaChallenge { + val apiPath = "/account/mfa/challenge" + + val apiParams = mutableMapOf( + "factor" to factor, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.MfaChallenge = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.MfaChallenge.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.MfaChallenge::class.java, + converter, + ) + } + + + /** + * Create MFA Challenge (confirmation) + * + * + * + * @param challengeId ID of the challenge. + * @param otp Valid verification token. + * @return [Any] + */ + suspend fun updateChallenge( + challengeId: String, + otp: String, + ): Any { + val apiPath = "/account/mfa/challenge" + + val apiParams = mutableMapOf( + "challengeId" to challengeId, + "otp" to otp, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + return client.call( + "PUT", + apiPath, + apiHeaders, + apiParams, + responseType = Any::class.java, + ) + } + + + /** + * List Factors + * + * + * + * @return [io.appwrite.models.MfaFactors] + */ + suspend fun listFactors( + ): io.appwrite.models.MfaFactors { + val apiPath = "/account/mfa/factors" + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.MfaFactors = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.MfaFactors.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.MfaFactors::class.java, + converter, + ) + } + + + /** + * Add Authenticator + * + * + * + * @param type Type of authenticator. + * @return [io.appwrite.models.MfaType] + */ + suspend fun addAuthenticator( + type: Type, + ): io.appwrite.models.MfaType { + val apiPath = "/account/mfa/{type}" + .replace("{type}", type.value) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.MfaType = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.MfaType.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.MfaType::class.java, + converter, + ) + } + + + /** + * Verify Authenticator + * + * + * + * @param type Type of authenticator. + * @param otp Valid verification token. + * @return [io.appwrite.models.User] + */ + suspend fun verifyAuthenticator( + type: Type, + otp: String, + nestedType: Class, + ): io.appwrite.models.User { + val apiPath = "/account/mfa/{type}" + .replace("{type}", type.value) + + val apiParams = mutableMapOf( + "otp" to otp, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.User.from(map = it as Map, nestedType) + } + return client.call( + "PUT", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Verify Authenticator + * + * + * + * @param type Type of authenticator. + * @param otp Valid verification token. + * @return [io.appwrite.models.User] + */ + @Throws(AppwriteException::class) + suspend fun verifyAuthenticator( + type: Type, + otp: String, + ): io.appwrite.models.User> = verifyAuthenticator( + type, + otp, + nestedType = classOf(), + ) + + /** + * Delete Authenticator + * + * + * + * @param type Type of authenticator. + * @param otp Valid verification token. + * @return [io.appwrite.models.User] + */ + suspend fun deleteAuthenticator( + type: Type, + otp: String, + nestedType: Class, + ): io.appwrite.models.User { + val apiPath = "/account/mfa/{type}" + .replace("{type}", type.value) + + val apiParams = mutableMapOf( + "otp" to otp, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.User.from(map = it as Map, nestedType) + } + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Delete Authenticator + * + * + * + * @param type Type of authenticator. + * @param otp Valid verification token. + * @return [io.appwrite.models.User] + */ + @Throws(AppwriteException::class) + suspend fun deleteAuthenticator( + type: Type, + otp: String, + ): io.appwrite.models.User> = deleteAuthenticator( + type, + otp, + nestedType = classOf(), + ) + /** * Update name * @@ -334,6 +633,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( @@ -387,6 +687,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( @@ -443,6 +744,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( @@ -492,6 +794,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Preferences.from(map = it as Map, nestedType) } return client.call( @@ -538,6 +841,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( @@ -589,6 +893,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } return client.call( @@ -609,15 +914,13 @@ class Account : Service { * * @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. + * @param password New user password. Must be between 8 and 256 chars. * @return [io.appwrite.models.Token] */ suspend fun updateRecovery( userId: String, secret: String, password: String, - passwordAgain: String, ): io.appwrite.models.Token { val apiPath = "/account/recovery" @@ -625,12 +928,12 @@ class Account : Service { "userId" to userId, "secret" to secret, "password" to password, - "passwordAgain" to passwordAgain, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } return client.call( @@ -661,6 +964,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.SessionList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.SessionList.from(map = it as Map) } return client.call( @@ -717,6 +1021,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } return client.call( @@ -731,7 +1036,7 @@ class Account : Service { /** - * Create email session + * Create email password session * * Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * @@ -739,7 +1044,7 @@ class Account : Service { * @param password User password. Must be at least 8 chars. * @return [io.appwrite.models.Session] */ - suspend fun createEmailSession( + suspend fun createEmailPasswordSession( email: String, password: String, ): io.appwrite.models.Session { @@ -753,6 +1058,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } return client.call( @@ -767,51 +1073,11 @@ class Account : Service { /** - * Create magic URL session - * - * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [PUT /account/sessions/magic-url](https://appwrite.io/docs/references/cloud/client-web/account#updateMagicURLSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). - * - * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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] - */ - @JvmOverloads - suspend fun createMagicURLSession( - userId: String, - email: String, - url: String? = null, - ): io.appwrite.models.Token { - val apiPath = "/account/sessions/magic-url" - - val apiParams = mutableMapOf( - "userId" to userId, - "email" to email, - "url" to url, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it as Map) - } - return client.call( - "POST", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.Token::class.java, - converter, - ) - } - - - /** - * Create magic URL session (confirmation) + * Create session (deprecated) * - * 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](https://appwrite.io/docs/references/cloud/client-web/account#createMagicURLSession) 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 create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. * - * @param userId User ID. + * @param userId User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 secret Valid verification token. * @return [io.appwrite.models.Session] */ @@ -829,6 +1095,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } return client.call( @@ -847,25 +1114,28 @@ class Account : Service { * * 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](https://appwrite.io/docs/authentication-security#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, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoom. + * @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, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom. * @param success URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's 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's 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 token Include token credentials in the final redirect, useful for server-side integrations, or when cookies are not available. * @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 suspend fun createOAuth2Session( activity: ComponentActivity, - provider: String, + provider: OAuthProvider, success: String? = null, failure: String? = null, + token: Boolean? = null, scopes: List? = null, ) { val apiPath = "/account/sessions/oauth2/{provider}" - .replace("{provider}", provider) + .replace("{provider}", provider.value) val apiParams = mutableMapOf( "success" to success, "failure" to failure, + "token" to token, "scopes" to scopes, "project" to client.config["project"], ) @@ -884,7 +1154,7 @@ class Account : Service { } } - val apiUrl = Uri.parse("${client.endPoint}${apiPath}?${apiQuery.joinToString("&")}") + val apiUrl = Uri.parse("${client.endpoint}${apiPath}?${apiQuery.joinToString("&")}") val callbackUrlScheme = "appwrite-callback-${client.config["project"]}" WebAuthComponent.authenticate(activity, apiUrl, callbackUrlScheme) { @@ -902,12 +1172,12 @@ class Account : Service { val cookie = Cookie.Builder() .name(key) .value(secret) - .domain(Uri.parse(client.endPoint).host!!) + .domain(Uri.parse(client.endpoint).host!!) .httpOnly() .build() client.http.cookieJar.saveFromResponse( - client.endPoint.toHttpUrl(), + client.endpoint.toHttpUrl(), listOf(cookie) ) } @@ -915,55 +1185,19 @@ class Account : Service { /** - * Create phone session + * Create 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](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. * - * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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] - */ - suspend fun createPhoneSession( - userId: String, - phone: String, - ): io.appwrite.models.Token { - val apiPath = "/account/sessions/phone" - - val apiParams = mutableMapOf( - "userId" to userId, - "phone" to phone, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Token = { - io.appwrite.models.Token.from(map = it as Map) - } - return client.call( - "POST", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.Token::class.java, - converter, - ) - } - - - /** - * Create phone session (confirmation) - * - * Use this endpoint to complete creating a session with SMS. Use the **userId** from the [createPhoneSession](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneSession) endpoint and the **secret** received via SMS to successfully update and confirm the phone session. - * - * @param userId User ID. - * @param secret Valid verification token. + * @param userId User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 secret Secret of a token generated by login methods. For example, the `createMagicURLToken` or `createPhoneToken` methods. * @return [io.appwrite.models.Session] */ - suspend fun updatePhoneSession( + suspend fun createSession( userId: String, secret: String, ): io.appwrite.models.Session { - val apiPath = "/account/sessions/phone" + val apiPath = "/account/sessions/token" val apiParams = mutableMapOf( "userId" to userId, @@ -973,10 +1207,11 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } return client.call( - "PUT", + "POST", apiPath, apiHeaders, apiParams, @@ -1006,6 +1241,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } return client.call( @@ -1020,9 +1256,9 @@ class Account : Service { /** - * Update OAuth session (refresh tokens) + * Update (or renew) a session * - * Access tokens have limited lifespan and expire to mitigate security risks. If session was created using an OAuth provider, this route can be used to "refresh" the access token. + * Extend session's expiry to increase it's lifespan. Extending a session is useful when session length is short such as 5 minutes. * * @param sessionId Session ID. Use the string 'current' to update the current device session. * @return [io.appwrite.models.Session] @@ -1039,6 +1275,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } return client.call( @@ -1099,6 +1336,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } return client.call( @@ -1124,6 +1362,235 @@ class Account : Service { nestedType = classOf(), ) + /** + * Create a push target + * + * + * + * @param targetId Target ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 identifier The target identifier (token, email, phone etc.) + * @param providerId Provider ID. Message will be sent to this target from the specified provider ID. If no provider ID is set the first setup provider will be used. + * @return [io.appwrite.models.Target] + */ + @JvmOverloads + suspend fun createPushTarget( + targetId: String, + identifier: String, + providerId: String? = null, + ): io.appwrite.models.Target { + val apiPath = "/account/targets/push" + + val apiParams = mutableMapOf( + "targetId" to targetId, + "identifier" to identifier, + "providerId" to providerId, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Target = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Target.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Target::class.java, + converter, + ) + } + + + /** + * Update a push target + * + * + * + * @param targetId Target ID. + * @param identifier The target identifier (token, email, phone etc.) + * @return [io.appwrite.models.Target] + */ + suspend fun updatePushTarget( + targetId: String, + identifier: String, + ): io.appwrite.models.Target { + val apiPath = "/account/targets/{targetId}/push" + .replace("{targetId}", targetId) + + val apiParams = mutableMapOf( + "identifier" to identifier, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Target = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Target.from(map = it as Map) + } + return client.call( + "PUT", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Target::class.java, + converter, + ) + } + + + /** + * Delete a push target + * + * + * + * @param targetId Target ID. + * @return [Any] + */ + suspend fun deletePushTarget( + targetId: String, + ): Any { + val apiPath = "/account/targets/{targetId}/push" + .replace("{targetId}", targetId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = Any::class.java, + ) + } + + + /** + * Create email token (OTP) + * + * Sends the user an email with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's email is valid for 15 minutes.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * + * @param userId User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 phrase Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. + * @return [io.appwrite.models.Token] + */ + @JvmOverloads + suspend fun createEmailToken( + userId: String, + email: String, + phrase: Boolean? = null, + ): io.appwrite.models.Token { + val apiPath = "/account/tokens/email" + + val apiParams = mutableMapOf( + "userId" to userId, + "email" to email, + "phrase" to phrase, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Token = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Token.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Token::class.java, + converter, + ) + } + + + /** + * Create magic URL token + * + * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * + * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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. + * @param phrase Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. + * @return [io.appwrite.models.Token] + */ + @JvmOverloads + suspend fun createMagicURLToken( + userId: String, + email: String, + url: String? = null, + phrase: Boolean? = null, + ): io.appwrite.models.Token { + val apiPath = "/account/tokens/magic-url" + + val apiParams = mutableMapOf( + "userId" to userId, + "email" to email, + "url" to url, + "phrase" to phrase, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Token = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Token.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Token::class.java, + converter, + ) + } + + + /** + * Create phone token + * + * Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * + * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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] + */ + suspend fun createPhoneToken( + userId: String, + phone: String, + ): io.appwrite.models.Token { + val apiPath = "/account/tokens/phone" + + val apiParams = mutableMapOf( + "userId" to userId, + "phone" to phone, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Token = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Token.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Token::class.java, + converter, + ) + } + + /** * Create email verification * @@ -1144,6 +1611,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } return client.call( @@ -1180,6 +1648,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } return client.call( @@ -1210,6 +1679,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } return client.call( @@ -1246,6 +1716,7 @@ class Account : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } return client.call( diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt index 27b7cde..e70fcda 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -2,7 +2,9 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client +import io.appwrite.Service import io.appwrite.models.* +import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import okhttp3.Cookie @@ -13,9 +15,7 @@ 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) { } +class Avatars(client: Client) : Service(client) { /** * Get browser icon @@ -30,13 +30,13 @@ class Avatars : Service { */ @JvmOverloads suspend fun getBrowser( - code: String, + code: Browser, width: Long? = null, height: Long? = null, quality: Long? = null, ): ByteArray { val apiPath = "/avatars/browsers/{code}" - .replace("{code}", code) + .replace("{code}", code.value) val apiParams = mutableMapOf( "width" to width, @@ -66,13 +66,13 @@ class Avatars : Service { */ @JvmOverloads suspend fun getCreditCard( - code: String, + code: CreditCard, width: Long? = null, height: Long? = null, quality: Long? = null, ): ByteArray { val apiPath = "/avatars/credit-cards/{code}" - .replace("{code}", code) + .replace("{code}", code.value) val apiParams = mutableMapOf( "width" to width, @@ -128,13 +128,13 @@ class Avatars : Service { */ @JvmOverloads suspend fun getFlag( - code: String, + code: Flag, width: Long? = null, height: Long? = null, quality: Long? = null, ): ByteArray { val apiPath = "/avatars/flags/{code}" - .replace("{code}", code) + .replace("{code}", code.value) val apiParams = mutableMapOf( "width" to width, diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index 4329b35..70ecf23 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -2,7 +2,9 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client +import io.appwrite.Service import io.appwrite.models.* +import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import okhttp3.Cookie @@ -11,9 +13,7 @@ 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) { } +class Databases(client: Client) : Service(client) { /** * List documents @@ -43,6 +43,7 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.DocumentList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.DocumentList.from(map = it as Map, nestedType) } return client.call( @@ -112,6 +113,7 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Document.from(map = it as Map, nestedType) } return client.call( @@ -161,7 +163,7 @@ 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. - * @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 method allowed is select. + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.Document] */ @JvmOverloads @@ -184,6 +186,7 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Document.from(map = it as Map, nestedType) } return client.call( @@ -204,7 +207,7 @@ 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. - * @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 method allowed is select. + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.Document] */ @JvmOverloads @@ -256,6 +259,7 @@ class Databases : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Document.from(map = it as Map, nestedType) } return client.call( diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index 257a130..d6cd35f 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -2,7 +2,9 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client +import io.appwrite.Service import io.appwrite.models.* +import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import okhttp3.Cookie @@ -11,9 +13,7 @@ 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) { } +class Functions(client: Client) : Service(client) { /** * List executions @@ -42,6 +42,7 @@ class Functions : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.ExecutionList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.ExecutionList.from(map = it as Map) } return client.call( @@ -74,7 +75,7 @@ class Functions : Service { body: String? = null, async: Boolean? = null, path: String? = null, - method: String? = null, + method: ExecutionMethod? = null, headers: Any? = null, ): io.appwrite.models.Execution { val apiPath = "/functions/{functionId}/executions" @@ -91,6 +92,7 @@ class Functions : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Execution = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Execution.from(map = it as Map) } return client.call( @@ -127,6 +129,7 @@ class Functions : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Execution = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Execution.from(map = it as Map) } return client.call( diff --git a/library/src/main/java/io/appwrite/services/Graphql.kt b/library/src/main/java/io/appwrite/services/Graphql.kt index 3a925d5..6c977a2 100644 --- a/library/src/main/java/io/appwrite/services/Graphql.kt +++ b/library/src/main/java/io/appwrite/services/Graphql.kt @@ -2,7 +2,9 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client +import io.appwrite.Service import io.appwrite.models.* +import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import okhttp3.Cookie @@ -11,9 +13,7 @@ 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) { } +class Graphql(client: Client) : Service(client) { /** * GraphQL endpoint diff --git a/library/src/main/java/io/appwrite/services/Locale.kt b/library/src/main/java/io/appwrite/services/Locale.kt index 510f451..ad3a6f6 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -2,7 +2,9 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client +import io.appwrite.Service import io.appwrite.models.* +import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import okhttp3.Cookie @@ -11,9 +13,7 @@ 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) { } +class Locale(client: Client) : Service(client) { /** * Get user locale @@ -32,6 +32,7 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Locale = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Locale.from(map = it as Map) } return client.call( @@ -62,6 +63,7 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LocaleCodeList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.LocaleCodeList.from(map = it as Map) } return client.call( @@ -92,6 +94,7 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.ContinentList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.ContinentList.from(map = it as Map) } return client.call( @@ -122,6 +125,7 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CountryList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.CountryList.from(map = it as Map) } return client.call( @@ -152,6 +156,7 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CountryList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.CountryList.from(map = it as Map) } return client.call( @@ -182,6 +187,7 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.PhoneList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.PhoneList.from(map = it as Map) } return client.call( @@ -212,6 +218,7 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CurrencyList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.CurrencyList.from(map = it as Map) } return client.call( @@ -242,6 +249,7 @@ class Locale : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LanguageList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.LanguageList.from(map = it as Map) } return client.call( diff --git a/library/src/main/java/io/appwrite/services/Messaging.kt b/library/src/main/java/io/appwrite/services/Messaging.kt new file mode 100644 index 0000000..eefe935 --- /dev/null +++ b/library/src/main/java/io/appwrite/services/Messaging.kt @@ -0,0 +1,90 @@ +package io.appwrite.services + +import android.net.Uri +import io.appwrite.Client +import io.appwrite.Service +import io.appwrite.models.* +import io.appwrite.enums.* +import io.appwrite.exceptions.AppwriteException +import io.appwrite.extensions.classOf +import okhttp3.Cookie +import java.io.File + +/** + * The Messaging service allows you to send messages to any provider type (SMTP, push notification, SMS, etc.). +**/ +class Messaging(client: Client) : Service(client) { + + /** + * Create a subscriber. + * + * + * + * @param topicId Topic ID. The topic ID to subscribe to. + * @param subscriberId Subscriber ID. Choose a custom Subscriber ID or a new Subscriber ID. + * @param targetId Target ID. The target ID to link to the specified Topic ID. + * @return [io.appwrite.models.Subscriber] + */ + suspend fun createSubscriber( + topicId: String, + subscriberId: String, + targetId: String, + ): io.appwrite.models.Subscriber { + val apiPath = "/messaging/topics/{topicId}/subscribers" + .replace("{topicId}", topicId) + + val apiParams = mutableMapOf( + "subscriberId" to subscriberId, + "targetId" to targetId, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Subscriber = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Subscriber.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Subscriber::class.java, + converter, + ) + } + + + /** + * Delete a subscriber. + * + * + * + * @param topicId Topic ID. The topic ID subscribed to. + * @param subscriberId Subscriber ID. + * @return [Any] + */ + suspend fun deleteSubscriber( + topicId: String, + subscriberId: String, + ): Any { + val apiPath = "/messaging/topics/{topicId}/subscribers/{subscriberId}" + .replace("{topicId}", topicId) + .replace("{subscriberId}", subscriberId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = Any::class.java, + ) + } + + +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Realtime.kt b/library/src/main/java/io/appwrite/services/Realtime.kt index 316054a..c2c7d9e 100644 --- a/library/src/main/java/io/appwrite/services/Realtime.kt +++ b/library/src/main/java/io/appwrite/services/Realtime.kt @@ -1,5 +1,6 @@ package io.appwrite.services +import io.appwrite.Service import io.appwrite.Client import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.forEachAsync @@ -55,7 +56,7 @@ class Realtime(client: Client) : Service(client), CoroutineScope { } val request = Request.Builder() - .url("${client.endPointRealtime}/realtime?$queryParamBuilder") + .url("${client.endpointRealtime}/realtime?$queryParamBuilder") .build() if (socket != null) { diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index 2b49f56..8407f3d 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -2,7 +2,9 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client +import io.appwrite.Service import io.appwrite.models.* +import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import okhttp3.Cookie @@ -13,9 +15,7 @@ import java.io.File /** * The Storage service allows you to manage your project files. **/ -class Storage : Service { - - public constructor (client: Client) : super(client) { } +class Storage(client: Client) : Service(client) { /** * List files @@ -44,6 +44,7 @@ class Storage : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.FileList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.FileList.from(map = it as Map) } return client.call( @@ -88,6 +89,7 @@ class Storage : Service { "content-type" to "multipart/form-data", ) val converter: (Any) -> io.appwrite.models.File = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.File.from(map = it as Map) } val idParamName: String? = "fileId" @@ -128,6 +130,7 @@ class Storage : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.File = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.File.from(map = it as Map) } return client.call( @@ -171,6 +174,7 @@ class Storage : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.File = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.File.from(map = it as Map) } return client.call( @@ -271,7 +275,7 @@ class Storage : Service { fileId: String, width: Long? = null, height: Long? = null, - gravity: String? = null, + gravity: ImageGravity? = null, quality: Long? = null, borderWidth: Long? = null, borderColor: String? = null, @@ -279,7 +283,7 @@ class Storage : Service { opacity: Double? = null, rotation: Long? = null, background: String? = null, - output: String? = null, + output: ImageFormat? = null, ): ByteArray { val apiPath = "/storage/buckets/{bucketId}/files/{fileId}/preview" .replace("{bucketId}", bucketId) diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 7f303ab..304e60d 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -2,7 +2,9 @@ package io.appwrite.services import android.net.Uri import io.appwrite.Client +import io.appwrite.Service import io.appwrite.models.* +import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import okhttp3.Cookie @@ -11,16 +13,14 @@ 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) { } +class Teams(client: Client) : Service(client) { /** * 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. * - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total, billingPlan * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.TeamList] */ @@ -40,6 +40,7 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.TeamList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.TeamList.from(map = it as Map, nestedType) } return client.call( @@ -57,7 +58,7 @@ class Teams : Service { * * Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results. * - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total, billingPlan * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.TeamList] */ @@ -100,6 +101,7 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Team = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Team.from(map = it as Map, nestedType) } return client.call( @@ -156,6 +158,7 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Team = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Team.from(map = it as Map, nestedType) } return client.call( @@ -208,6 +211,7 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Team = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Team.from(map = it as Map, nestedType) } return client.call( @@ -295,6 +299,7 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MembershipList = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.MembershipList.from(map = it as Map) } return client.call( @@ -347,6 +352,7 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Membership.from(map = it as Map) } return client.call( @@ -383,6 +389,7 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Membership.from(map = it as Map) } return client.call( @@ -422,6 +429,7 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Membership.from(map = it as Map) } return client.call( @@ -496,6 +504,7 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Membership.from(map = it as Map) } return client.call( @@ -530,6 +539,7 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Preferences.from(map = it as Map, nestedType) } return client.call( @@ -582,6 +592,7 @@ class Teams : Service { "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { + @Suppress("UNCHECKED_CAST") io.appwrite.models.Preferences.from(map = it as Map, nestedType) } return client.call( diff --git a/scripts/publish-module.gradle b/scripts/publish-module.gradle index e32ff84..96b31b2 100644 --- a/scripts/publish-module.gradle +++ b/scripts/publish-module.gradle @@ -63,7 +63,8 @@ publishing { configurations .getByName("releaseCompileClasspath") .resolvedConfiguration - .firstLevelModuleDependencies.forEach { + .firstLevelModuleDependencies + .forEach { def dependency = dependencies.appendNode("dependency") dependency.appendNode("groupId", it.moduleGroup) dependency.appendNode("artifactId", it.moduleName) diff --git a/settings.gradle b/settings.gradle index 73c359b..423c64e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,3 @@ rootProject.name = "Appwrite Android SDK" include ':example' -include ':library' -include ':example-java' \ No newline at end of file +include ':library' \ No newline at end of file From 77162806605567d214ed1ea23921a21f6466f0e0 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 19 Feb 2024 17:00:28 +1300 Subject: [PATCH 063/118] Release candidate for 1.5.x --- README.md | 4 ++-- docs/examples/java/account/add-authenticator.md | 4 ++-- docs/examples/java/account/create2f-a-challenge.md | 4 ++-- docs/examples/java/account/delete-authenticator.md | 4 ++-- docs/examples/java/account/verify-authenticator.md | 4 ++-- docs/examples/kotlin/account/add-authenticator.md | 4 ++-- docs/examples/kotlin/account/create2f-a-challenge.md | 4 ++-- docs/examples/kotlin/account/delete-authenticator.md | 4 ++-- docs/examples/kotlin/account/verify-authenticator.md | 4 ++-- library/src/main/java/io/appwrite/Client.kt | 4 ++-- .../enums/{Factor.kt => AuthenticationFactor.kt} | 2 +- .../appwrite/enums/{Type.kt => AuthenticatorType.kt} | 2 +- .../src/main/java/io/appwrite/services/Account.kt | 12 ++++++------ 13 files changed, 28 insertions(+), 28 deletions(-) rename library/src/main/java/io/appwrite/enums/{Factor.kt => AuthenticationFactor.kt} (69%) rename library/src/main/java/io/appwrite/enums/{Type.kt => AuthenticatorType.kt} (62%) diff --git a/README.md b/README.md index f381415..1824a95 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:5.0.0-rc.2") +implementation("io.appwrite:sdk-for-android:5.0.0-rc.3") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 5.0.0-rc.2 + 5.0.0-rc.3 ``` diff --git a/docs/examples/java/account/add-authenticator.md b/docs/examples/java/account/add-authenticator.md index ebb7d12..71dd8d3 100644 --- a/docs/examples/java/account/add-authenticator.md +++ b/docs/examples/java/account/add-authenticator.md @@ -1,7 +1,7 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; -import io.appwrite.enums.Type; +import io.appwrite.enums.AuthenticatorType; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -10,7 +10,7 @@ Client client = new Client(context) Account account = new Account(client); account.addAuthenticator( - type.TOTP, + AuthenticatorType.TOTP, new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/create2f-a-challenge.md b/docs/examples/java/account/create2f-a-challenge.md index 47fa615..28641da 100644 --- a/docs/examples/java/account/create2f-a-challenge.md +++ b/docs/examples/java/account/create2f-a-challenge.md @@ -1,7 +1,7 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; -import io.appwrite.enums.Factor; +import io.appwrite.enums.AuthenticationFactor; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -10,7 +10,7 @@ Client client = new Client(context) Account account = new Account(client); account.create2FAChallenge( - factor.TOTP, + AuthenticationFactor.TOTP, new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/delete-authenticator.md b/docs/examples/java/account/delete-authenticator.md index ba690b3..83f0203 100644 --- a/docs/examples/java/account/delete-authenticator.md +++ b/docs/examples/java/account/delete-authenticator.md @@ -1,7 +1,7 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; -import io.appwrite.enums.Type; +import io.appwrite.enums.AuthenticatorType; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -10,7 +10,7 @@ Client client = new Client(context) Account account = new Account(client); account.deleteAuthenticator( - type.TOTP, + AuthenticatorType.TOTP, "[OTP]", new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/account/verify-authenticator.md b/docs/examples/java/account/verify-authenticator.md index 0d10030..fe8ec33 100644 --- a/docs/examples/java/account/verify-authenticator.md +++ b/docs/examples/java/account/verify-authenticator.md @@ -1,7 +1,7 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; -import io.appwrite.enums.Type; +import io.appwrite.enums.AuthenticatorType; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -10,7 +10,7 @@ Client client = new Client(context) Account account = new Account(client); account.verifyAuthenticator( - type.TOTP, + AuthenticatorType.TOTP, "[OTP]", new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/kotlin/account/add-authenticator.md b/docs/examples/kotlin/account/add-authenticator.md index 96a9c6e..08e83a4 100644 --- a/docs/examples/kotlin/account/add-authenticator.md +++ b/docs/examples/kotlin/account/add-authenticator.md @@ -1,7 +1,7 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account -import io.appwrite.enums.Type +import io.appwrite.enums.AuthenticatorType val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -10,5 +10,5 @@ val client = Client(context) val account = Account(client) val response = account.addAuthenticator( - type = type.TOTP, + type = AuthenticatorType.TOTP, ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create2f-a-challenge.md b/docs/examples/kotlin/account/create2f-a-challenge.md index fcc483e..4608491 100644 --- a/docs/examples/kotlin/account/create2f-a-challenge.md +++ b/docs/examples/kotlin/account/create2f-a-challenge.md @@ -1,7 +1,7 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account -import io.appwrite.enums.Factor +import io.appwrite.enums.AuthenticationFactor val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -10,5 +10,5 @@ val client = Client(context) val account = Account(client) val response = account.create2FAChallenge( - factor = factor.TOTP, + factor = AuthenticationFactor.TOTP, ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-authenticator.md b/docs/examples/kotlin/account/delete-authenticator.md index b43fc54..44de084 100644 --- a/docs/examples/kotlin/account/delete-authenticator.md +++ b/docs/examples/kotlin/account/delete-authenticator.md @@ -1,7 +1,7 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account -import io.appwrite.enums.Type +import io.appwrite.enums.AuthenticatorType val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -10,6 +10,6 @@ val client = Client(context) val account = Account(client) val response = account.deleteAuthenticator( - type = type.TOTP, + type = AuthenticatorType.TOTP, otp = "[OTP]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/verify-authenticator.md b/docs/examples/kotlin/account/verify-authenticator.md index ec9943c..aee1dc9 100644 --- a/docs/examples/kotlin/account/verify-authenticator.md +++ b/docs/examples/kotlin/account/verify-authenticator.md @@ -1,7 +1,7 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account -import io.appwrite.enums.Type +import io.appwrite.enums.AuthenticatorType val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint @@ -10,6 +10,6 @@ val client = Client(context) val account = Account(client) val response = account.verifyAuthenticator( - type = type.TOTP, + type = AuthenticatorType.TOTP, otp = "[OTP]", ) \ 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 f04ea23..c0d039f 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -83,8 +83,8 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "5.0.0-rc.2", - "x-appwrite-response-format" to "1.4.0" + "x-sdk-version" to "5.0.0-rc.3", + "x-appwrite-response-format" to "1.5.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/enums/Factor.kt b/library/src/main/java/io/appwrite/enums/AuthenticationFactor.kt similarity index 69% rename from library/src/main/java/io/appwrite/enums/Factor.kt rename to library/src/main/java/io/appwrite/enums/AuthenticationFactor.kt index 1c705c8..3303e0b 100644 --- a/library/src/main/java/io/appwrite/enums/Factor.kt +++ b/library/src/main/java/io/appwrite/enums/AuthenticationFactor.kt @@ -1,6 +1,6 @@ package io.appwrite.enums -enum class Factor(val value: String) { +enum class AuthenticationFactor(val value: String) { TOTP("totp"), PHONE("phone"), EMAIL("email"); diff --git a/library/src/main/java/io/appwrite/enums/Type.kt b/library/src/main/java/io/appwrite/enums/AuthenticatorType.kt similarity index 62% rename from library/src/main/java/io/appwrite/enums/Type.kt rename to library/src/main/java/io/appwrite/enums/AuthenticatorType.kt index 51a06b4..27e1635 100644 --- a/library/src/main/java/io/appwrite/enums/Type.kt +++ b/library/src/main/java/io/appwrite/enums/AuthenticatorType.kt @@ -1,6 +1,6 @@ package io.appwrite.enums -enum class Type(val value: String) { +enum class AuthenticatorType(val value: String) { TOTP("totp"); override fun toString() = value diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index b9a4b96..ccc2c29 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -378,7 +378,7 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.MfaChallenge] */ suspend fun create2FAChallenge( - factor: Factor, + factor: AuthenticationFactor, ): io.appwrite.models.MfaChallenge { val apiPath = "/account/mfa/challenge" @@ -475,7 +475,7 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.MfaType] */ suspend fun addAuthenticator( - type: Type, + type: AuthenticatorType, ): io.appwrite.models.MfaType { val apiPath = "/account/mfa/{type}" .replace("{type}", type.value) @@ -510,7 +510,7 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.User] */ suspend fun verifyAuthenticator( - type: Type, + type: AuthenticatorType, otp: String, nestedType: Class, ): io.appwrite.models.User { @@ -548,7 +548,7 @@ class Account(client: Client) : Service(client) { */ @Throws(AppwriteException::class) suspend fun verifyAuthenticator( - type: Type, + type: AuthenticatorType, otp: String, ): io.appwrite.models.User> = verifyAuthenticator( type, @@ -566,7 +566,7 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.User] */ suspend fun deleteAuthenticator( - type: Type, + type: AuthenticatorType, otp: String, nestedType: Class, ): io.appwrite.models.User { @@ -604,7 +604,7 @@ class Account(client: Client) : Service(client) { */ @Throws(AppwriteException::class) suspend fun deleteAuthenticator( - type: Type, + type: AuthenticatorType, otp: String, ): io.appwrite.models.User> = deleteAuthenticator( type, From 956492a88794043301f6205dce2d0d1682390803 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 21 Feb 2024 23:36:01 +1300 Subject: [PATCH 064/118] Release candidate 4 for 1.5.x --- README.md | 6 +++--- .../examples/java/account/add-authenticator.md | 5 +++-- .../account/create-email-password-session.md | 7 ++++--- .../java/account/create-email-token.md | 8 +++++--- .../java/account/create-magic-u-r-l-token.md | 9 ++++++--- .../java/account/create-o-auth2session.md | 9 +++++++-- .../java/account/create-phone-token.md | 7 ++++--- .../java/account/create-push-target.md | 8 +++++--- docs/examples/java/account/create-recovery.md | 7 ++++--- docs/examples/java/account/create-session.md | 7 ++++--- .../java/account/create-verification.md | 5 +++-- docs/examples/java/account/create.md | 10 ++++++---- .../java/account/create2f-a-challenge.md | 5 +++-- .../java/account/delete-authenticator.md | 7 ++++--- docs/examples/java/account/delete-identity.md | 5 +++-- .../java/account/delete-push-target.md | 5 +++-- docs/examples/java/account/delete-session.md | 5 +++-- docs/examples/java/account/get-session.md | 5 +++-- docs/examples/java/account/list-identities.md | 4 +++- docs/examples/java/account/list-logs.md | 4 +++- docs/examples/java/account/update-challenge.md | 7 ++++--- docs/examples/java/account/update-email.md | 7 ++++--- docs/examples/java/account/update-m-f-a.md | 5 +++-- .../java/account/update-magic-u-r-l-session.md | 7 ++++--- docs/examples/java/account/update-name.md | 5 +++-- docs/examples/java/account/update-password.md | 6 ++++-- .../java/account/update-phone-verification.md | 7 ++++--- docs/examples/java/account/update-phone.md | 7 ++++--- docs/examples/java/account/update-prefs.md | 5 +++-- .../java/account/update-push-target.md | 7 ++++--- docs/examples/java/account/update-recovery.md | 9 +++++---- docs/examples/java/account/update-session.md | 5 +++-- .../java/account/update-verification.md | 7 ++++--- .../java/account/verify-authenticator.md | 7 ++++--- docs/examples/java/avatars/get-browser.md | 8 ++++++-- docs/examples/java/avatars/get-credit-card.md | 8 ++++++-- docs/examples/java/avatars/get-favicon.md | 5 +++-- docs/examples/java/avatars/get-flag.md | 8 ++++++-- docs/examples/java/avatars/get-image.md | 7 +++++-- docs/examples/java/avatars/get-initials.md | 7 ++++++- docs/examples/java/avatars/get-q-r.md | 8 ++++++-- .../examples/java/databases/create-document.md | 12 +++++++----- .../examples/java/databases/delete-document.md | 9 +++++---- docs/examples/java/databases/get-document.md | 10 ++++++---- docs/examples/java/databases/list-documents.md | 8 +++++--- .../examples/java/databases/update-document.md | 11 +++++++---- .../java/functions/create-execution.md | 10 ++++++++-- docs/examples/java/functions/get-execution.md | 7 ++++--- .../examples/java/functions/list-executions.md | 7 +++++-- docs/examples/java/graphql/mutation.md | 5 +++-- docs/examples/java/graphql/query.md | 5 +++-- .../java/messaging/create-subscriber.md | 9 +++++---- .../java/messaging/delete-subscriber.md | 7 ++++--- docs/examples/java/storage/create-file.md | 10 ++++++---- docs/examples/java/storage/delete-file.md | 7 ++++--- .../examples/java/storage/get-file-download.md | 7 ++++--- docs/examples/java/storage/get-file-preview.md | 18 +++++++++++++++--- docs/examples/java/storage/get-file-view.md | 7 ++++--- docs/examples/java/storage/get-file.md | 7 ++++--- docs/examples/java/storage/list-files.md | 7 +++++-- docs/examples/java/storage/update-file.md | 9 ++++++--- docs/examples/java/teams/create-membership.md | 12 +++++++++--- docs/examples/java/teams/create.md | 8 +++++--- docs/examples/java/teams/delete-membership.md | 7 ++++--- docs/examples/java/teams/delete.md | 5 +++-- docs/examples/java/teams/get-membership.md | 7 ++++--- docs/examples/java/teams/get-prefs.md | 5 +++-- docs/examples/java/teams/get.md | 5 +++-- docs/examples/java/teams/list-memberships.md | 7 +++++-- docs/examples/java/teams/list.md | 5 ++++- .../java/teams/update-membership-status.md | 11 ++++++----- docs/examples/java/teams/update-membership.md | 9 +++++---- docs/examples/java/teams/update-name.md | 7 ++++--- docs/examples/java/teams/update-prefs.md | 7 ++++--- .../account/create-email-password-session.md | 4 ++-- .../kotlin/account/create-email-token.md | 5 +++-- .../kotlin/account/create-magic-u-r-l-token.md | 6 ++++-- .../kotlin/account/create-o-auth2session.md | 4 ++++ .../kotlin/account/create-phone-token.md | 4 ++-- .../kotlin/account/create-push-target.md | 5 +++-- .../examples/kotlin/account/create-recovery.md | 4 ++-- docs/examples/kotlin/account/create-session.md | 4 ++-- .../kotlin/account/create-verification.md | 2 +- docs/examples/kotlin/account/create.md | 7 ++++--- .../kotlin/account/delete-authenticator.md | 2 +- .../examples/kotlin/account/delete-identity.md | 2 +- .../kotlin/account/delete-push-target.md | 2 +- docs/examples/kotlin/account/delete-session.md | 2 +- docs/examples/kotlin/account/get-session.md | 2 +- .../examples/kotlin/account/list-identities.md | 1 + docs/examples/kotlin/account/list-logs.md | 1 + .../kotlin/account/update-challenge.md | 4 ++-- docs/examples/kotlin/account/update-email.md | 4 ++-- docs/examples/kotlin/account/update-m-f-a.md | 2 +- .../account/update-magic-u-r-l-session.md | 4 ++-- docs/examples/kotlin/account/update-name.md | 2 +- .../examples/kotlin/account/update-password.md | 3 ++- .../account/update-phone-verification.md | 4 ++-- docs/examples/kotlin/account/update-phone.md | 4 ++-- docs/examples/kotlin/account/update-prefs.md | 2 +- .../kotlin/account/update-push-target.md | 4 ++-- .../examples/kotlin/account/update-recovery.md | 6 +++--- docs/examples/kotlin/account/update-session.md | 2 +- .../kotlin/account/update-verification.md | 4 ++-- .../kotlin/account/verify-authenticator.md | 2 +- docs/examples/kotlin/avatars/get-browser.md | 3 +++ .../examples/kotlin/avatars/get-credit-card.md | 3 +++ docs/examples/kotlin/avatars/get-favicon.md | 2 +- docs/examples/kotlin/avatars/get-flag.md | 3 +++ docs/examples/kotlin/avatars/get-image.md | 4 +++- docs/examples/kotlin/avatars/get-initials.md | 4 ++++ docs/examples/kotlin/avatars/get-q-r.md | 5 ++++- .../kotlin/databases/create-document.md | 9 +++++---- .../kotlin/databases/delete-document.md | 6 +++--- docs/examples/kotlin/databases/get-document.md | 7 ++++--- .../kotlin/databases/list-documents.md | 5 +++-- .../kotlin/databases/update-document.md | 8 +++++--- .../kotlin/functions/create-execution.md | 7 ++++++- .../examples/kotlin/functions/get-execution.md | 4 ++-- .../kotlin/functions/list-executions.md | 4 +++- docs/examples/kotlin/graphql/mutation.md | 2 +- docs/examples/kotlin/graphql/query.md | 2 +- .../kotlin/messaging/create-subscriber.md | 6 +++--- .../kotlin/messaging/delete-subscriber.md | 4 ++-- docs/examples/kotlin/storage/create-file.md | 7 ++++--- docs/examples/kotlin/storage/delete-file.md | 4 ++-- .../kotlin/storage/get-file-download.md | 4 ++-- .../kotlin/storage/get-file-preview.md | 15 +++++++++++++-- docs/examples/kotlin/storage/get-file-view.md | 4 ++-- docs/examples/kotlin/storage/get-file.md | 4 ++-- docs/examples/kotlin/storage/list-files.md | 4 +++- docs/examples/kotlin/storage/update-file.md | 6 ++++-- .../examples/kotlin/teams/create-membership.md | 9 +++++++-- docs/examples/kotlin/teams/create.md | 5 +++-- .../examples/kotlin/teams/delete-membership.md | 4 ++-- docs/examples/kotlin/teams/delete.md | 2 +- docs/examples/kotlin/teams/get-membership.md | 4 ++-- docs/examples/kotlin/teams/get-prefs.md | 2 +- docs/examples/kotlin/teams/get.md | 2 +- docs/examples/kotlin/teams/list-memberships.md | 4 +++- docs/examples/kotlin/teams/list.md | 2 ++ .../kotlin/teams/update-membership-status.md | 8 ++++---- .../examples/kotlin/teams/update-membership.md | 6 +++--- docs/examples/kotlin/teams/update-name.md | 4 ++-- docs/examples/kotlin/teams/update-prefs.md | 4 ++-- example/build.gradle | 8 ++++---- example/src/main/AndroidManifest.xml | 2 +- library/src/main/java/io/appwrite/Client.kt | 2 +- .../java/io/appwrite/services/Messaging.kt | 8 ++++---- 149 files changed, 531 insertions(+), 322 deletions(-) diff --git a/README.md b/README.md index 1824a95..61632fd 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![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.4.13-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.5.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) @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:5.0.0-rc.3") +implementation("io.appwrite:sdk-for-android:5.0.0-rc.4") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 5.0.0-rc.3 + 5.0.0-rc.4 ``` diff --git a/docs/examples/java/account/add-authenticator.md b/docs/examples/java/account/add-authenticator.md index 71dd8d3..e81255d 100644 --- a/docs/examples/java/account/add-authenticator.md +++ b/docs/examples/java/account/add-authenticator.md @@ -10,7 +10,7 @@ Client client = new Client(context) Account account = new Account(client); account.addAuthenticator( - AuthenticatorType.TOTP, + AuthenticatorType.TOTP, // type new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,5 @@ account.addAuthenticator( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/create-email-password-session.md b/docs/examples/java/account/create-email-password-session.md index e3cd353..85d460e 100644 --- a/docs/examples/java/account/create-email-password-session.md +++ b/docs/examples/java/account/create-email-password-session.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.createEmailPasswordSession( - "email@example.com", - "password", + "email@example.com", // email + "password", // password new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,5 @@ account.createEmailPasswordSession( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/create-email-token.md b/docs/examples/java/account/create-email-token.md index f032eb6..c308ca7 100644 --- a/docs/examples/java/account/create-email-token.md +++ b/docs/examples/java/account/create-email-token.md @@ -9,8 +9,9 @@ Client client = new Client(context) Account account = new Account(client); account.createEmailToken( - "[USER_ID]", - "email@example.com", + "[USER_ID]", // userId + "email@example.com", // email + false, // phrase (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +20,5 @@ account.createEmailToken( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/create-magic-u-r-l-token.md b/docs/examples/java/account/create-magic-u-r-l-token.md index 48a8b9b..c3a3392 100644 --- a/docs/examples/java/account/create-magic-u-r-l-token.md +++ b/docs/examples/java/account/create-magic-u-r-l-token.md @@ -9,8 +9,10 @@ Client client = new Client(context) Account account = new Account(client); account.createMagicURLToken( - "[USER_ID]", - "email@example.com", + "[USER_ID]", // userId + "email@example.com", // email + "https://example.com", // url (optional) + false, // phrase (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +21,5 @@ account.createMagicURLToken( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/create-o-auth2session.md b/docs/examples/java/account/create-o-auth2session.md index 1389673..1e1a3b2 100644 --- a/docs/examples/java/account/create-o-auth2session.md +++ b/docs/examples/java/account/create-o-auth2session.md @@ -10,7 +10,11 @@ Client client = new Client(context) Account account = new Account(client); account.createOAuth2Session( - OAuthProvider.AMAZON, + OAuthProvider.AMAZON, // provider + "https://example.com", // success (optional) + "https://example.com", // failure (optional) + false, // token (optional) + listOf(), // scopes (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +23,5 @@ account.createOAuth2Session( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/create-phone-token.md b/docs/examples/java/account/create-phone-token.md index a839e81..a47d57b 100644 --- a/docs/examples/java/account/create-phone-token.md +++ b/docs/examples/java/account/create-phone-token.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.createPhoneToken( - "[USER_ID]", - "+12065550100", + "[USER_ID]", // userId + "+12065550100", // phone new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,5 @@ account.createPhoneToken( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/create-push-target.md b/docs/examples/java/account/create-push-target.md index 18a5e76..8268bee 100644 --- a/docs/examples/java/account/create-push-target.md +++ b/docs/examples/java/account/create-push-target.md @@ -9,8 +9,9 @@ Client client = new Client(context) Account account = new Account(client); account.createPushTarget( - "[TARGET_ID]", - "[IDENTIFIER]", + "[TARGET_ID]", // targetId + "[IDENTIFIER]", // identifier + "[PROVIDER_ID]", // providerId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +20,5 @@ account.createPushTarget( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/create-recovery.md b/docs/examples/java/account/create-recovery.md index f167af2..19006f6 100644 --- a/docs/examples/java/account/create-recovery.md +++ b/docs/examples/java/account/create-recovery.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.createRecovery( - "email@example.com", - "https://example.com", + "email@example.com", // email + "https://example.com", // url new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,5 @@ account.createRecovery( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/create-session.md b/docs/examples/java/account/create-session.md index d853209..b1805fa 100644 --- a/docs/examples/java/account/create-session.md +++ b/docs/examples/java/account/create-session.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.createSession( - "[USER_ID]", - "[SECRET]", + "[USER_ID]", // userId + "[SECRET]", // secret new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,5 @@ account.createSession( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/create-verification.md b/docs/examples/java/account/create-verification.md index eb7a537..254a31b 100644 --- a/docs/examples/java/account/create-verification.md +++ b/docs/examples/java/account/create-verification.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.createVerification( - "https://example.com", + "https://example.com", // url new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,5 @@ account.createVerification( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/create.md b/docs/examples/java/account/create.md index a16d2c7..dce55b7 100644 --- a/docs/examples/java/account/create.md +++ b/docs/examples/java/account/create.md @@ -9,9 +9,10 @@ Client client = new Client(context) Account account = new Account(client); account.create( - "[USER_ID]", - "email@example.com", - "", + "[USER_ID]", // userId + "email@example.com", // email + "", // password + "[NAME]", // name (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -20,4 +21,5 @@ account.create( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/create2f-a-challenge.md b/docs/examples/java/account/create2f-a-challenge.md index 28641da..e095df7 100644 --- a/docs/examples/java/account/create2f-a-challenge.md +++ b/docs/examples/java/account/create2f-a-challenge.md @@ -10,7 +10,7 @@ Client client = new Client(context) Account account = new Account(client); account.create2FAChallenge( - AuthenticationFactor.TOTP, + AuthenticationFactor.TOTP, // factor new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,5 @@ account.create2FAChallenge( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/delete-authenticator.md b/docs/examples/java/account/delete-authenticator.md index 83f0203..4525524 100644 --- a/docs/examples/java/account/delete-authenticator.md +++ b/docs/examples/java/account/delete-authenticator.md @@ -10,8 +10,8 @@ Client client = new Client(context) Account account = new Account(client); account.deleteAuthenticator( - AuthenticatorType.TOTP, - "[OTP]", + AuthenticatorType.TOTP, // type + "[OTP]", // otp new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -20,4 +20,5 @@ account.deleteAuthenticator( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/delete-identity.md b/docs/examples/java/account/delete-identity.md index f33c29a..5cc7178 100644 --- a/docs/examples/java/account/delete-identity.md +++ b/docs/examples/java/account/delete-identity.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.deleteIdentity( - "[IDENTITY_ID]", + "[IDENTITY_ID]", // identityId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,5 @@ account.deleteIdentity( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/delete-push-target.md b/docs/examples/java/account/delete-push-target.md index 77b21d6..f798ea9 100644 --- a/docs/examples/java/account/delete-push-target.md +++ b/docs/examples/java/account/delete-push-target.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.deletePushTarget( - "[TARGET_ID]", + "[TARGET_ID]", // targetId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,5 @@ account.deletePushTarget( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/delete-session.md b/docs/examples/java/account/delete-session.md index 2b8d228..9d11640 100644 --- a/docs/examples/java/account/delete-session.md +++ b/docs/examples/java/account/delete-session.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.deleteSession( - "[SESSION_ID]", + "[SESSION_ID]", // sessionId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,5 @@ account.deleteSession( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/get-session.md b/docs/examples/java/account/get-session.md index dd9c89c..fe01211 100644 --- a/docs/examples/java/account/get-session.md +++ b/docs/examples/java/account/get-session.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.getSession( - "[SESSION_ID]", + "[SESSION_ID]", // sessionId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,5 @@ account.getSession( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/list-identities.md b/docs/examples/java/account/list-identities.md index 08d4c19..cb5f74e 100644 --- a/docs/examples/java/account/list-identities.md +++ b/docs/examples/java/account/list-identities.md @@ -9,6 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.listIdentities( + listOf(), // queries (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -17,4 +18,5 @@ account.listIdentities( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/list-logs.md b/docs/examples/java/account/list-logs.md index f4c39fb..998d8a8 100644 --- a/docs/examples/java/account/list-logs.md +++ b/docs/examples/java/account/list-logs.md @@ -9,6 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.listLogs( + listOf(), // queries (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -17,4 +18,5 @@ account.listLogs( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/update-challenge.md b/docs/examples/java/account/update-challenge.md index d972a14..7e2d369 100644 --- a/docs/examples/java/account/update-challenge.md +++ b/docs/examples/java/account/update-challenge.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.updateChallenge( - "[CHALLENGE_ID]", - "[OTP]", + "[CHALLENGE_ID]", // challengeId + "[OTP]", // otp new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,5 @@ account.updateChallenge( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/update-email.md b/docs/examples/java/account/update-email.md index a7cb414..13c5b65 100644 --- a/docs/examples/java/account/update-email.md +++ b/docs/examples/java/account/update-email.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.updateEmail( - "email@example.com", - "password", + "email@example.com", // email + "password", // password new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,5 @@ account.updateEmail( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/update-m-f-a.md b/docs/examples/java/account/update-m-f-a.md index 16f6973..7c774c7 100644 --- a/docs/examples/java/account/update-m-f-a.md +++ b/docs/examples/java/account/update-m-f-a.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.updateMFA( - false, + false, // mfa new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,5 @@ account.updateMFA( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + 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 f46422b..697e00a 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 @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.updateMagicURLSession( - "[USER_ID]", - "[SECRET]", + "[USER_ID]", // userId + "[SECRET]", // secret new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,5 @@ account.updateMagicURLSession( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/update-name.md b/docs/examples/java/account/update-name.md index 8b27389..bc64afc 100644 --- a/docs/examples/java/account/update-name.md +++ b/docs/examples/java/account/update-name.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.updateName( - "[NAME]", + "[NAME]", // name new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,5 @@ account.updateName( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/update-password.md b/docs/examples/java/account/update-password.md index 430ab7e..764debf 100644 --- a/docs/examples/java/account/update-password.md +++ b/docs/examples/java/account/update-password.md @@ -9,7 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.updatePassword( - "", + "", // password + "password", // oldPassword (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +19,5 @@ account.updatePassword( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/update-phone-verification.md b/docs/examples/java/account/update-phone-verification.md index 7d66fd9..94c2eb2 100644 --- a/docs/examples/java/account/update-phone-verification.md +++ b/docs/examples/java/account/update-phone-verification.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.updatePhoneVerification( - "[USER_ID]", - "[SECRET]", + "[USER_ID]", // userId + "[SECRET]", // secret new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,5 @@ account.updatePhoneVerification( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/update-phone.md b/docs/examples/java/account/update-phone.md index c958911..795700a 100644 --- a/docs/examples/java/account/update-phone.md +++ b/docs/examples/java/account/update-phone.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.updatePhone( - "+12065550100", - "password", + "+12065550100", // phone + "password", // password new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,5 @@ account.updatePhone( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/update-prefs.md b/docs/examples/java/account/update-prefs.md index 5d2e75d..71eae4c 100644 --- a/docs/examples/java/account/update-prefs.md +++ b/docs/examples/java/account/update-prefs.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.updatePrefs( - mapOf( "a" to "b" ), + mapOf( "a" to "b" ), // prefs new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,5 @@ account.updatePrefs( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/update-push-target.md b/docs/examples/java/account/update-push-target.md index 10efbad..7dd97fd 100644 --- a/docs/examples/java/account/update-push-target.md +++ b/docs/examples/java/account/update-push-target.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.updatePushTarget( - "[TARGET_ID]", - "[IDENTIFIER]", + "[TARGET_ID]", // targetId + "[IDENTIFIER]", // identifier new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,5 @@ account.updatePushTarget( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/update-recovery.md b/docs/examples/java/account/update-recovery.md index 313eaa5..b009e43 100644 --- a/docs/examples/java/account/update-recovery.md +++ b/docs/examples/java/account/update-recovery.md @@ -9,9 +9,9 @@ Client client = new Client(context) Account account = new Account(client); account.updateRecovery( - "[USER_ID]", - "[SECRET]", - "", + "[USER_ID]", // userId + "[SECRET]", // secret + "", // password new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -20,4 +20,5 @@ account.updateRecovery( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/update-session.md b/docs/examples/java/account/update-session.md index 66eda54..aac43e4 100644 --- a/docs/examples/java/account/update-session.md +++ b/docs/examples/java/account/update-session.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.updateSession( - "[SESSION_ID]", + "[SESSION_ID]", // sessionId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,5 @@ account.updateSession( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/update-verification.md b/docs/examples/java/account/update-verification.md index 9beb1bd..f6020ae 100644 --- a/docs/examples/java/account/update-verification.md +++ b/docs/examples/java/account/update-verification.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.updateVerification( - "[USER_ID]", - "[SECRET]", + "[USER_ID]", // userId + "[SECRET]", // secret new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,5 @@ account.updateVerification( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/account/verify-authenticator.md b/docs/examples/java/account/verify-authenticator.md index fe8ec33..7d5efe4 100644 --- a/docs/examples/java/account/verify-authenticator.md +++ b/docs/examples/java/account/verify-authenticator.md @@ -10,8 +10,8 @@ Client client = new Client(context) Account account = new Account(client); account.verifyAuthenticator( - AuthenticatorType.TOTP, - "[OTP]", + AuthenticatorType.TOTP, // type + "[OTP]", // otp new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -20,4 +20,5 @@ account.verifyAuthenticator( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/avatars/get-browser.md b/docs/examples/java/avatars/get-browser.md index 0652a47..a7b9e7f 100644 --- a/docs/examples/java/avatars/get-browser.md +++ b/docs/examples/java/avatars/get-browser.md @@ -10,7 +10,10 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); avatars.getBrowser( - Browser.AVANT_BROWSER, + Browser.AVANT_BROWSER, // code + 0, // width (optional) + 0, // height (optional) + 0, // quality (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +22,5 @@ avatars.getBrowser( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/avatars/get-credit-card.md b/docs/examples/java/avatars/get-credit-card.md index 0f0541a..61a8a51 100644 --- a/docs/examples/java/avatars/get-credit-card.md +++ b/docs/examples/java/avatars/get-credit-card.md @@ -10,7 +10,10 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); avatars.getCreditCard( - CreditCard.AMERICAN_EXPRESS, + CreditCard.AMERICAN_EXPRESS, // code + 0, // width (optional) + 0, // height (optional) + 0, // quality (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +22,5 @@ avatars.getCreditCard( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/avatars/get-favicon.md b/docs/examples/java/avatars/get-favicon.md index cef5b08..d2f86c0 100644 --- a/docs/examples/java/avatars/get-favicon.md +++ b/docs/examples/java/avatars/get-favicon.md @@ -9,7 +9,7 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); avatars.getFavicon( - "https://example.com", + "https://example.com", // url new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,5 @@ avatars.getFavicon( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/avatars/get-flag.md b/docs/examples/java/avatars/get-flag.md index c931336..dc8cc29 100644 --- a/docs/examples/java/avatars/get-flag.md +++ b/docs/examples/java/avatars/get-flag.md @@ -10,7 +10,10 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); avatars.getFlag( - Flag.AFGHANISTAN, + Flag.AFGHANISTAN, // code + 0, // width (optional) + 0, // height (optional) + 0, // quality (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +22,5 @@ avatars.getFlag( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/avatars/get-image.md b/docs/examples/java/avatars/get-image.md index 8ae4df1..81e8029 100644 --- a/docs/examples/java/avatars/get-image.md +++ b/docs/examples/java/avatars/get-image.md @@ -9,7 +9,9 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); avatars.getImage( - "https://example.com", + "https://example.com", // url + 0, // width (optional) + 0, // height (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +20,5 @@ avatars.getImage( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/avatars/get-initials.md b/docs/examples/java/avatars/get-initials.md index 36757c4..d019a16 100644 --- a/docs/examples/java/avatars/get-initials.md +++ b/docs/examples/java/avatars/get-initials.md @@ -9,6 +9,10 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); avatars.getInitials( + "[NAME]", // name (optional) + 0, // width (optional) + 0, // height (optional) + "", // background (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -17,4 +21,5 @@ avatars.getInitials( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/avatars/get-q-r.md b/docs/examples/java/avatars/get-q-r.md index 4894433..19fbe7a 100644 --- a/docs/examples/java/avatars/get-q-r.md +++ b/docs/examples/java/avatars/get-q-r.md @@ -9,7 +9,10 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); avatars.getQR( - "[TEXT]", + "[TEXT]", // text + 1, // size (optional) + 0, // margin (optional) + false, // download (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +21,5 @@ avatars.getQR( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index c26a142..c409d8e 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -9,10 +9,11 @@ Client client = new Client(context) Databases databases = new Databases(client); databases.createDocument( - "[DATABASE_ID]", - "[COLLECTION_ID]", - "[DOCUMENT_ID]", - mapOf( "a" to "b" ), + "[DATABASE_ID]", // databaseId + "[COLLECTION_ID]", // collectionId + "[DOCUMENT_ID]", // documentId + mapOf( "a" to "b" ), // data + listOf("read("any")"), // permissions (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -21,4 +22,5 @@ databases.createDocument( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/databases/delete-document.md b/docs/examples/java/databases/delete-document.md index d59266b..8ab8f61 100644 --- a/docs/examples/java/databases/delete-document.md +++ b/docs/examples/java/databases/delete-document.md @@ -9,9 +9,9 @@ Client client = new Client(context) Databases databases = new Databases(client); databases.deleteDocument( - "[DATABASE_ID]", - "[COLLECTION_ID]", - "[DOCUMENT_ID]", + "[DATABASE_ID]", // databaseId + "[COLLECTION_ID]", // collectionId + "[DOCUMENT_ID]", // documentId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -20,4 +20,5 @@ databases.deleteDocument( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/databases/get-document.md b/docs/examples/java/databases/get-document.md index a63836e..4ee0d6d 100644 --- a/docs/examples/java/databases/get-document.md +++ b/docs/examples/java/databases/get-document.md @@ -9,9 +9,10 @@ Client client = new Client(context) Databases databases = new Databases(client); databases.getDocument( - "[DATABASE_ID]", - "[COLLECTION_ID]", - "[DOCUMENT_ID]", + "[DATABASE_ID]", // databaseId + "[COLLECTION_ID]", // collectionId + "[DOCUMENT_ID]", // documentId + listOf(), // queries (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -20,4 +21,5 @@ databases.getDocument( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/databases/list-documents.md b/docs/examples/java/databases/list-documents.md index 6f577ef..5aaf4f2 100644 --- a/docs/examples/java/databases/list-documents.md +++ b/docs/examples/java/databases/list-documents.md @@ -9,8 +9,9 @@ Client client = new Client(context) Databases databases = new Databases(client); databases.listDocuments( - "[DATABASE_ID]", - "[COLLECTION_ID]", + "[DATABASE_ID]", // databaseId + "[COLLECTION_ID]", // collectionId + listOf(), // queries (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +20,5 @@ databases.listDocuments( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/databases/update-document.md b/docs/examples/java/databases/update-document.md index ae4d539..ba1b7a8 100644 --- a/docs/examples/java/databases/update-document.md +++ b/docs/examples/java/databases/update-document.md @@ -9,9 +9,11 @@ Client client = new Client(context) Databases databases = new Databases(client); databases.updateDocument( - "[DATABASE_ID]", - "[COLLECTION_ID]", - "[DOCUMENT_ID]", + "[DATABASE_ID]", // databaseId + "[COLLECTION_ID]", // collectionId + "[DOCUMENT_ID]", // documentId + mapOf( "a" to "b" ), // data (optional) + listOf("read("any")"), // permissions (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -20,4 +22,5 @@ databases.updateDocument( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/functions/create-execution.md b/docs/examples/java/functions/create-execution.md index 985d502..ab1c32c 100644 --- a/docs/examples/java/functions/create-execution.md +++ b/docs/examples/java/functions/create-execution.md @@ -9,7 +9,12 @@ Client client = new Client(context) Functions functions = new Functions(client); functions.createExecution( - "[FUNCTION_ID]", + "[FUNCTION_ID]", // functionId + "[BODY]", // body (optional) + false, // async (optional) + "[PATH]", // path (optional) + ExecutionMethod.GET, // method (optional) + mapOf( "a" to "b" ), // headers (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +23,5 @@ functions.createExecution( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/functions/get-execution.md b/docs/examples/java/functions/get-execution.md index c066540..5f1a772 100644 --- a/docs/examples/java/functions/get-execution.md +++ b/docs/examples/java/functions/get-execution.md @@ -9,8 +9,8 @@ Client client = new Client(context) Functions functions = new Functions(client); functions.getExecution( - "[FUNCTION_ID]", - "[EXECUTION_ID]", + "[FUNCTION_ID]", // functionId + "[EXECUTION_ID]", // executionId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,5 @@ functions.getExecution( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/functions/list-executions.md b/docs/examples/java/functions/list-executions.md index 53f45ca..1405da6 100644 --- a/docs/examples/java/functions/list-executions.md +++ b/docs/examples/java/functions/list-executions.md @@ -9,7 +9,9 @@ Client client = new Client(context) Functions functions = new Functions(client); functions.listExecutions( - "[FUNCTION_ID]", + "[FUNCTION_ID]", // functionId + listOf(), // queries (optional) + "[SEARCH]", // search (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +20,5 @@ functions.listExecutions( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/graphql/mutation.md b/docs/examples/java/graphql/mutation.md index 5d140d6..a7e5f6e 100644 --- a/docs/examples/java/graphql/mutation.md +++ b/docs/examples/java/graphql/mutation.md @@ -9,7 +9,7 @@ Client client = new Client(context) Graphql graphql = new Graphql(client); graphql.mutation( - mapOf( "a" to "b" ), + mapOf( "a" to "b" ), // query new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,5 @@ graphql.mutation( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/graphql/query.md b/docs/examples/java/graphql/query.md index de693fa..a6420b4 100644 --- a/docs/examples/java/graphql/query.md +++ b/docs/examples/java/graphql/query.md @@ -9,7 +9,7 @@ Client client = new Client(context) Graphql graphql = new Graphql(client); graphql.query( - mapOf( "a" to "b" ), + mapOf( "a" to "b" ), // query new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,5 @@ graphql.query( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/messaging/create-subscriber.md b/docs/examples/java/messaging/create-subscriber.md index d071008..f059ae2 100644 --- a/docs/examples/java/messaging/create-subscriber.md +++ b/docs/examples/java/messaging/create-subscriber.md @@ -9,9 +9,9 @@ Client client = new Client(context) Messaging messaging = new Messaging(client); messaging.createSubscriber( - "[TOPIC_ID]", - "[SUBSCRIBER_ID]", - "[TARGET_ID]", + "[TOPIC_ID]", // topicId + "[SUBSCRIBER_ID]", // subscriberId + "[TARGET_ID]", // targetId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -20,4 +20,5 @@ messaging.createSubscriber( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/messaging/delete-subscriber.md b/docs/examples/java/messaging/delete-subscriber.md index a1d5686..ee2caa3 100644 --- a/docs/examples/java/messaging/delete-subscriber.md +++ b/docs/examples/java/messaging/delete-subscriber.md @@ -9,8 +9,8 @@ Client client = new Client(context) Messaging messaging = new Messaging(client); messaging.deleteSubscriber( - "[TOPIC_ID]", - "[SUBSCRIBER_ID]", + "[TOPIC_ID]", // topicId + "[SUBSCRIBER_ID]", // subscriberId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,5 @@ messaging.deleteSubscriber( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/storage/create-file.md b/docs/examples/java/storage/create-file.md index b99312b..3c67a7b 100644 --- a/docs/examples/java/storage/create-file.md +++ b/docs/examples/java/storage/create-file.md @@ -10,9 +10,10 @@ Client client = new Client(context) Storage storage = new Storage(client); storage.createFile( - "[BUCKET_ID]", - "[FILE_ID]", - InputFile.fromPath("file.png"), + "[BUCKET_ID]", // bucketId + "[FILE_ID]", // fileId + InputFile.fromPath("file.png"), // file + listOf("read("any")"), // permissions (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -21,4 +22,5 @@ storage.createFile( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/storage/delete-file.md b/docs/examples/java/storage/delete-file.md index 9ac7f2e..f216bbf 100644 --- a/docs/examples/java/storage/delete-file.md +++ b/docs/examples/java/storage/delete-file.md @@ -9,8 +9,8 @@ Client client = new Client(context) Storage storage = new Storage(client); storage.deleteFile( - "[BUCKET_ID]", - "[FILE_ID]", + "[BUCKET_ID]", // bucketId + "[FILE_ID]", // fileId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,5 @@ storage.deleteFile( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/storage/get-file-download.md b/docs/examples/java/storage/get-file-download.md index 7428cc0..a46ae8e 100644 --- a/docs/examples/java/storage/get-file-download.md +++ b/docs/examples/java/storage/get-file-download.md @@ -9,8 +9,8 @@ Client client = new Client(context) Storage storage = new Storage(client); storage.getFileDownload( - "[BUCKET_ID]", - "[FILE_ID]", + "[BUCKET_ID]", // bucketId + "[FILE_ID]", // fileId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,5 @@ storage.getFileDownload( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/storage/get-file-preview.md b/docs/examples/java/storage/get-file-preview.md index 6de0abf..dfe66a7 100644 --- a/docs/examples/java/storage/get-file-preview.md +++ b/docs/examples/java/storage/get-file-preview.md @@ -9,8 +9,19 @@ Client client = new Client(context) Storage storage = new Storage(client); storage.getFilePreview( - "[BUCKET_ID]", - "[FILE_ID]", + "[BUCKET_ID]", // bucketId + "[FILE_ID]", // fileId + 0, // width (optional) + 0, // height (optional) + ImageGravity.CENTER, // gravity (optional) + 0, // quality (optional) + 0, // borderWidth (optional) + "", // borderColor (optional) + 0, // borderRadius (optional) + 0, // opacity (optional) + -360, // rotation (optional) + "", // background (optional) + ImageFormat.JPG, // output (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +30,5 @@ storage.getFilePreview( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/storage/get-file-view.md b/docs/examples/java/storage/get-file-view.md index 3c0392d..18dd41e 100644 --- a/docs/examples/java/storage/get-file-view.md +++ b/docs/examples/java/storage/get-file-view.md @@ -9,8 +9,8 @@ Client client = new Client(context) Storage storage = new Storage(client); storage.getFileView( - "[BUCKET_ID]", - "[FILE_ID]", + "[BUCKET_ID]", // bucketId + "[FILE_ID]", // fileId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,5 @@ storage.getFileView( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/storage/get-file.md b/docs/examples/java/storage/get-file.md index c425758..5bc2456 100644 --- a/docs/examples/java/storage/get-file.md +++ b/docs/examples/java/storage/get-file.md @@ -9,8 +9,8 @@ Client client = new Client(context) Storage storage = new Storage(client); storage.getFile( - "[BUCKET_ID]", - "[FILE_ID]", + "[BUCKET_ID]", // bucketId + "[FILE_ID]", // fileId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,5 @@ storage.getFile( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/storage/list-files.md b/docs/examples/java/storage/list-files.md index b6d38aa..2fdd026 100644 --- a/docs/examples/java/storage/list-files.md +++ b/docs/examples/java/storage/list-files.md @@ -9,7 +9,9 @@ Client client = new Client(context) Storage storage = new Storage(client); storage.listFiles( - "[BUCKET_ID]", + "[BUCKET_ID]", // bucketId + listOf(), // queries (optional) + "[SEARCH]", // search (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +20,5 @@ storage.listFiles( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/storage/update-file.md b/docs/examples/java/storage/update-file.md index 6aae427..c445c28 100644 --- a/docs/examples/java/storage/update-file.md +++ b/docs/examples/java/storage/update-file.md @@ -9,8 +9,10 @@ Client client = new Client(context) Storage storage = new Storage(client); storage.updateFile( - "[BUCKET_ID]", - "[FILE_ID]", + "[BUCKET_ID]", // bucketId + "[FILE_ID]", // fileId + "[NAME]", // name (optional) + listOf("read("any")"), // permissions (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +21,5 @@ storage.updateFile( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/teams/create-membership.md b/docs/examples/java/teams/create-membership.md index 3091164..9d8a73a 100644 --- a/docs/examples/java/teams/create-membership.md +++ b/docs/examples/java/teams/create-membership.md @@ -9,8 +9,13 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.createMembership( - "[TEAM_ID]", - listOf(), + "[TEAM_ID]", // teamId + listOf(), // roles + "email@example.com", // email (optional) + "[USER_ID]", // userId (optional) + "+12065550100", // phone (optional) + "https://example.com", // url (optional) + "[NAME]", // name (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +24,5 @@ teams.createMembership( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/teams/create.md b/docs/examples/java/teams/create.md index aa7f567..f637994 100644 --- a/docs/examples/java/teams/create.md +++ b/docs/examples/java/teams/create.md @@ -9,8 +9,9 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.create( - "[TEAM_ID]", - "[NAME]", + "[TEAM_ID]", // teamId + "[NAME]", // name + listOf(), // roles (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +20,5 @@ teams.create( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/teams/delete-membership.md b/docs/examples/java/teams/delete-membership.md index 3837fad..ecf2bdc 100644 --- a/docs/examples/java/teams/delete-membership.md +++ b/docs/examples/java/teams/delete-membership.md @@ -9,8 +9,8 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.deleteMembership( - "[TEAM_ID]", - "[MEMBERSHIP_ID]", + "[TEAM_ID]", // teamId + "[MEMBERSHIP_ID]", // membershipId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,5 @@ teams.deleteMembership( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/teams/delete.md b/docs/examples/java/teams/delete.md index 75355ae..62bb284 100644 --- a/docs/examples/java/teams/delete.md +++ b/docs/examples/java/teams/delete.md @@ -9,7 +9,7 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.delete( - "[TEAM_ID]", + "[TEAM_ID]", // teamId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,5 @@ teams.delete( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/teams/get-membership.md b/docs/examples/java/teams/get-membership.md index 0ba9c87..5a0eb03 100644 --- a/docs/examples/java/teams/get-membership.md +++ b/docs/examples/java/teams/get-membership.md @@ -9,8 +9,8 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.getMembership( - "[TEAM_ID]", - "[MEMBERSHIP_ID]", + "[TEAM_ID]", // teamId + "[MEMBERSHIP_ID]", // membershipId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,5 @@ teams.getMembership( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/teams/get-prefs.md b/docs/examples/java/teams/get-prefs.md index e93b482..78d01de 100644 --- a/docs/examples/java/teams/get-prefs.md +++ b/docs/examples/java/teams/get-prefs.md @@ -9,7 +9,7 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.getPrefs( - "[TEAM_ID]", + "[TEAM_ID]", // teamId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,5 @@ teams.getPrefs( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/teams/get.md b/docs/examples/java/teams/get.md index f5406a2..9442b85 100644 --- a/docs/examples/java/teams/get.md +++ b/docs/examples/java/teams/get.md @@ -9,7 +9,7 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.get( - "[TEAM_ID]", + "[TEAM_ID]", // teamId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +18,5 @@ teams.get( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/teams/list-memberships.md b/docs/examples/java/teams/list-memberships.md index b61b0d0..92934bf 100644 --- a/docs/examples/java/teams/list-memberships.md +++ b/docs/examples/java/teams/list-memberships.md @@ -9,7 +9,9 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.listMemberships( - "[TEAM_ID]", + "[TEAM_ID]", // teamId + listOf(), // queries (optional) + "[SEARCH]", // search (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -18,4 +20,5 @@ teams.listMemberships( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/teams/list.md b/docs/examples/java/teams/list.md index 2f21813..6eacc8e 100644 --- a/docs/examples/java/teams/list.md +++ b/docs/examples/java/teams/list.md @@ -9,6 +9,8 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.list( + listOf(), // queries (optional) + "[SEARCH]", // search (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -17,4 +19,5 @@ teams.list( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/teams/update-membership-status.md b/docs/examples/java/teams/update-membership-status.md index 33bd869..8a01220 100644 --- a/docs/examples/java/teams/update-membership-status.md +++ b/docs/examples/java/teams/update-membership-status.md @@ -9,10 +9,10 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.updateMembershipStatus( - "[TEAM_ID]", - "[MEMBERSHIP_ID]", - "[USER_ID]", - "[SECRET]", + "[TEAM_ID]", // teamId + "[MEMBERSHIP_ID]", // membershipId + "[USER_ID]", // userId + "[SECRET]", // secret new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -21,4 +21,5 @@ teams.updateMembershipStatus( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/teams/update-membership.md b/docs/examples/java/teams/update-membership.md index 48efbe3..779479b 100644 --- a/docs/examples/java/teams/update-membership.md +++ b/docs/examples/java/teams/update-membership.md @@ -9,9 +9,9 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.updateMembership( - "[TEAM_ID]", - "[MEMBERSHIP_ID]", - listOf(), + "[TEAM_ID]", // teamId + "[MEMBERSHIP_ID]", // membershipId + listOf(), // roles new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -20,4 +20,5 @@ teams.updateMembership( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/teams/update-name.md b/docs/examples/java/teams/update-name.md index a84ba84..50960fb 100644 --- a/docs/examples/java/teams/update-name.md +++ b/docs/examples/java/teams/update-name.md @@ -9,8 +9,8 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.updateName( - "[TEAM_ID]", - "[NAME]", + "[TEAM_ID]", // teamId + "[NAME]", // name new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,5 @@ teams.updateName( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/java/teams/update-prefs.md b/docs/examples/java/teams/update-prefs.md index 874f976..9949b44 100644 --- a/docs/examples/java/teams/update-prefs.md +++ b/docs/examples/java/teams/update-prefs.md @@ -9,8 +9,8 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.updatePrefs( - "[TEAM_ID]", - mapOf( "a" to "b" ), + "[TEAM_ID]", // teamId + mapOf( "a" to "b" ), // prefs new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); @@ -19,4 +19,5 @@ teams.updatePrefs( Log.d("Appwrite", result.toString()); }) -); \ No newline at end of file +); + diff --git a/docs/examples/kotlin/account/create-email-password-session.md b/docs/examples/kotlin/account/create-email-password-session.md index 016e73b..d226101 100644 --- a/docs/examples/kotlin/account/create-email-password-session.md +++ b/docs/examples/kotlin/account/create-email-password-session.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val response = account.createEmailPasswordSession( - email = "email@example.com", - password = "password", + email = "email@example.com", + password = "password", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-email-token.md b/docs/examples/kotlin/account/create-email-token.md index 6165707..f8ecea0 100644 --- a/docs/examples/kotlin/account/create-email-token.md +++ b/docs/examples/kotlin/account/create-email-token.md @@ -9,6 +9,7 @@ val client = Client(context) val account = Account(client) val response = account.createEmailToken( - userId = "[USER_ID]", - email = "email@example.com", + userId = "[USER_ID]", + email = "email@example.com", + phrase = false, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-magic-u-r-l-token.md b/docs/examples/kotlin/account/create-magic-u-r-l-token.md index 9d02c96..93122ab 100644 --- a/docs/examples/kotlin/account/create-magic-u-r-l-token.md +++ b/docs/examples/kotlin/account/create-magic-u-r-l-token.md @@ -9,6 +9,8 @@ val client = Client(context) val account = Account(client) val response = account.createMagicURLToken( - userId = "[USER_ID]", - email = "email@example.com", + userId = "[USER_ID]", + email = "email@example.com", + url = "https://example.com", // (optional) + phrase = false, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-o-auth2session.md b/docs/examples/kotlin/account/create-o-auth2session.md index ac01fe5..90a4e56 100644 --- a/docs/examples/kotlin/account/create-o-auth2session.md +++ b/docs/examples/kotlin/account/create-o-auth2session.md @@ -11,4 +11,8 @@ val account = Account(client) account.createOAuth2Session( provider = OAuthProvider.AMAZON, + success = "https://example.com", // (optional) + failure = "https://example.com", // (optional) + token = false, // (optional) + scopes = listOf(), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-phone-token.md b/docs/examples/kotlin/account/create-phone-token.md index abb46c5..b85d8c5 100644 --- a/docs/examples/kotlin/account/create-phone-token.md +++ b/docs/examples/kotlin/account/create-phone-token.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val response = account.createPhoneToken( - userId = "[USER_ID]", - phone = "+12065550100", + userId = "[USER_ID]", + phone = "+12065550100", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-push-target.md b/docs/examples/kotlin/account/create-push-target.md index 30c4d39..f9dd27b 100644 --- a/docs/examples/kotlin/account/create-push-target.md +++ b/docs/examples/kotlin/account/create-push-target.md @@ -9,6 +9,7 @@ val client = Client(context) val account = Account(client) val response = account.createPushTarget( - targetId = "[TARGET_ID]", - identifier = "[IDENTIFIER]", + targetId = "[TARGET_ID]", + identifier = "[IDENTIFIER]", + providerId = "[PROVIDER_ID]", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-recovery.md b/docs/examples/kotlin/account/create-recovery.md index f678fcf..833edc5 100644 --- a/docs/examples/kotlin/account/create-recovery.md +++ b/docs/examples/kotlin/account/create-recovery.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val response = account.createRecovery( - email = "email@example.com", - url = "https://example.com", + email = "email@example.com", + url = "https://example.com", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-session.md b/docs/examples/kotlin/account/create-session.md index ceb7726..5639145 100644 --- a/docs/examples/kotlin/account/create-session.md +++ b/docs/examples/kotlin/account/create-session.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val response = account.createSession( - userId = "[USER_ID]", - secret = "[SECRET]", + userId = "[USER_ID]", + secret = "[SECRET]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-verification.md b/docs/examples/kotlin/account/create-verification.md index 1832348..1f66931 100644 --- a/docs/examples/kotlin/account/create-verification.md +++ b/docs/examples/kotlin/account/create-verification.md @@ -9,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.createVerification( - url = "https://example.com", + url = "https://example.com", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create.md b/docs/examples/kotlin/account/create.md index 8022955..377cccc 100644 --- a/docs/examples/kotlin/account/create.md +++ b/docs/examples/kotlin/account/create.md @@ -9,7 +9,8 @@ val client = Client(context) val account = Account(client) val response = account.create( - userId = "[USER_ID]", - email = "email@example.com", - password = "", + userId = "[USER_ID]", + email = "email@example.com", + password = "", + name = "[NAME]", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-authenticator.md b/docs/examples/kotlin/account/delete-authenticator.md index 44de084..7033470 100644 --- a/docs/examples/kotlin/account/delete-authenticator.md +++ b/docs/examples/kotlin/account/delete-authenticator.md @@ -11,5 +11,5 @@ val account = Account(client) val response = account.deleteAuthenticator( type = AuthenticatorType.TOTP, - otp = "[OTP]", + otp = "[OTP]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-identity.md b/docs/examples/kotlin/account/delete-identity.md index cbf6913..96fa467 100644 --- a/docs/examples/kotlin/account/delete-identity.md +++ b/docs/examples/kotlin/account/delete-identity.md @@ -9,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.deleteIdentity( - identityId = "[IDENTITY_ID]", + identityId = "[IDENTITY_ID]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-push-target.md b/docs/examples/kotlin/account/delete-push-target.md index ea79749..c03c13d 100644 --- a/docs/examples/kotlin/account/delete-push-target.md +++ b/docs/examples/kotlin/account/delete-push-target.md @@ -9,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.deletePushTarget( - targetId = "[TARGET_ID]", + targetId = "[TARGET_ID]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-session.md b/docs/examples/kotlin/account/delete-session.md index 615f218..52ff38e 100644 --- a/docs/examples/kotlin/account/delete-session.md +++ b/docs/examples/kotlin/account/delete-session.md @@ -9,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.deleteSession( - sessionId = "[SESSION_ID]", + sessionId = "[SESSION_ID]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/get-session.md b/docs/examples/kotlin/account/get-session.md index 1b15d5b..261f295 100644 --- a/docs/examples/kotlin/account/get-session.md +++ b/docs/examples/kotlin/account/get-session.md @@ -9,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.getSession( - sessionId = "[SESSION_ID]", + sessionId = "[SESSION_ID]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/list-identities.md b/docs/examples/kotlin/account/list-identities.md index d87409c..3b5e7ca 100644 --- a/docs/examples/kotlin/account/list-identities.md +++ b/docs/examples/kotlin/account/list-identities.md @@ -9,4 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.listIdentities( + queries = listOf(), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/list-logs.md b/docs/examples/kotlin/account/list-logs.md index f4ce74f..abf89b2 100644 --- a/docs/examples/kotlin/account/list-logs.md +++ b/docs/examples/kotlin/account/list-logs.md @@ -9,4 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.listLogs( + queries = listOf(), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-challenge.md b/docs/examples/kotlin/account/update-challenge.md index 23718d2..44a6dbd 100644 --- a/docs/examples/kotlin/account/update-challenge.md +++ b/docs/examples/kotlin/account/update-challenge.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val response = account.updateChallenge( - challengeId = "[CHALLENGE_ID]", - otp = "[OTP]", + challengeId = "[CHALLENGE_ID]", + otp = "[OTP]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-email.md b/docs/examples/kotlin/account/update-email.md index 6b3655a..aa4679c 100644 --- a/docs/examples/kotlin/account/update-email.md +++ b/docs/examples/kotlin/account/update-email.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val response = account.updateEmail( - email = "email@example.com", - password = "password", + email = "email@example.com", + password = "password", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-m-f-a.md b/docs/examples/kotlin/account/update-m-f-a.md index 1bd3fd2..0327757 100644 --- a/docs/examples/kotlin/account/update-m-f-a.md +++ b/docs/examples/kotlin/account/update-m-f-a.md @@ -9,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.updateMFA( - mfa = false, + mfa = false, ) \ No newline at end of file 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 1f77281..bbf5c65 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 @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val response = account.updateMagicURLSession( - userId = "[USER_ID]", - secret = "[SECRET]", + userId = "[USER_ID]", + secret = "[SECRET]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-name.md b/docs/examples/kotlin/account/update-name.md index 5d18e1f..9b1cb8c 100644 --- a/docs/examples/kotlin/account/update-name.md +++ b/docs/examples/kotlin/account/update-name.md @@ -9,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.updateName( - name = "[NAME]", + name = "[NAME]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-password.md b/docs/examples/kotlin/account/update-password.md index 45e9556..646ebe7 100644 --- a/docs/examples/kotlin/account/update-password.md +++ b/docs/examples/kotlin/account/update-password.md @@ -9,5 +9,6 @@ val client = Client(context) val account = Account(client) val response = account.updatePassword( - password = "", + password = "", + oldPassword = "password", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-phone-verification.md b/docs/examples/kotlin/account/update-phone-verification.md index c4c0e84..d86f478 100644 --- a/docs/examples/kotlin/account/update-phone-verification.md +++ b/docs/examples/kotlin/account/update-phone-verification.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val response = account.updatePhoneVerification( - userId = "[USER_ID]", - secret = "[SECRET]", + userId = "[USER_ID]", + secret = "[SECRET]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-phone.md b/docs/examples/kotlin/account/update-phone.md index d86e628..834d826 100644 --- a/docs/examples/kotlin/account/update-phone.md +++ b/docs/examples/kotlin/account/update-phone.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val response = account.updatePhone( - phone = "+12065550100", - password = "password", + phone = "+12065550100", + password = "password", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-prefs.md b/docs/examples/kotlin/account/update-prefs.md index 58d5cd0..02ddc58 100644 --- a/docs/examples/kotlin/account/update-prefs.md +++ b/docs/examples/kotlin/account/update-prefs.md @@ -9,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.updatePrefs( - prefs = mapOf( "a" to "b" ), + prefs = mapOf( "a" to "b" ), ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-push-target.md b/docs/examples/kotlin/account/update-push-target.md index ff1e3a1..019f55c 100644 --- a/docs/examples/kotlin/account/update-push-target.md +++ b/docs/examples/kotlin/account/update-push-target.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val response = account.updatePushTarget( - targetId = "[TARGET_ID]", - identifier = "[IDENTIFIER]", + targetId = "[TARGET_ID]", + identifier = "[IDENTIFIER]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-recovery.md b/docs/examples/kotlin/account/update-recovery.md index 6b7a6d0..176dd25 100644 --- a/docs/examples/kotlin/account/update-recovery.md +++ b/docs/examples/kotlin/account/update-recovery.md @@ -9,7 +9,7 @@ val client = Client(context) val account = Account(client) val response = account.updateRecovery( - userId = "[USER_ID]", - secret = "[SECRET]", - password = "", + userId = "[USER_ID]", + secret = "[SECRET]", + password = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-session.md b/docs/examples/kotlin/account/update-session.md index 1257334..afea816 100644 --- a/docs/examples/kotlin/account/update-session.md +++ b/docs/examples/kotlin/account/update-session.md @@ -9,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.updateSession( - sessionId = "[SESSION_ID]", + sessionId = "[SESSION_ID]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-verification.md b/docs/examples/kotlin/account/update-verification.md index 0dcd75b..eae6318 100644 --- a/docs/examples/kotlin/account/update-verification.md +++ b/docs/examples/kotlin/account/update-verification.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val response = account.updateVerification( - userId = "[USER_ID]", - secret = "[SECRET]", + userId = "[USER_ID]", + secret = "[SECRET]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/verify-authenticator.md b/docs/examples/kotlin/account/verify-authenticator.md index aee1dc9..5b9b7ca 100644 --- a/docs/examples/kotlin/account/verify-authenticator.md +++ b/docs/examples/kotlin/account/verify-authenticator.md @@ -11,5 +11,5 @@ val account = Account(client) val response = account.verifyAuthenticator( type = AuthenticatorType.TOTP, - otp = "[OTP]", + otp = "[OTP]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-browser.md b/docs/examples/kotlin/avatars/get-browser.md index ab7c749..ab443c3 100644 --- a/docs/examples/kotlin/avatars/get-browser.md +++ b/docs/examples/kotlin/avatars/get-browser.md @@ -11,4 +11,7 @@ val avatars = Avatars(client) val result =avatars.getBrowser( code = Browser.AVANT_BROWSER, + width = 0, // (optional) + height = 0, // (optional) + quality = 0, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-credit-card.md b/docs/examples/kotlin/avatars/get-credit-card.md index 758f70d..cb4a3f2 100644 --- a/docs/examples/kotlin/avatars/get-credit-card.md +++ b/docs/examples/kotlin/avatars/get-credit-card.md @@ -11,4 +11,7 @@ val avatars = Avatars(client) val result =avatars.getCreditCard( code = CreditCard.AMERICAN_EXPRESS, + width = 0, // (optional) + height = 0, // (optional) + quality = 0, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-favicon.md b/docs/examples/kotlin/avatars/get-favicon.md index 1bb1372..aa4bac3 100644 --- a/docs/examples/kotlin/avatars/get-favicon.md +++ b/docs/examples/kotlin/avatars/get-favicon.md @@ -9,5 +9,5 @@ val client = Client(context) val avatars = Avatars(client) val result =avatars.getFavicon( - url = "https://example.com", + url = "https://example.com", ) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-flag.md b/docs/examples/kotlin/avatars/get-flag.md index 142f626..f54b952 100644 --- a/docs/examples/kotlin/avatars/get-flag.md +++ b/docs/examples/kotlin/avatars/get-flag.md @@ -11,4 +11,7 @@ val avatars = Avatars(client) val result =avatars.getFlag( code = Flag.AFGHANISTAN, + width = 0, // (optional) + height = 0, // (optional) + quality = 0, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-image.md b/docs/examples/kotlin/avatars/get-image.md index c1ccd96..18b1c78 100644 --- a/docs/examples/kotlin/avatars/get-image.md +++ b/docs/examples/kotlin/avatars/get-image.md @@ -9,5 +9,7 @@ val client = Client(context) val avatars = Avatars(client) val result =avatars.getImage( - url = "https://example.com", + url = "https://example.com", + width = 0, // (optional) + height = 0, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-initials.md b/docs/examples/kotlin/avatars/get-initials.md index 62c69c8..5c84a34 100644 --- a/docs/examples/kotlin/avatars/get-initials.md +++ b/docs/examples/kotlin/avatars/get-initials.md @@ -9,4 +9,8 @@ val client = Client(context) val avatars = Avatars(client) val result =avatars.getInitials( + name = "[NAME]", // (optional) + width = 0, // (optional) + height = 0, // (optional) + background = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-q-r.md b/docs/examples/kotlin/avatars/get-q-r.md index 85de6d3..bc525d0 100644 --- a/docs/examples/kotlin/avatars/get-q-r.md +++ b/docs/examples/kotlin/avatars/get-q-r.md @@ -9,5 +9,8 @@ val client = Client(context) val avatars = Avatars(client) val result =avatars.getQR( - text = "[TEXT]", + text = "[TEXT]", + size = 1, // (optional) + margin = 0, // (optional) + download = false, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index bc5445a..7155af9 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -9,8 +9,9 @@ val client = Client(context) val databases = Databases(client) val response = databases.createDocument( - databaseId = "[DATABASE_ID]", - collectionId = "[COLLECTION_ID]", - documentId = "[DOCUMENT_ID]", - data = mapOf( "a" to "b" ), + databaseId = "[DATABASE_ID]", + collectionId = "[COLLECTION_ID]", + documentId = "[DOCUMENT_ID]", + data = mapOf( "a" to "b" ), + permissions = listOf("read("any")"), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/delete-document.md b/docs/examples/kotlin/databases/delete-document.md index d24db61..f9e7a07 100644 --- a/docs/examples/kotlin/databases/delete-document.md +++ b/docs/examples/kotlin/databases/delete-document.md @@ -9,7 +9,7 @@ val client = Client(context) val databases = Databases(client) val response = databases.deleteDocument( - databaseId = "[DATABASE_ID]", - collectionId = "[COLLECTION_ID]", - documentId = "[DOCUMENT_ID]", + databaseId = "[DATABASE_ID]", + collectionId = "[COLLECTION_ID]", + documentId = "[DOCUMENT_ID]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/get-document.md b/docs/examples/kotlin/databases/get-document.md index 328b801..b52852c 100644 --- a/docs/examples/kotlin/databases/get-document.md +++ b/docs/examples/kotlin/databases/get-document.md @@ -9,7 +9,8 @@ val client = Client(context) val databases = Databases(client) val response = databases.getDocument( - databaseId = "[DATABASE_ID]", - collectionId = "[COLLECTION_ID]", - documentId = "[DOCUMENT_ID]", + databaseId = "[DATABASE_ID]", + collectionId = "[COLLECTION_ID]", + documentId = "[DOCUMENT_ID]", + queries = listOf(), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/list-documents.md b/docs/examples/kotlin/databases/list-documents.md index b5511d6..9bcdea2 100644 --- a/docs/examples/kotlin/databases/list-documents.md +++ b/docs/examples/kotlin/databases/list-documents.md @@ -9,6 +9,7 @@ val client = Client(context) val databases = Databases(client) val response = databases.listDocuments( - databaseId = "[DATABASE_ID]", - collectionId = "[COLLECTION_ID]", + databaseId = "[DATABASE_ID]", + collectionId = "[COLLECTION_ID]", + queries = listOf(), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/update-document.md b/docs/examples/kotlin/databases/update-document.md index e2d989e..ae19c7e 100644 --- a/docs/examples/kotlin/databases/update-document.md +++ b/docs/examples/kotlin/databases/update-document.md @@ -9,7 +9,9 @@ val client = Client(context) val databases = Databases(client) val response = databases.updateDocument( - databaseId = "[DATABASE_ID]", - collectionId = "[COLLECTION_ID]", - documentId = "[DOCUMENT_ID]", + databaseId = "[DATABASE_ID]", + collectionId = "[COLLECTION_ID]", + documentId = "[DOCUMENT_ID]", + data = mapOf( "a" to "b" ), // (optional) + permissions = listOf("read("any")"), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/create-execution.md b/docs/examples/kotlin/functions/create-execution.md index 96dad59..4a2cd3f 100644 --- a/docs/examples/kotlin/functions/create-execution.md +++ b/docs/examples/kotlin/functions/create-execution.md @@ -9,5 +9,10 @@ val client = Client(context) val functions = Functions(client) val response = functions.createExecution( - functionId = "[FUNCTION_ID]", + functionId = "[FUNCTION_ID]", + body = "[BODY]", // (optional) + async = false, // (optional) + path = "[PATH]", // (optional) + method = ExecutionMethod.GET, // (optional) + headers = mapOf( "a" to "b" ), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/get-execution.md b/docs/examples/kotlin/functions/get-execution.md index e366f4b..cbe8dd1 100644 --- a/docs/examples/kotlin/functions/get-execution.md +++ b/docs/examples/kotlin/functions/get-execution.md @@ -9,6 +9,6 @@ val client = Client(context) val functions = Functions(client) val response = functions.getExecution( - functionId = "[FUNCTION_ID]", - executionId = "[EXECUTION_ID]", + functionId = "[FUNCTION_ID]", + executionId = "[EXECUTION_ID]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/list-executions.md b/docs/examples/kotlin/functions/list-executions.md index ba2ff2d..2b6c5f8 100644 --- a/docs/examples/kotlin/functions/list-executions.md +++ b/docs/examples/kotlin/functions/list-executions.md @@ -9,5 +9,7 @@ val client = Client(context) val functions = Functions(client) val response = functions.listExecutions( - functionId = "[FUNCTION_ID]", + functionId = "[FUNCTION_ID]", + queries = listOf(), // (optional) + search = "[SEARCH]", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/graphql/mutation.md b/docs/examples/kotlin/graphql/mutation.md index eee3f82..c22a403 100644 --- a/docs/examples/kotlin/graphql/mutation.md +++ b/docs/examples/kotlin/graphql/mutation.md @@ -9,5 +9,5 @@ val client = Client(context) val graphql = Graphql(client) val response = graphql.mutation( - query = mapOf( "a" to "b" ), + query = mapOf( "a" to "b" ), ) \ No newline at end of file diff --git a/docs/examples/kotlin/graphql/query.md b/docs/examples/kotlin/graphql/query.md index 1337d36..00850c4 100644 --- a/docs/examples/kotlin/graphql/query.md +++ b/docs/examples/kotlin/graphql/query.md @@ -9,5 +9,5 @@ val client = Client(context) val graphql = Graphql(client) val response = graphql.query( - query = mapOf( "a" to "b" ), + query = mapOf( "a" to "b" ), ) \ No newline at end of file diff --git a/docs/examples/kotlin/messaging/create-subscriber.md b/docs/examples/kotlin/messaging/create-subscriber.md index 1da3ed3..163c427 100644 --- a/docs/examples/kotlin/messaging/create-subscriber.md +++ b/docs/examples/kotlin/messaging/create-subscriber.md @@ -9,7 +9,7 @@ val client = Client(context) val messaging = Messaging(client) val response = messaging.createSubscriber( - topicId = "[TOPIC_ID]", - subscriberId = "[SUBSCRIBER_ID]", - targetId = "[TARGET_ID]", + topicId = "[TOPIC_ID]", + subscriberId = "[SUBSCRIBER_ID]", + targetId = "[TARGET_ID]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/messaging/delete-subscriber.md b/docs/examples/kotlin/messaging/delete-subscriber.md index 0096de3..7ac8930 100644 --- a/docs/examples/kotlin/messaging/delete-subscriber.md +++ b/docs/examples/kotlin/messaging/delete-subscriber.md @@ -9,6 +9,6 @@ val client = Client(context) val messaging = Messaging(client) val response = messaging.deleteSubscriber( - topicId = "[TOPIC_ID]", - subscriberId = "[SUBSCRIBER_ID]", + topicId = "[TOPIC_ID]", + subscriberId = "[SUBSCRIBER_ID]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/create-file.md b/docs/examples/kotlin/storage/create-file.md index 19eae0f..7381696 100644 --- a/docs/examples/kotlin/storage/create-file.md +++ b/docs/examples/kotlin/storage/create-file.md @@ -10,7 +10,8 @@ val client = Client(context) val storage = Storage(client) val response = storage.createFile( - bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]", - file = InputFile.fromPath("file.png"), + bucketId = "[BUCKET_ID]", + fileId = "[FILE_ID]", + file = InputFile.fromPath("file.png"), + permissions = listOf("read("any")"), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/delete-file.md b/docs/examples/kotlin/storage/delete-file.md index c64e8dc..0b14a1b 100644 --- a/docs/examples/kotlin/storage/delete-file.md +++ b/docs/examples/kotlin/storage/delete-file.md @@ -9,6 +9,6 @@ val client = Client(context) val storage = Storage(client) val response = storage.deleteFile( - bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]", + bucketId = "[BUCKET_ID]", + fileId = "[FILE_ID]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file-download.md b/docs/examples/kotlin/storage/get-file-download.md index 07ebcc0..83071ea 100644 --- a/docs/examples/kotlin/storage/get-file-download.md +++ b/docs/examples/kotlin/storage/get-file-download.md @@ -9,6 +9,6 @@ val client = Client(context) val storage = Storage(client) val result =storage.getFileDownload( - bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]", + bucketId = "[BUCKET_ID]", + fileId = "[FILE_ID]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file-preview.md b/docs/examples/kotlin/storage/get-file-preview.md index b5995ae..4d23b0e 100644 --- a/docs/examples/kotlin/storage/get-file-preview.md +++ b/docs/examples/kotlin/storage/get-file-preview.md @@ -9,6 +9,17 @@ val client = Client(context) val storage = Storage(client) val result =storage.getFilePreview( - bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]", + bucketId = "[BUCKET_ID]", + fileId = "[FILE_ID]", + width = 0, // (optional) + height = 0, // (optional) + gravity = ImageGravity.CENTER, // (optional) + quality = 0, // (optional) + borderWidth = 0, // (optional) + borderColor = "", // (optional) + borderRadius = 0, // (optional) + opacity = 0, // (optional) + rotation = -360, // (optional) + background = "", // (optional) + output = ImageFormat.JPG, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file-view.md b/docs/examples/kotlin/storage/get-file-view.md index 82b55c2..552427e 100644 --- a/docs/examples/kotlin/storage/get-file-view.md +++ b/docs/examples/kotlin/storage/get-file-view.md @@ -9,6 +9,6 @@ val client = Client(context) val storage = Storage(client) val result =storage.getFileView( - bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]", + bucketId = "[BUCKET_ID]", + fileId = "[FILE_ID]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file.md b/docs/examples/kotlin/storage/get-file.md index 9c1abd4..2f07fee 100644 --- a/docs/examples/kotlin/storage/get-file.md +++ b/docs/examples/kotlin/storage/get-file.md @@ -9,6 +9,6 @@ val client = Client(context) val storage = Storage(client) val response = storage.getFile( - bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]", + bucketId = "[BUCKET_ID]", + fileId = "[FILE_ID]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/list-files.md b/docs/examples/kotlin/storage/list-files.md index 575a8b9..c07afc2 100644 --- a/docs/examples/kotlin/storage/list-files.md +++ b/docs/examples/kotlin/storage/list-files.md @@ -9,5 +9,7 @@ val client = Client(context) val storage = Storage(client) val response = storage.listFiles( - bucketId = "[BUCKET_ID]", + bucketId = "[BUCKET_ID]", + queries = listOf(), // (optional) + search = "[SEARCH]", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/update-file.md b/docs/examples/kotlin/storage/update-file.md index 75585fa..8331e94 100644 --- a/docs/examples/kotlin/storage/update-file.md +++ b/docs/examples/kotlin/storage/update-file.md @@ -9,6 +9,8 @@ val client = Client(context) val storage = Storage(client) val response = storage.updateFile( - bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]", + bucketId = "[BUCKET_ID]", + fileId = "[FILE_ID]", + name = "[NAME]", // (optional) + permissions = listOf("read("any")"), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/create-membership.md b/docs/examples/kotlin/teams/create-membership.md index 231a991..77fea6e 100644 --- a/docs/examples/kotlin/teams/create-membership.md +++ b/docs/examples/kotlin/teams/create-membership.md @@ -9,6 +9,11 @@ val client = Client(context) val teams = Teams(client) val response = teams.createMembership( - teamId = "[TEAM_ID]", - roles = listOf(), + teamId = "[TEAM_ID]", + roles = listOf(), + email = "email@example.com", // (optional) + userId = "[USER_ID]", // (optional) + phone = "+12065550100", // (optional) + url = "https://example.com", // (optional) + name = "[NAME]", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/create.md b/docs/examples/kotlin/teams/create.md index dd1125c..4b841f9 100644 --- a/docs/examples/kotlin/teams/create.md +++ b/docs/examples/kotlin/teams/create.md @@ -9,6 +9,7 @@ val client = Client(context) val teams = Teams(client) val response = teams.create( - teamId = "[TEAM_ID]", - name = "[NAME]", + teamId = "[TEAM_ID]", + name = "[NAME]", + roles = listOf(), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/delete-membership.md b/docs/examples/kotlin/teams/delete-membership.md index 3f165a7..9ad5e21 100644 --- a/docs/examples/kotlin/teams/delete-membership.md +++ b/docs/examples/kotlin/teams/delete-membership.md @@ -9,6 +9,6 @@ val client = Client(context) val teams = Teams(client) val response = teams.deleteMembership( - teamId = "[TEAM_ID]", - membershipId = "[MEMBERSHIP_ID]", + teamId = "[TEAM_ID]", + membershipId = "[MEMBERSHIP_ID]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/delete.md b/docs/examples/kotlin/teams/delete.md index 756e91f..bab1a31 100644 --- a/docs/examples/kotlin/teams/delete.md +++ b/docs/examples/kotlin/teams/delete.md @@ -9,5 +9,5 @@ val client = Client(context) val teams = Teams(client) val response = teams.delete( - teamId = "[TEAM_ID]", + teamId = "[TEAM_ID]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/get-membership.md b/docs/examples/kotlin/teams/get-membership.md index 7c5d286..8fbc3f7 100644 --- a/docs/examples/kotlin/teams/get-membership.md +++ b/docs/examples/kotlin/teams/get-membership.md @@ -9,6 +9,6 @@ val client = Client(context) val teams = Teams(client) val response = teams.getMembership( - teamId = "[TEAM_ID]", - membershipId = "[MEMBERSHIP_ID]", + teamId = "[TEAM_ID]", + membershipId = "[MEMBERSHIP_ID]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/get-prefs.md b/docs/examples/kotlin/teams/get-prefs.md index 2953dcf..7738575 100644 --- a/docs/examples/kotlin/teams/get-prefs.md +++ b/docs/examples/kotlin/teams/get-prefs.md @@ -9,5 +9,5 @@ val client = Client(context) val teams = Teams(client) val response = teams.getPrefs( - teamId = "[TEAM_ID]", + teamId = "[TEAM_ID]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/get.md b/docs/examples/kotlin/teams/get.md index 63cdd05..16a1b43 100644 --- a/docs/examples/kotlin/teams/get.md +++ b/docs/examples/kotlin/teams/get.md @@ -9,5 +9,5 @@ val client = Client(context) val teams = Teams(client) val response = teams.get( - teamId = "[TEAM_ID]", + teamId = "[TEAM_ID]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/list-memberships.md b/docs/examples/kotlin/teams/list-memberships.md index c82fa52..44c9638 100644 --- a/docs/examples/kotlin/teams/list-memberships.md +++ b/docs/examples/kotlin/teams/list-memberships.md @@ -9,5 +9,7 @@ val client = Client(context) val teams = Teams(client) val response = teams.listMemberships( - teamId = "[TEAM_ID]", + teamId = "[TEAM_ID]", + queries = listOf(), // (optional) + search = "[SEARCH]", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/list.md b/docs/examples/kotlin/teams/list.md index f0f4af2..38ac1d9 100644 --- a/docs/examples/kotlin/teams/list.md +++ b/docs/examples/kotlin/teams/list.md @@ -9,4 +9,6 @@ val client = Client(context) val teams = Teams(client) val response = teams.list( + queries = listOf(), // (optional) + search = "[SEARCH]", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-membership-status.md b/docs/examples/kotlin/teams/update-membership-status.md index 50f04a2..53fbe20 100644 --- a/docs/examples/kotlin/teams/update-membership-status.md +++ b/docs/examples/kotlin/teams/update-membership-status.md @@ -9,8 +9,8 @@ val client = Client(context) val teams = Teams(client) val response = teams.updateMembershipStatus( - teamId = "[TEAM_ID]", - membershipId = "[MEMBERSHIP_ID]", - userId = "[USER_ID]", - secret = "[SECRET]", + teamId = "[TEAM_ID]", + membershipId = "[MEMBERSHIP_ID]", + userId = "[USER_ID]", + secret = "[SECRET]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-membership.md b/docs/examples/kotlin/teams/update-membership.md index 9990cc4..4e47025 100644 --- a/docs/examples/kotlin/teams/update-membership.md +++ b/docs/examples/kotlin/teams/update-membership.md @@ -9,7 +9,7 @@ val client = Client(context) val teams = Teams(client) val response = teams.updateMembership( - teamId = "[TEAM_ID]", - membershipId = "[MEMBERSHIP_ID]", - roles = listOf(), + teamId = "[TEAM_ID]", + membershipId = "[MEMBERSHIP_ID]", + roles = listOf(), ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-name.md b/docs/examples/kotlin/teams/update-name.md index 1332fe1..f92b302 100644 --- a/docs/examples/kotlin/teams/update-name.md +++ b/docs/examples/kotlin/teams/update-name.md @@ -9,6 +9,6 @@ val client = Client(context) val teams = Teams(client) val response = teams.updateName( - teamId = "[TEAM_ID]", - name = "[NAME]", + teamId = "[TEAM_ID]", + name = "[NAME]", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-prefs.md b/docs/examples/kotlin/teams/update-prefs.md index 5f77c6c..dc12687 100644 --- a/docs/examples/kotlin/teams/update-prefs.md +++ b/docs/examples/kotlin/teams/update-prefs.md @@ -9,6 +9,6 @@ val client = Client(context) val teams = Teams(client) val response = teams.updatePrefs( - teamId = "[TEAM_ID]", - prefs = mapOf( "a" to "b" ), + teamId = "[TEAM_ID]", + prefs = mapOf( "a" to "b" ), ) \ No newline at end of file diff --git a/example/build.gradle b/example/build.gradle index ff37072..0ebf8b2 100644 --- a/example/build.gradle +++ b/example/build.gradle @@ -46,13 +46,13 @@ dependencies { implementation("androidx.appcompat:appcompat:1.6.1") implementation("com.google.android.material:material:1.11.0") implementation("androidx.constraintlayout:constraintlayout:2.1.4") - implementation("androidx.navigation:navigation-fragment-ktx:2.7.6") + implementation("androidx.navigation:navigation-fragment-ktx:2.7.7") implementation("androidx.fragment:fragment-ktx:1.6.2") - implementation("androidx.navigation:navigation-ui-ktx:2.7.6") + implementation("androidx.navigation:navigation-ui-ktx:2.7.7") implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.7.0") implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0") - implementation("androidx.navigation:navigation-fragment-ktx:2.7.6") - implementation("androidx.navigation:navigation-ui-ktx:2.7.6") + implementation("androidx.navigation:navigation-fragment-ktx:2.7.7") + implementation("androidx.navigation:navigation-ui-ktx:2.7.7") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1") diff --git a/example/src/main/AndroidManifest.xml b/example/src/main/AndroidManifest.xml index 5c2e7b0..3564397 100644 --- a/example/src/main/AndroidManifest.xml +++ b/example/src/main/AndroidManifest.xml @@ -27,7 +27,7 @@ - + diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index c0d039f..2877f9f 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -83,7 +83,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "5.0.0-rc.3", + "x-sdk-version" to "5.0.0-rc.4", "x-appwrite-response-format" to "1.5.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/services/Messaging.kt b/library/src/main/java/io/appwrite/services/Messaging.kt index eefe935..6e11bd7 100644 --- a/library/src/main/java/io/appwrite/services/Messaging.kt +++ b/library/src/main/java/io/appwrite/services/Messaging.kt @@ -16,9 +16,9 @@ import java.io.File class Messaging(client: Client) : Service(client) { /** - * Create a subscriber. + * Create a subscriber * - * + * Create a new subscriber. * * @param topicId Topic ID. The topic ID to subscribe to. * @param subscriberId Subscriber ID. Choose a custom Subscriber ID or a new Subscriber ID. @@ -56,9 +56,9 @@ class Messaging(client: Client) : Service(client) { /** - * Delete a subscriber. + * Delete a subscriber * - * + * Delete a subscriber by its unique ID. * * @param topicId Topic ID. The topic ID subscribed to. * @param subscriberId Subscriber ID. From e9887c81d0589a88b0296a9bda936abfc8810c9d Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 22 Feb 2024 00:11:12 +1300 Subject: [PATCH 065/118] Update publish.yml --- .github/workflows/publish.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ae9090b..ffe898b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -12,10 +12,10 @@ jobs: steps: - name: Check out code uses: actions/checkout@v2 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v1 with: - java-version: 11 + java-version: 17 # Base64 decodes and pipes the GPG key content into the secret file - name: Prepare environment env: @@ -37,7 +37,7 @@ jobs: # Runs upload, and then closes & releases the repository - name: Publish Release Version to MavenCentral run: | - if ${{ endswith(github.event.release.tag_name, '-SNAPSHOT') }}; then + if ${{ contains(github.event.release.tag_name, '-rc') }}; then echo "Publising Snapshot Version ${{ github.event.release.tag_name}} to Snapshot repository" ./gradlew publishToSonatype else From d30691f7a8583b731f3b136f574f9ca7655d4187 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Sun, 25 Feb 2024 00:29:57 +1300 Subject: [PATCH 066/118] Release candidate for 1.5.x --- .github/workflows/publish.yml | 1 - README.md | 17 +- ...e2f-a-challenge.md => create-challenge.md} | 2 +- .../java/account/create-email-token.md | 2 +- .../java/account/create-magic-u-r-l-token.md | 2 +- .../java/account/create-o-auth2session.md | 1 - .../java/account/create-o-auth2token.md | 26 +++ .../java/account/create-phone-token.md | 2 +- .../java/account/create-push-target.md | 6 +- docs/examples/java/account/create-session.md | 4 +- docs/examples/java/account/create.md | 4 +- .../java/account/delete-authenticator.md | 2 +- docs/examples/java/account/delete-identity.md | 2 +- .../java/account/delete-push-target.md | 2 +- docs/examples/java/account/delete-session.md | 2 +- docs/examples/java/account/get-session.md | 2 +- .../examples/java/account/update-challenge.md | 4 +- .../account/update-magic-u-r-l-session.md | 4 +- docs/examples/java/account/update-name.md | 2 +- .../java/account/update-phone-verification.md | 4 +- .../java/account/update-push-target.md | 4 +- docs/examples/java/account/update-recovery.md | 4 +- docs/examples/java/account/update-session.md | 2 +- .../java/account/update-verification.md | 4 +- .../java/account/verify-authenticator.md | 2 +- docs/examples/java/avatars/get-initials.md | 2 +- docs/examples/java/avatars/get-q-r.md | 2 +- .../java/databases/create-document.md | 6 +- .../java/databases/delete-document.md | 6 +- docs/examples/java/databases/get-document.md | 6 +- .../examples/java/databases/list-documents.md | 4 +- .../java/databases/update-document.md | 6 +- .../java/functions/create-execution.md | 6 +- docs/examples/java/functions/get-execution.md | 4 +- .../java/functions/list-executions.md | 4 +- .../java/messaging/create-subscriber.md | 6 +- .../java/messaging/delete-subscriber.md | 4 +- docs/examples/java/storage/create-file.md | 4 +- docs/examples/java/storage/delete-file.md | 4 +- .../java/storage/get-file-download.md | 4 +- .../examples/java/storage/get-file-preview.md | 4 +- docs/examples/java/storage/get-file-view.md | 4 +- docs/examples/java/storage/get-file.md | 4 +- docs/examples/java/storage/list-files.md | 4 +- docs/examples/java/storage/update-file.md | 6 +- docs/examples/java/teams/create-membership.md | 6 +- docs/examples/java/teams/create.md | 4 +- docs/examples/java/teams/delete-membership.md | 4 +- docs/examples/java/teams/delete.md | 2 +- docs/examples/java/teams/get-membership.md | 4 +- docs/examples/java/teams/get-prefs.md | 2 +- docs/examples/java/teams/get.md | 2 +- docs/examples/java/teams/list-memberships.md | 4 +- docs/examples/java/teams/list.md | 2 +- .../java/teams/update-membership-status.md | 8 +- docs/examples/java/teams/update-membership.md | 4 +- docs/examples/java/teams/update-name.md | 4 +- docs/examples/java/teams/update-prefs.md | 2 +- ...e2f-a-challenge.md => create-challenge.md} | 2 +- .../kotlin/account/create-email-token.md | 2 +- .../account/create-magic-u-r-l-token.md | 2 +- .../kotlin/account/create-o-auth2session.md | 1 - .../kotlin/account/create-o-auth2token.md | 17 ++ .../kotlin/account/create-phone-token.md | 2 +- .../kotlin/account/create-push-target.md | 6 +- .../examples/kotlin/account/create-session.md | 4 +- docs/examples/kotlin/account/create.md | 4 +- .../kotlin/account/delete-authenticator.md | 2 +- .../kotlin/account/delete-identity.md | 2 +- .../kotlin/account/delete-push-target.md | 2 +- .../examples/kotlin/account/delete-session.md | 2 +- docs/examples/kotlin/account/get-session.md | 2 +- .../kotlin/account/update-challenge.md | 4 +- .../account/update-magic-u-r-l-session.md | 4 +- docs/examples/kotlin/account/update-name.md | 2 +- .../account/update-phone-verification.md | 4 +- .../kotlin/account/update-push-target.md | 4 +- .../kotlin/account/update-recovery.md | 4 +- .../examples/kotlin/account/update-session.md | 2 +- .../kotlin/account/update-verification.md | 4 +- .../kotlin/account/verify-authenticator.md | 2 +- docs/examples/kotlin/avatars/get-initials.md | 2 +- docs/examples/kotlin/avatars/get-q-r.md | 2 +- .../kotlin/databases/create-document.md | 6 +- .../kotlin/databases/delete-document.md | 6 +- .../examples/kotlin/databases/get-document.md | 6 +- .../kotlin/databases/list-documents.md | 4 +- .../kotlin/databases/update-document.md | 6 +- .../kotlin/functions/create-execution.md | 6 +- .../kotlin/functions/get-execution.md | 4 +- .../kotlin/functions/list-executions.md | 4 +- .../kotlin/messaging/create-subscriber.md | 6 +- .../kotlin/messaging/delete-subscriber.md | 4 +- docs/examples/kotlin/storage/create-file.md | 4 +- docs/examples/kotlin/storage/delete-file.md | 4 +- .../kotlin/storage/get-file-download.md | 4 +- .../kotlin/storage/get-file-preview.md | 4 +- docs/examples/kotlin/storage/get-file-view.md | 4 +- docs/examples/kotlin/storage/get-file.md | 4 +- docs/examples/kotlin/storage/list-files.md | 4 +- docs/examples/kotlin/storage/update-file.md | 6 +- .../kotlin/teams/create-membership.md | 6 +- docs/examples/kotlin/teams/create.md | 4 +- .../kotlin/teams/delete-membership.md | 4 +- docs/examples/kotlin/teams/delete.md | 2 +- docs/examples/kotlin/teams/get-membership.md | 4 +- docs/examples/kotlin/teams/get-prefs.md | 2 +- docs/examples/kotlin/teams/get.md | 2 +- .../examples/kotlin/teams/list-memberships.md | 4 +- docs/examples/kotlin/teams/list.md | 2 +- .../kotlin/teams/update-membership-status.md | 8 +- .../kotlin/teams/update-membership.md | 4 +- docs/examples/kotlin/teams/update-name.md | 4 +- docs/examples/kotlin/teams/update-prefs.md | 2 +- library/src/main/java/io/appwrite/Client.kt | 2 +- library/src/main/java/io/appwrite/OS.kt | 52 ----- .../io/appwrite/enums/AuthenticationFactor.kt | 5 + .../io/appwrite/enums/AuthenticatorType.kt | 3 + .../main/java/io/appwrite/enums/Browser.kt | 16 ++ .../main/java/io/appwrite/enums/CreditCard.kt | 18 ++ .../java/io/appwrite/enums/ExecutionMethod.kt | 8 + .../src/main/java/io/appwrite/enums/Flag.kt | 196 ++++++++++++++++++ .../java/io/appwrite/enums/ImageFormat.kt | 7 + .../java/io/appwrite/enums/ImageGravity.kt | 11 + .../java/io/appwrite/enums/OAuthProvider.kt | 41 ++++ .../main/java/io/appwrite/services/Account.kt | 77 ++++++- 126 files changed, 632 insertions(+), 267 deletions(-) rename docs/examples/java/account/{create2f-a-challenge.md => create-challenge.md} (95%) create mode 100644 docs/examples/java/account/create-o-auth2token.md rename docs/examples/kotlin/account/{create2f-a-challenge.md => create-challenge.md} (89%) create mode 100644 docs/examples/kotlin/account/create-o-auth2token.md delete mode 100644 library/src/main/java/io/appwrite/OS.kt diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ffe898b..7145ba6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,7 +16,6 @@ jobs: uses: actions/setup-java@v1 with: java-version: 17 - # Base64 decodes and pipes the GPG key content into the secret file - name: Prepare environment env: GPG_KEY_CONTENTS: ${{ secrets.GPG_KEY_CONTENTS }} diff --git a/README.md b/README.md index 61632fd..c8363ac 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:5.0.0-rc.4") +implementation("io.appwrite:sdk-for-android:5.0.0-rc.5") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 5.0.0-rc.4 + 5.0.0-rc.5 ``` @@ -109,8 +109,9 @@ When trying to connect to Appwrite from an emulator or a mobile device, localhos val account = Account(client) val response = account.create( ID.unique(), - "email@example.com", - "password" + "email@example.com", + "password", + "Walter O'Brien" ) ``` @@ -129,8 +130,9 @@ val client = Client(context) val account = Account(client) val user = account.create( ID.unique(), - "email@example.com", - "password" + "email@example.com", + "password", + "Walter O'Brien" ) ``` @@ -139,7 +141,7 @@ The Appwrite Android SDK raises an `AppwriteException` object with `message`, `c ```kotlin try { - var user = account.create(ID.unique(), "email@example.com", "password") + var user = account.create(ID.unique(),"email@example.com","password","Walter O'Brien") Log.d("Appwrite user", user.toMap()) } catch(e : AppwriteException) { e.printStackTrace() @@ -153,6 +155,7 @@ You can use the following resources to learn more and get help - 💬 [Discord Community](https://appwrite.io/discord) - 🚂 [Appwrite Android Playground](https://github.com/appwrite/playground-for-android) + ## Contribution This library is auto-generated by Appwrite custom [SDK Generator](https://github.com/appwrite/sdk-generator). To learn more about how you can help us improve this SDK, please check the [contribution guide](https://github.com/appwrite/sdk-generator/blob/master/CONTRIBUTING.md) before sending a pull-request. diff --git a/docs/examples/java/account/create2f-a-challenge.md b/docs/examples/java/account/create-challenge.md similarity index 95% rename from docs/examples/java/account/create2f-a-challenge.md rename to docs/examples/java/account/create-challenge.md index e095df7..7a31920 100644 --- a/docs/examples/java/account/create2f-a-challenge.md +++ b/docs/examples/java/account/create-challenge.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); -account.create2FAChallenge( +account.createChallenge( AuthenticationFactor.TOTP, // factor new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/account/create-email-token.md b/docs/examples/java/account/create-email-token.md index c308ca7..adf8b3d 100644 --- a/docs/examples/java/account/create-email-token.md +++ b/docs/examples/java/account/create-email-token.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.createEmailToken( - "[USER_ID]", // userId + "", // userId "email@example.com", // email false, // phrase (optional) new CoroutineCallback<>((result, error) -> { diff --git a/docs/examples/java/account/create-magic-u-r-l-token.md b/docs/examples/java/account/create-magic-u-r-l-token.md index c3a3392..21108cc 100644 --- a/docs/examples/java/account/create-magic-u-r-l-token.md +++ b/docs/examples/java/account/create-magic-u-r-l-token.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.createMagicURLToken( - "[USER_ID]", // userId + "", // userId "email@example.com", // email "https://example.com", // url (optional) false, // phrase (optional) diff --git a/docs/examples/java/account/create-o-auth2session.md b/docs/examples/java/account/create-o-auth2session.md index 1e1a3b2..ba284a1 100644 --- a/docs/examples/java/account/create-o-auth2session.md +++ b/docs/examples/java/account/create-o-auth2session.md @@ -13,7 +13,6 @@ account.createOAuth2Session( OAuthProvider.AMAZON, // provider "https://example.com", // success (optional) "https://example.com", // failure (optional) - false, // token (optional) listOf(), // scopes (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/account/create-o-auth2token.md b/docs/examples/java/account/create-o-auth2token.md new file mode 100644 index 0000000..eb64da1 --- /dev/null +++ b/docs/examples/java/account/create-o-auth2token.md @@ -0,0 +1,26 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; +import io.appwrite.enums.OAuthProvider; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.createOAuth2Token( + OAuthProvider.AMAZON, // provider + "https://example.com", // success (optional) + "https://example.com", // failure (optional) + listOf(), // scopes (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/account/create-phone-token.md b/docs/examples/java/account/create-phone-token.md index a47d57b..29ef311 100644 --- a/docs/examples/java/account/create-phone-token.md +++ b/docs/examples/java/account/create-phone-token.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.createPhoneToken( - "[USER_ID]", // userId + "", // userId "+12065550100", // phone new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/account/create-push-target.md b/docs/examples/java/account/create-push-target.md index 8268bee..7eff453 100644 --- a/docs/examples/java/account/create-push-target.md +++ b/docs/examples/java/account/create-push-target.md @@ -9,9 +9,9 @@ Client client = new Client(context) Account account = new Account(client); account.createPushTarget( - "[TARGET_ID]", // targetId - "[IDENTIFIER]", // identifier - "[PROVIDER_ID]", // providerId (optional) + "", // targetId + "", // identifier + "", // providerId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/create-session.md b/docs/examples/java/account/create-session.md index b1805fa..013d372 100644 --- a/docs/examples/java/account/create-session.md +++ b/docs/examples/java/account/create-session.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.createSession( - "[USER_ID]", // userId - "[SECRET]", // secret + "", // userId + "", // secret new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/create.md b/docs/examples/java/account/create.md index dce55b7..8ee1de3 100644 --- a/docs/examples/java/account/create.md +++ b/docs/examples/java/account/create.md @@ -9,10 +9,10 @@ Client client = new Client(context) Account account = new Account(client); account.create( - "[USER_ID]", // userId + "", // userId "email@example.com", // email "", // password - "[NAME]", // name (optional) + "", // name (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/delete-authenticator.md b/docs/examples/java/account/delete-authenticator.md index 4525524..c988cfa 100644 --- a/docs/examples/java/account/delete-authenticator.md +++ b/docs/examples/java/account/delete-authenticator.md @@ -11,7 +11,7 @@ Account account = new Account(client); account.deleteAuthenticator( AuthenticatorType.TOTP, // type - "[OTP]", // otp + "", // otp new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/delete-identity.md b/docs/examples/java/account/delete-identity.md index 5cc7178..1d6922a 100644 --- a/docs/examples/java/account/delete-identity.md +++ b/docs/examples/java/account/delete-identity.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.deleteIdentity( - "[IDENTITY_ID]", // identityId + "", // identityId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/delete-push-target.md b/docs/examples/java/account/delete-push-target.md index f798ea9..484fc2c 100644 --- a/docs/examples/java/account/delete-push-target.md +++ b/docs/examples/java/account/delete-push-target.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.deletePushTarget( - "[TARGET_ID]", // targetId + "", // targetId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/delete-session.md b/docs/examples/java/account/delete-session.md index 9d11640..4344061 100644 --- a/docs/examples/java/account/delete-session.md +++ b/docs/examples/java/account/delete-session.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.deleteSession( - "[SESSION_ID]", // sessionId + "", // sessionId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/get-session.md b/docs/examples/java/account/get-session.md index fe01211..470f643 100644 --- a/docs/examples/java/account/get-session.md +++ b/docs/examples/java/account/get-session.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.getSession( - "[SESSION_ID]", // sessionId + "", // sessionId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-challenge.md b/docs/examples/java/account/update-challenge.md index 7e2d369..b2953e3 100644 --- a/docs/examples/java/account/update-challenge.md +++ b/docs/examples/java/account/update-challenge.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.updateChallenge( - "[CHALLENGE_ID]", // challengeId - "[OTP]", // otp + "", // challengeId + "", // otp new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); 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 697e00a..339b1f7 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 @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.updateMagicURLSession( - "[USER_ID]", // userId - "[SECRET]", // secret + "", // userId + "", // secret new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-name.md b/docs/examples/java/account/update-name.md index bc64afc..ff23ace 100644 --- a/docs/examples/java/account/update-name.md +++ b/docs/examples/java/account/update-name.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.updateName( - "[NAME]", // name + "", // name new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-phone-verification.md b/docs/examples/java/account/update-phone-verification.md index 94c2eb2..304e73e 100644 --- a/docs/examples/java/account/update-phone-verification.md +++ b/docs/examples/java/account/update-phone-verification.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.updatePhoneVerification( - "[USER_ID]", // userId - "[SECRET]", // secret + "", // userId + "", // secret new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-push-target.md b/docs/examples/java/account/update-push-target.md index 7dd97fd..90dc29e 100644 --- a/docs/examples/java/account/update-push-target.md +++ b/docs/examples/java/account/update-push-target.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.updatePushTarget( - "[TARGET_ID]", // targetId - "[IDENTIFIER]", // identifier + "", // targetId + "", // identifier new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-recovery.md b/docs/examples/java/account/update-recovery.md index b009e43..527351c 100644 --- a/docs/examples/java/account/update-recovery.md +++ b/docs/examples/java/account/update-recovery.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.updateRecovery( - "[USER_ID]", // userId - "[SECRET]", // secret + "", // userId + "", // secret "", // password new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/account/update-session.md b/docs/examples/java/account/update-session.md index aac43e4..e2ef0c3 100644 --- a/docs/examples/java/account/update-session.md +++ b/docs/examples/java/account/update-session.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.updateSession( - "[SESSION_ID]", // sessionId + "", // sessionId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-verification.md b/docs/examples/java/account/update-verification.md index f6020ae..3f14196 100644 --- a/docs/examples/java/account/update-verification.md +++ b/docs/examples/java/account/update-verification.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.updateVerification( - "[USER_ID]", // userId - "[SECRET]", // secret + "", // userId + "", // secret new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/verify-authenticator.md b/docs/examples/java/account/verify-authenticator.md index 7d5efe4..c73ac43 100644 --- a/docs/examples/java/account/verify-authenticator.md +++ b/docs/examples/java/account/verify-authenticator.md @@ -11,7 +11,7 @@ Account account = new Account(client); account.verifyAuthenticator( AuthenticatorType.TOTP, // type - "[OTP]", // otp + "", // otp new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/avatars/get-initials.md b/docs/examples/java/avatars/get-initials.md index d019a16..f6c3ee6 100644 --- a/docs/examples/java/avatars/get-initials.md +++ b/docs/examples/java/avatars/get-initials.md @@ -9,7 +9,7 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); avatars.getInitials( - "[NAME]", // name (optional) + "", // name (optional) 0, // width (optional) 0, // height (optional) "", // background (optional) diff --git a/docs/examples/java/avatars/get-q-r.md b/docs/examples/java/avatars/get-q-r.md index 19fbe7a..d75b3b3 100644 --- a/docs/examples/java/avatars/get-q-r.md +++ b/docs/examples/java/avatars/get-q-r.md @@ -9,7 +9,7 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); avatars.getQR( - "[TEXT]", // text + "", // text 1, // size (optional) 0, // margin (optional) false, // download (optional) diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index c409d8e..361d5fe 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -9,9 +9,9 @@ Client client = new Client(context) Databases databases = new Databases(client); databases.createDocument( - "[DATABASE_ID]", // databaseId - "[COLLECTION_ID]", // collectionId - "[DOCUMENT_ID]", // documentId + "", // databaseId + "", // collectionId + "", // documentId mapOf( "a" to "b" ), // data listOf("read("any")"), // permissions (optional) new CoroutineCallback<>((result, error) -> { diff --git a/docs/examples/java/databases/delete-document.md b/docs/examples/java/databases/delete-document.md index 8ab8f61..26b67a2 100644 --- a/docs/examples/java/databases/delete-document.md +++ b/docs/examples/java/databases/delete-document.md @@ -9,9 +9,9 @@ Client client = new Client(context) Databases databases = new Databases(client); databases.deleteDocument( - "[DATABASE_ID]", // databaseId - "[COLLECTION_ID]", // collectionId - "[DOCUMENT_ID]", // documentId + "", // databaseId + "", // collectionId + "", // documentId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/get-document.md b/docs/examples/java/databases/get-document.md index 4ee0d6d..ac89489 100644 --- a/docs/examples/java/databases/get-document.md +++ b/docs/examples/java/databases/get-document.md @@ -9,9 +9,9 @@ Client client = new Client(context) Databases databases = new Databases(client); databases.getDocument( - "[DATABASE_ID]", // databaseId - "[COLLECTION_ID]", // collectionId - "[DOCUMENT_ID]", // documentId + "", // databaseId + "", // collectionId + "", // documentId listOf(), // queries (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/databases/list-documents.md b/docs/examples/java/databases/list-documents.md index 5aaf4f2..9f70425 100644 --- a/docs/examples/java/databases/list-documents.md +++ b/docs/examples/java/databases/list-documents.md @@ -9,8 +9,8 @@ Client client = new Client(context) Databases databases = new Databases(client); databases.listDocuments( - "[DATABASE_ID]", // databaseId - "[COLLECTION_ID]", // collectionId + "", // databaseId + "", // collectionId listOf(), // queries (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/databases/update-document.md b/docs/examples/java/databases/update-document.md index ba1b7a8..430a617 100644 --- a/docs/examples/java/databases/update-document.md +++ b/docs/examples/java/databases/update-document.md @@ -9,9 +9,9 @@ Client client = new Client(context) Databases databases = new Databases(client); databases.updateDocument( - "[DATABASE_ID]", // databaseId - "[COLLECTION_ID]", // collectionId - "[DOCUMENT_ID]", // documentId + "", // databaseId + "", // collectionId + "", // documentId mapOf( "a" to "b" ), // data (optional) listOf("read("any")"), // permissions (optional) new CoroutineCallback<>((result, error) -> { diff --git a/docs/examples/java/functions/create-execution.md b/docs/examples/java/functions/create-execution.md index ab1c32c..0db569b 100644 --- a/docs/examples/java/functions/create-execution.md +++ b/docs/examples/java/functions/create-execution.md @@ -9,10 +9,10 @@ Client client = new Client(context) Functions functions = new Functions(client); functions.createExecution( - "[FUNCTION_ID]", // functionId - "[BODY]", // body (optional) + "", // functionId + "", // body (optional) false, // async (optional) - "[PATH]", // path (optional) + "", // path (optional) ExecutionMethod.GET, // method (optional) mapOf( "a" to "b" ), // headers (optional) new CoroutineCallback<>((result, error) -> { diff --git a/docs/examples/java/functions/get-execution.md b/docs/examples/java/functions/get-execution.md index 5f1a772..66bf263 100644 --- a/docs/examples/java/functions/get-execution.md +++ b/docs/examples/java/functions/get-execution.md @@ -9,8 +9,8 @@ Client client = new Client(context) Functions functions = new Functions(client); functions.getExecution( - "[FUNCTION_ID]", // functionId - "[EXECUTION_ID]", // executionId + "", // functionId + "", // executionId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/functions/list-executions.md b/docs/examples/java/functions/list-executions.md index 1405da6..1bb510a 100644 --- a/docs/examples/java/functions/list-executions.md +++ b/docs/examples/java/functions/list-executions.md @@ -9,9 +9,9 @@ Client client = new Client(context) Functions functions = new Functions(client); functions.listExecutions( - "[FUNCTION_ID]", // functionId + "", // functionId listOf(), // queries (optional) - "[SEARCH]", // search (optional) + "", // search (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/messaging/create-subscriber.md b/docs/examples/java/messaging/create-subscriber.md index f059ae2..e83b43c 100644 --- a/docs/examples/java/messaging/create-subscriber.md +++ b/docs/examples/java/messaging/create-subscriber.md @@ -9,9 +9,9 @@ Client client = new Client(context) Messaging messaging = new Messaging(client); messaging.createSubscriber( - "[TOPIC_ID]", // topicId - "[SUBSCRIBER_ID]", // subscriberId - "[TARGET_ID]", // targetId + "", // topicId + "", // subscriberId + "", // targetId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/messaging/delete-subscriber.md b/docs/examples/java/messaging/delete-subscriber.md index ee2caa3..5e8302b 100644 --- a/docs/examples/java/messaging/delete-subscriber.md +++ b/docs/examples/java/messaging/delete-subscriber.md @@ -9,8 +9,8 @@ Client client = new Client(context) Messaging messaging = new Messaging(client); messaging.deleteSubscriber( - "[TOPIC_ID]", // topicId - "[SUBSCRIBER_ID]", // subscriberId + "", // topicId + "", // subscriberId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/create-file.md b/docs/examples/java/storage/create-file.md index 3c67a7b..a060552 100644 --- a/docs/examples/java/storage/create-file.md +++ b/docs/examples/java/storage/create-file.md @@ -10,8 +10,8 @@ Client client = new Client(context) Storage storage = new Storage(client); storage.createFile( - "[BUCKET_ID]", // bucketId - "[FILE_ID]", // fileId + "", // bucketId + "", // fileId InputFile.fromPath("file.png"), // file listOf("read("any")"), // permissions (optional) new CoroutineCallback<>((result, error) -> { diff --git a/docs/examples/java/storage/delete-file.md b/docs/examples/java/storage/delete-file.md index f216bbf..113dfce 100644 --- a/docs/examples/java/storage/delete-file.md +++ b/docs/examples/java/storage/delete-file.md @@ -9,8 +9,8 @@ Client client = new Client(context) Storage storage = new Storage(client); storage.deleteFile( - "[BUCKET_ID]", // bucketId - "[FILE_ID]", // fileId + "", // bucketId + "", // fileId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/get-file-download.md b/docs/examples/java/storage/get-file-download.md index a46ae8e..22207ca 100644 --- a/docs/examples/java/storage/get-file-download.md +++ b/docs/examples/java/storage/get-file-download.md @@ -9,8 +9,8 @@ Client client = new Client(context) Storage storage = new Storage(client); storage.getFileDownload( - "[BUCKET_ID]", // bucketId - "[FILE_ID]", // fileId + "", // bucketId + "", // fileId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/get-file-preview.md b/docs/examples/java/storage/get-file-preview.md index dfe66a7..df81fb4 100644 --- a/docs/examples/java/storage/get-file-preview.md +++ b/docs/examples/java/storage/get-file-preview.md @@ -9,8 +9,8 @@ Client client = new Client(context) Storage storage = new Storage(client); storage.getFilePreview( - "[BUCKET_ID]", // bucketId - "[FILE_ID]", // fileId + "", // bucketId + "", // fileId 0, // width (optional) 0, // height (optional) ImageGravity.CENTER, // gravity (optional) diff --git a/docs/examples/java/storage/get-file-view.md b/docs/examples/java/storage/get-file-view.md index 18dd41e..d64c3e6 100644 --- a/docs/examples/java/storage/get-file-view.md +++ b/docs/examples/java/storage/get-file-view.md @@ -9,8 +9,8 @@ Client client = new Client(context) Storage storage = new Storage(client); storage.getFileView( - "[BUCKET_ID]", // bucketId - "[FILE_ID]", // fileId + "", // bucketId + "", // fileId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/get-file.md b/docs/examples/java/storage/get-file.md index 5bc2456..b68bf78 100644 --- a/docs/examples/java/storage/get-file.md +++ b/docs/examples/java/storage/get-file.md @@ -9,8 +9,8 @@ Client client = new Client(context) Storage storage = new Storage(client); storage.getFile( - "[BUCKET_ID]", // bucketId - "[FILE_ID]", // fileId + "", // bucketId + "", // fileId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/list-files.md b/docs/examples/java/storage/list-files.md index 2fdd026..8b84ecb 100644 --- a/docs/examples/java/storage/list-files.md +++ b/docs/examples/java/storage/list-files.md @@ -9,9 +9,9 @@ Client client = new Client(context) Storage storage = new Storage(client); storage.listFiles( - "[BUCKET_ID]", // bucketId + "", // bucketId listOf(), // queries (optional) - "[SEARCH]", // search (optional) + "", // search (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/update-file.md b/docs/examples/java/storage/update-file.md index c445c28..12b6443 100644 --- a/docs/examples/java/storage/update-file.md +++ b/docs/examples/java/storage/update-file.md @@ -9,9 +9,9 @@ Client client = new Client(context) Storage storage = new Storage(client); storage.updateFile( - "[BUCKET_ID]", // bucketId - "[FILE_ID]", // fileId - "[NAME]", // name (optional) + "", // bucketId + "", // fileId + "", // name (optional) listOf("read("any")"), // permissions (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/teams/create-membership.md b/docs/examples/java/teams/create-membership.md index 9d8a73a..468571e 100644 --- a/docs/examples/java/teams/create-membership.md +++ b/docs/examples/java/teams/create-membership.md @@ -9,13 +9,13 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.createMembership( - "[TEAM_ID]", // teamId + "", // teamId listOf(), // roles "email@example.com", // email (optional) - "[USER_ID]", // userId (optional) + "", // userId (optional) "+12065550100", // phone (optional) "https://example.com", // url (optional) - "[NAME]", // name (optional) + "", // name (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/create.md b/docs/examples/java/teams/create.md index f637994..3c757ac 100644 --- a/docs/examples/java/teams/create.md +++ b/docs/examples/java/teams/create.md @@ -9,8 +9,8 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.create( - "[TEAM_ID]", // teamId - "[NAME]", // name + "", // teamId + "", // name listOf(), // roles (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/teams/delete-membership.md b/docs/examples/java/teams/delete-membership.md index ecf2bdc..e23409f 100644 --- a/docs/examples/java/teams/delete-membership.md +++ b/docs/examples/java/teams/delete-membership.md @@ -9,8 +9,8 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.deleteMembership( - "[TEAM_ID]", // teamId - "[MEMBERSHIP_ID]", // membershipId + "", // teamId + "", // membershipId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/delete.md b/docs/examples/java/teams/delete.md index 62bb284..567ea3d 100644 --- a/docs/examples/java/teams/delete.md +++ b/docs/examples/java/teams/delete.md @@ -9,7 +9,7 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.delete( - "[TEAM_ID]", // teamId + "", // teamId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/get-membership.md b/docs/examples/java/teams/get-membership.md index 5a0eb03..c09a267 100644 --- a/docs/examples/java/teams/get-membership.md +++ b/docs/examples/java/teams/get-membership.md @@ -9,8 +9,8 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.getMembership( - "[TEAM_ID]", // teamId - "[MEMBERSHIP_ID]", // membershipId + "", // teamId + "", // membershipId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/get-prefs.md b/docs/examples/java/teams/get-prefs.md index 78d01de..48a9815 100644 --- a/docs/examples/java/teams/get-prefs.md +++ b/docs/examples/java/teams/get-prefs.md @@ -9,7 +9,7 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.getPrefs( - "[TEAM_ID]", // teamId + "", // teamId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/get.md b/docs/examples/java/teams/get.md index 9442b85..20a6f6a 100644 --- a/docs/examples/java/teams/get.md +++ b/docs/examples/java/teams/get.md @@ -9,7 +9,7 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.get( - "[TEAM_ID]", // teamId + "", // teamId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/list-memberships.md b/docs/examples/java/teams/list-memberships.md index 92934bf..2de609c 100644 --- a/docs/examples/java/teams/list-memberships.md +++ b/docs/examples/java/teams/list-memberships.md @@ -9,9 +9,9 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.listMemberships( - "[TEAM_ID]", // teamId + "", // teamId listOf(), // queries (optional) - "[SEARCH]", // search (optional) + "", // search (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/list.md b/docs/examples/java/teams/list.md index 6eacc8e..7f7910c 100644 --- a/docs/examples/java/teams/list.md +++ b/docs/examples/java/teams/list.md @@ -10,7 +10,7 @@ Teams teams = new Teams(client); teams.list( listOf(), // queries (optional) - "[SEARCH]", // search (optional) + "", // search (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/update-membership-status.md b/docs/examples/java/teams/update-membership-status.md index 8a01220..97e8242 100644 --- a/docs/examples/java/teams/update-membership-status.md +++ b/docs/examples/java/teams/update-membership-status.md @@ -9,10 +9,10 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.updateMembershipStatus( - "[TEAM_ID]", // teamId - "[MEMBERSHIP_ID]", // membershipId - "[USER_ID]", // userId - "[SECRET]", // secret + "", // teamId + "", // membershipId + "", // userId + "", // secret new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/update-membership.md b/docs/examples/java/teams/update-membership.md index 779479b..86f0ddd 100644 --- a/docs/examples/java/teams/update-membership.md +++ b/docs/examples/java/teams/update-membership.md @@ -9,8 +9,8 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.updateMembership( - "[TEAM_ID]", // teamId - "[MEMBERSHIP_ID]", // membershipId + "", // teamId + "", // membershipId listOf(), // roles new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/teams/update-name.md b/docs/examples/java/teams/update-name.md index 50960fb..1aa96f8 100644 --- a/docs/examples/java/teams/update-name.md +++ b/docs/examples/java/teams/update-name.md @@ -9,8 +9,8 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.updateName( - "[TEAM_ID]", // teamId - "[NAME]", // name + "", // teamId + "", // name new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/update-prefs.md b/docs/examples/java/teams/update-prefs.md index 9949b44..e188a99 100644 --- a/docs/examples/java/teams/update-prefs.md +++ b/docs/examples/java/teams/update-prefs.md @@ -9,7 +9,7 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.updatePrefs( - "[TEAM_ID]", // teamId + "", // teamId mapOf( "a" to "b" ), // prefs new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/kotlin/account/create2f-a-challenge.md b/docs/examples/kotlin/account/create-challenge.md similarity index 89% rename from docs/examples/kotlin/account/create2f-a-challenge.md rename to docs/examples/kotlin/account/create-challenge.md index 4608491..273d062 100644 --- a/docs/examples/kotlin/account/create2f-a-challenge.md +++ b/docs/examples/kotlin/account/create-challenge.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) -val response = account.create2FAChallenge( +val response = account.createChallenge( factor = AuthenticationFactor.TOTP, ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-email-token.md b/docs/examples/kotlin/account/create-email-token.md index f8ecea0..750be55 100644 --- a/docs/examples/kotlin/account/create-email-token.md +++ b/docs/examples/kotlin/account/create-email-token.md @@ -9,7 +9,7 @@ val client = Client(context) val account = Account(client) val response = account.createEmailToken( - userId = "[USER_ID]", + userId = "", email = "email@example.com", phrase = false, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-magic-u-r-l-token.md b/docs/examples/kotlin/account/create-magic-u-r-l-token.md index 93122ab..99ce7ae 100644 --- a/docs/examples/kotlin/account/create-magic-u-r-l-token.md +++ b/docs/examples/kotlin/account/create-magic-u-r-l-token.md @@ -9,7 +9,7 @@ val client = Client(context) val account = Account(client) val response = account.createMagicURLToken( - userId = "[USER_ID]", + userId = "", email = "email@example.com", url = "https://example.com", // (optional) phrase = false, // (optional) diff --git a/docs/examples/kotlin/account/create-o-auth2session.md b/docs/examples/kotlin/account/create-o-auth2session.md index 90a4e56..d642de8 100644 --- a/docs/examples/kotlin/account/create-o-auth2session.md +++ b/docs/examples/kotlin/account/create-o-auth2session.md @@ -13,6 +13,5 @@ account.createOAuth2Session( provider = OAuthProvider.AMAZON, success = "https://example.com", // (optional) failure = "https://example.com", // (optional) - token = false, // (optional) scopes = listOf(), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-o-auth2token.md b/docs/examples/kotlin/account/create-o-auth2token.md new file mode 100644 index 0000000..7d651b1 --- /dev/null +++ b/docs/examples/kotlin/account/create-o-auth2token.md @@ -0,0 +1,17 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account +import io.appwrite.enums.OAuthProvider + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +account.createOAuth2Token( + provider = OAuthProvider.AMAZON, + success = "https://example.com", // (optional) + failure = "https://example.com", // (optional) + scopes = listOf(), // (optional) +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-phone-token.md b/docs/examples/kotlin/account/create-phone-token.md index b85d8c5..acef3bd 100644 --- a/docs/examples/kotlin/account/create-phone-token.md +++ b/docs/examples/kotlin/account/create-phone-token.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val response = account.createPhoneToken( - userId = "[USER_ID]", + userId = "", phone = "+12065550100", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-push-target.md b/docs/examples/kotlin/account/create-push-target.md index f9dd27b..de9b5a2 100644 --- a/docs/examples/kotlin/account/create-push-target.md +++ b/docs/examples/kotlin/account/create-push-target.md @@ -9,7 +9,7 @@ val client = Client(context) val account = Account(client) val response = account.createPushTarget( - targetId = "[TARGET_ID]", - identifier = "[IDENTIFIER]", - providerId = "[PROVIDER_ID]", // (optional) + targetId = "", + identifier = "", + providerId = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-session.md b/docs/examples/kotlin/account/create-session.md index 5639145..1ea8d22 100644 --- a/docs/examples/kotlin/account/create-session.md +++ b/docs/examples/kotlin/account/create-session.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val response = account.createSession( - userId = "[USER_ID]", - secret = "[SECRET]", + userId = "", + secret = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create.md b/docs/examples/kotlin/account/create.md index 377cccc..21718ef 100644 --- a/docs/examples/kotlin/account/create.md +++ b/docs/examples/kotlin/account/create.md @@ -9,8 +9,8 @@ val client = Client(context) val account = Account(client) val response = account.create( - userId = "[USER_ID]", + userId = "", email = "email@example.com", password = "", - name = "[NAME]", // (optional) + name = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-authenticator.md b/docs/examples/kotlin/account/delete-authenticator.md index 7033470..6cb24db 100644 --- a/docs/examples/kotlin/account/delete-authenticator.md +++ b/docs/examples/kotlin/account/delete-authenticator.md @@ -11,5 +11,5 @@ val account = Account(client) val response = account.deleteAuthenticator( type = AuthenticatorType.TOTP, - otp = "[OTP]", + otp = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-identity.md b/docs/examples/kotlin/account/delete-identity.md index 96fa467..1507342 100644 --- a/docs/examples/kotlin/account/delete-identity.md +++ b/docs/examples/kotlin/account/delete-identity.md @@ -9,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.deleteIdentity( - identityId = "[IDENTITY_ID]", + identityId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-push-target.md b/docs/examples/kotlin/account/delete-push-target.md index c03c13d..c774d02 100644 --- a/docs/examples/kotlin/account/delete-push-target.md +++ b/docs/examples/kotlin/account/delete-push-target.md @@ -9,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.deletePushTarget( - targetId = "[TARGET_ID]", + targetId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-session.md b/docs/examples/kotlin/account/delete-session.md index 52ff38e..b49b3a5 100644 --- a/docs/examples/kotlin/account/delete-session.md +++ b/docs/examples/kotlin/account/delete-session.md @@ -9,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.deleteSession( - sessionId = "[SESSION_ID]", + sessionId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/get-session.md b/docs/examples/kotlin/account/get-session.md index 261f295..38a5fa6 100644 --- a/docs/examples/kotlin/account/get-session.md +++ b/docs/examples/kotlin/account/get-session.md @@ -9,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.getSession( - sessionId = "[SESSION_ID]", + sessionId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-challenge.md b/docs/examples/kotlin/account/update-challenge.md index 44a6dbd..2bf6754 100644 --- a/docs/examples/kotlin/account/update-challenge.md +++ b/docs/examples/kotlin/account/update-challenge.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val response = account.updateChallenge( - challengeId = "[CHALLENGE_ID]", - otp = "[OTP]", + challengeId = "", + otp = "", ) \ No newline at end of file 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 bbf5c65..9226177 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 @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val response = account.updateMagicURLSession( - userId = "[USER_ID]", - secret = "[SECRET]", + userId = "", + secret = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-name.md b/docs/examples/kotlin/account/update-name.md index 9b1cb8c..5af1deb 100644 --- a/docs/examples/kotlin/account/update-name.md +++ b/docs/examples/kotlin/account/update-name.md @@ -9,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.updateName( - name = "[NAME]", + name = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-phone-verification.md b/docs/examples/kotlin/account/update-phone-verification.md index d86f478..0ef08ce 100644 --- a/docs/examples/kotlin/account/update-phone-verification.md +++ b/docs/examples/kotlin/account/update-phone-verification.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val response = account.updatePhoneVerification( - userId = "[USER_ID]", - secret = "[SECRET]", + userId = "", + secret = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-push-target.md b/docs/examples/kotlin/account/update-push-target.md index 019f55c..2a7d4d7 100644 --- a/docs/examples/kotlin/account/update-push-target.md +++ b/docs/examples/kotlin/account/update-push-target.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val response = account.updatePushTarget( - targetId = "[TARGET_ID]", - identifier = "[IDENTIFIER]", + targetId = "", + identifier = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-recovery.md b/docs/examples/kotlin/account/update-recovery.md index 176dd25..646c3a5 100644 --- a/docs/examples/kotlin/account/update-recovery.md +++ b/docs/examples/kotlin/account/update-recovery.md @@ -9,7 +9,7 @@ val client = Client(context) val account = Account(client) val response = account.updateRecovery( - userId = "[USER_ID]", - secret = "[SECRET]", + userId = "", + secret = "", password = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-session.md b/docs/examples/kotlin/account/update-session.md index afea816..2bad6e8 100644 --- a/docs/examples/kotlin/account/update-session.md +++ b/docs/examples/kotlin/account/update-session.md @@ -9,5 +9,5 @@ val client = Client(context) val account = Account(client) val response = account.updateSession( - sessionId = "[SESSION_ID]", + sessionId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-verification.md b/docs/examples/kotlin/account/update-verification.md index eae6318..129b825 100644 --- a/docs/examples/kotlin/account/update-verification.md +++ b/docs/examples/kotlin/account/update-verification.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val response = account.updateVerification( - userId = "[USER_ID]", - secret = "[SECRET]", + userId = "", + secret = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/verify-authenticator.md b/docs/examples/kotlin/account/verify-authenticator.md index 5b9b7ca..a0f5dd3 100644 --- a/docs/examples/kotlin/account/verify-authenticator.md +++ b/docs/examples/kotlin/account/verify-authenticator.md @@ -11,5 +11,5 @@ val account = Account(client) val response = account.verifyAuthenticator( type = AuthenticatorType.TOTP, - otp = "[OTP]", + otp = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-initials.md b/docs/examples/kotlin/avatars/get-initials.md index 5c84a34..69f2f9b 100644 --- a/docs/examples/kotlin/avatars/get-initials.md +++ b/docs/examples/kotlin/avatars/get-initials.md @@ -9,7 +9,7 @@ val client = Client(context) val avatars = Avatars(client) val result =avatars.getInitials( - name = "[NAME]", // (optional) + name = "", // (optional) width = 0, // (optional) height = 0, // (optional) background = "", // (optional) diff --git a/docs/examples/kotlin/avatars/get-q-r.md b/docs/examples/kotlin/avatars/get-q-r.md index bc525d0..e54b0c4 100644 --- a/docs/examples/kotlin/avatars/get-q-r.md +++ b/docs/examples/kotlin/avatars/get-q-r.md @@ -9,7 +9,7 @@ val client = Client(context) val avatars = Avatars(client) val result =avatars.getQR( - text = "[TEXT]", + text = "", size = 1, // (optional) margin = 0, // (optional) download = false, // (optional) diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index 7155af9..6a36558 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -9,9 +9,9 @@ val client = Client(context) val databases = Databases(client) val response = databases.createDocument( - databaseId = "[DATABASE_ID]", - collectionId = "[COLLECTION_ID]", - documentId = "[DOCUMENT_ID]", + databaseId = "", + collectionId = "", + documentId = "", data = mapOf( "a" to "b" ), permissions = listOf("read("any")"), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/delete-document.md b/docs/examples/kotlin/databases/delete-document.md index f9e7a07..f8859a5 100644 --- a/docs/examples/kotlin/databases/delete-document.md +++ b/docs/examples/kotlin/databases/delete-document.md @@ -9,7 +9,7 @@ val client = Client(context) val databases = Databases(client) val response = databases.deleteDocument( - databaseId = "[DATABASE_ID]", - collectionId = "[COLLECTION_ID]", - documentId = "[DOCUMENT_ID]", + databaseId = "", + collectionId = "", + documentId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/get-document.md b/docs/examples/kotlin/databases/get-document.md index b52852c..5a8e260 100644 --- a/docs/examples/kotlin/databases/get-document.md +++ b/docs/examples/kotlin/databases/get-document.md @@ -9,8 +9,8 @@ val client = Client(context) val databases = Databases(client) val response = databases.getDocument( - databaseId = "[DATABASE_ID]", - collectionId = "[COLLECTION_ID]", - documentId = "[DOCUMENT_ID]", + databaseId = "", + collectionId = "", + documentId = "", queries = listOf(), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/list-documents.md b/docs/examples/kotlin/databases/list-documents.md index 9bcdea2..5601f06 100644 --- a/docs/examples/kotlin/databases/list-documents.md +++ b/docs/examples/kotlin/databases/list-documents.md @@ -9,7 +9,7 @@ val client = Client(context) val databases = Databases(client) val response = databases.listDocuments( - databaseId = "[DATABASE_ID]", - collectionId = "[COLLECTION_ID]", + databaseId = "", + collectionId = "", queries = listOf(), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/update-document.md b/docs/examples/kotlin/databases/update-document.md index ae19c7e..583ba3f 100644 --- a/docs/examples/kotlin/databases/update-document.md +++ b/docs/examples/kotlin/databases/update-document.md @@ -9,9 +9,9 @@ val client = Client(context) val databases = Databases(client) val response = databases.updateDocument( - databaseId = "[DATABASE_ID]", - collectionId = "[COLLECTION_ID]", - documentId = "[DOCUMENT_ID]", + databaseId = "", + collectionId = "", + documentId = "", data = mapOf( "a" to "b" ), // (optional) permissions = listOf("read("any")"), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/create-execution.md b/docs/examples/kotlin/functions/create-execution.md index 4a2cd3f..b0b5538 100644 --- a/docs/examples/kotlin/functions/create-execution.md +++ b/docs/examples/kotlin/functions/create-execution.md @@ -9,10 +9,10 @@ val client = Client(context) val functions = Functions(client) val response = functions.createExecution( - functionId = "[FUNCTION_ID]", - body = "[BODY]", // (optional) + functionId = "", + body = "", // (optional) async = false, // (optional) - path = "[PATH]", // (optional) + path = "", // (optional) method = ExecutionMethod.GET, // (optional) headers = mapOf( "a" to "b" ), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/get-execution.md b/docs/examples/kotlin/functions/get-execution.md index cbe8dd1..2adbf9a 100644 --- a/docs/examples/kotlin/functions/get-execution.md +++ b/docs/examples/kotlin/functions/get-execution.md @@ -9,6 +9,6 @@ val client = Client(context) val functions = Functions(client) val response = functions.getExecution( - functionId = "[FUNCTION_ID]", - executionId = "[EXECUTION_ID]", + functionId = "", + executionId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/list-executions.md b/docs/examples/kotlin/functions/list-executions.md index 2b6c5f8..8e02409 100644 --- a/docs/examples/kotlin/functions/list-executions.md +++ b/docs/examples/kotlin/functions/list-executions.md @@ -9,7 +9,7 @@ val client = Client(context) val functions = Functions(client) val response = functions.listExecutions( - functionId = "[FUNCTION_ID]", + functionId = "", queries = listOf(), // (optional) - search = "[SEARCH]", // (optional) + search = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/messaging/create-subscriber.md b/docs/examples/kotlin/messaging/create-subscriber.md index 163c427..20771e5 100644 --- a/docs/examples/kotlin/messaging/create-subscriber.md +++ b/docs/examples/kotlin/messaging/create-subscriber.md @@ -9,7 +9,7 @@ val client = Client(context) val messaging = Messaging(client) val response = messaging.createSubscriber( - topicId = "[TOPIC_ID]", - subscriberId = "[SUBSCRIBER_ID]", - targetId = "[TARGET_ID]", + topicId = "", + subscriberId = "", + targetId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/messaging/delete-subscriber.md b/docs/examples/kotlin/messaging/delete-subscriber.md index 7ac8930..02487c7 100644 --- a/docs/examples/kotlin/messaging/delete-subscriber.md +++ b/docs/examples/kotlin/messaging/delete-subscriber.md @@ -9,6 +9,6 @@ val client = Client(context) val messaging = Messaging(client) val response = messaging.deleteSubscriber( - topicId = "[TOPIC_ID]", - subscriberId = "[SUBSCRIBER_ID]", + topicId = "", + subscriberId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/create-file.md b/docs/examples/kotlin/storage/create-file.md index 7381696..b5e4663 100644 --- a/docs/examples/kotlin/storage/create-file.md +++ b/docs/examples/kotlin/storage/create-file.md @@ -10,8 +10,8 @@ val client = Client(context) val storage = Storage(client) val response = storage.createFile( - bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]", + bucketId = "", + fileId = "", file = InputFile.fromPath("file.png"), permissions = listOf("read("any")"), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/delete-file.md b/docs/examples/kotlin/storage/delete-file.md index 0b14a1b..49a2505 100644 --- a/docs/examples/kotlin/storage/delete-file.md +++ b/docs/examples/kotlin/storage/delete-file.md @@ -9,6 +9,6 @@ val client = Client(context) val storage = Storage(client) val response = storage.deleteFile( - bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]", + bucketId = "", + fileId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file-download.md b/docs/examples/kotlin/storage/get-file-download.md index 83071ea..c6fe106 100644 --- a/docs/examples/kotlin/storage/get-file-download.md +++ b/docs/examples/kotlin/storage/get-file-download.md @@ -9,6 +9,6 @@ val client = Client(context) val storage = Storage(client) val result =storage.getFileDownload( - bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]", + bucketId = "", + fileId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file-preview.md b/docs/examples/kotlin/storage/get-file-preview.md index 4d23b0e..545391f 100644 --- a/docs/examples/kotlin/storage/get-file-preview.md +++ b/docs/examples/kotlin/storage/get-file-preview.md @@ -9,8 +9,8 @@ val client = Client(context) val storage = Storage(client) val result =storage.getFilePreview( - bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]", + bucketId = "", + fileId = "", width = 0, // (optional) height = 0, // (optional) gravity = ImageGravity.CENTER, // (optional) diff --git a/docs/examples/kotlin/storage/get-file-view.md b/docs/examples/kotlin/storage/get-file-view.md index 552427e..307739d 100644 --- a/docs/examples/kotlin/storage/get-file-view.md +++ b/docs/examples/kotlin/storage/get-file-view.md @@ -9,6 +9,6 @@ val client = Client(context) val storage = Storage(client) val result =storage.getFileView( - bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]", + bucketId = "", + fileId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file.md b/docs/examples/kotlin/storage/get-file.md index 2f07fee..e82eb56 100644 --- a/docs/examples/kotlin/storage/get-file.md +++ b/docs/examples/kotlin/storage/get-file.md @@ -9,6 +9,6 @@ val client = Client(context) val storage = Storage(client) val response = storage.getFile( - bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]", + bucketId = "", + fileId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/list-files.md b/docs/examples/kotlin/storage/list-files.md index c07afc2..54dbaa0 100644 --- a/docs/examples/kotlin/storage/list-files.md +++ b/docs/examples/kotlin/storage/list-files.md @@ -9,7 +9,7 @@ val client = Client(context) val storage = Storage(client) val response = storage.listFiles( - bucketId = "[BUCKET_ID]", + bucketId = "", queries = listOf(), // (optional) - search = "[SEARCH]", // (optional) + search = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/update-file.md b/docs/examples/kotlin/storage/update-file.md index 8331e94..351ea52 100644 --- a/docs/examples/kotlin/storage/update-file.md +++ b/docs/examples/kotlin/storage/update-file.md @@ -9,8 +9,8 @@ val client = Client(context) val storage = Storage(client) val response = storage.updateFile( - bucketId = "[BUCKET_ID]", - fileId = "[FILE_ID]", - name = "[NAME]", // (optional) + bucketId = "", + fileId = "", + name = "", // (optional) permissions = listOf("read("any")"), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/create-membership.md b/docs/examples/kotlin/teams/create-membership.md index 77fea6e..1a49b3e 100644 --- a/docs/examples/kotlin/teams/create-membership.md +++ b/docs/examples/kotlin/teams/create-membership.md @@ -9,11 +9,11 @@ val client = Client(context) val teams = Teams(client) val response = teams.createMembership( - teamId = "[TEAM_ID]", + teamId = "", roles = listOf(), email = "email@example.com", // (optional) - userId = "[USER_ID]", // (optional) + userId = "", // (optional) phone = "+12065550100", // (optional) url = "https://example.com", // (optional) - name = "[NAME]", // (optional) + name = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/create.md b/docs/examples/kotlin/teams/create.md index 4b841f9..1dce8a5 100644 --- a/docs/examples/kotlin/teams/create.md +++ b/docs/examples/kotlin/teams/create.md @@ -9,7 +9,7 @@ val client = Client(context) val teams = Teams(client) val response = teams.create( - teamId = "[TEAM_ID]", - name = "[NAME]", + teamId = "", + name = "", roles = listOf(), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/delete-membership.md b/docs/examples/kotlin/teams/delete-membership.md index 9ad5e21..1548551 100644 --- a/docs/examples/kotlin/teams/delete-membership.md +++ b/docs/examples/kotlin/teams/delete-membership.md @@ -9,6 +9,6 @@ val client = Client(context) val teams = Teams(client) val response = teams.deleteMembership( - teamId = "[TEAM_ID]", - membershipId = "[MEMBERSHIP_ID]", + teamId = "", + membershipId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/delete.md b/docs/examples/kotlin/teams/delete.md index bab1a31..3709d7b 100644 --- a/docs/examples/kotlin/teams/delete.md +++ b/docs/examples/kotlin/teams/delete.md @@ -9,5 +9,5 @@ val client = Client(context) val teams = Teams(client) val response = teams.delete( - teamId = "[TEAM_ID]", + teamId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/get-membership.md b/docs/examples/kotlin/teams/get-membership.md index 8fbc3f7..b77e813 100644 --- a/docs/examples/kotlin/teams/get-membership.md +++ b/docs/examples/kotlin/teams/get-membership.md @@ -9,6 +9,6 @@ val client = Client(context) val teams = Teams(client) val response = teams.getMembership( - teamId = "[TEAM_ID]", - membershipId = "[MEMBERSHIP_ID]", + teamId = "", + membershipId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/get-prefs.md b/docs/examples/kotlin/teams/get-prefs.md index 7738575..11ecc61 100644 --- a/docs/examples/kotlin/teams/get-prefs.md +++ b/docs/examples/kotlin/teams/get-prefs.md @@ -9,5 +9,5 @@ val client = Client(context) val teams = Teams(client) val response = teams.getPrefs( - teamId = "[TEAM_ID]", + teamId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/get.md b/docs/examples/kotlin/teams/get.md index 16a1b43..ff885e8 100644 --- a/docs/examples/kotlin/teams/get.md +++ b/docs/examples/kotlin/teams/get.md @@ -9,5 +9,5 @@ val client = Client(context) val teams = Teams(client) val response = teams.get( - teamId = "[TEAM_ID]", + teamId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/list-memberships.md b/docs/examples/kotlin/teams/list-memberships.md index 44c9638..f143426 100644 --- a/docs/examples/kotlin/teams/list-memberships.md +++ b/docs/examples/kotlin/teams/list-memberships.md @@ -9,7 +9,7 @@ val client = Client(context) val teams = Teams(client) val response = teams.listMemberships( - teamId = "[TEAM_ID]", + teamId = "", queries = listOf(), // (optional) - search = "[SEARCH]", // (optional) + search = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/list.md b/docs/examples/kotlin/teams/list.md index 38ac1d9..91475e2 100644 --- a/docs/examples/kotlin/teams/list.md +++ b/docs/examples/kotlin/teams/list.md @@ -10,5 +10,5 @@ val teams = Teams(client) val response = teams.list( queries = listOf(), // (optional) - search = "[SEARCH]", // (optional) + search = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-membership-status.md b/docs/examples/kotlin/teams/update-membership-status.md index 53fbe20..22b1c81 100644 --- a/docs/examples/kotlin/teams/update-membership-status.md +++ b/docs/examples/kotlin/teams/update-membership-status.md @@ -9,8 +9,8 @@ val client = Client(context) val teams = Teams(client) val response = teams.updateMembershipStatus( - teamId = "[TEAM_ID]", - membershipId = "[MEMBERSHIP_ID]", - userId = "[USER_ID]", - secret = "[SECRET]", + teamId = "", + membershipId = "", + userId = "", + secret = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-membership.md b/docs/examples/kotlin/teams/update-membership.md index 4e47025..035bdff 100644 --- a/docs/examples/kotlin/teams/update-membership.md +++ b/docs/examples/kotlin/teams/update-membership.md @@ -9,7 +9,7 @@ val client = Client(context) val teams = Teams(client) val response = teams.updateMembership( - teamId = "[TEAM_ID]", - membershipId = "[MEMBERSHIP_ID]", + teamId = "", + membershipId = "", roles = listOf(), ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-name.md b/docs/examples/kotlin/teams/update-name.md index f92b302..77ccd47 100644 --- a/docs/examples/kotlin/teams/update-name.md +++ b/docs/examples/kotlin/teams/update-name.md @@ -9,6 +9,6 @@ val client = Client(context) val teams = Teams(client) val response = teams.updateName( - teamId = "[TEAM_ID]", - name = "[NAME]", + teamId = "", + name = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-prefs.md b/docs/examples/kotlin/teams/update-prefs.md index dc12687..702bc9c 100644 --- a/docs/examples/kotlin/teams/update-prefs.md +++ b/docs/examples/kotlin/teams/update-prefs.md @@ -9,6 +9,6 @@ val client = Client(context) val teams = Teams(client) val response = teams.updatePrefs( - teamId = "[TEAM_ID]", + teamId = "", prefs = mapOf( "a" to "b" ), ) \ 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 2877f9f..a191ff0 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -83,7 +83,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "5.0.0-rc.4", + "x-sdk-version" to "5.0.0-rc.5", "x-appwrite-response-format" to "1.5.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/OS.kt b/library/src/main/java/io/appwrite/OS.kt deleted file mode 100644 index 7828f02..0000000 --- a/library/src/main/java/io/appwrite/OS.kt +++ /dev/null @@ -1,52 +0,0 @@ -package io.appwrite - -import android.Manifest -import android.content.pm.PackageManager -import android.os.Build -import androidx.activity.result.contract.ActivityResultContracts -import androidx.appcompat.app.AppCompatActivity -import androidx.core.content.ContextCompat - -object OS { - fun requestPermission( - activity: AppCompatActivity, - permission: String, - onGranted: () -> Unit = {}, - onDenied: () -> Unit = {}, - onShowRationale: () -> Unit = {}, - ) { - if ( - Build.VERSION.SDK_INT < Build.VERSION_CODES.M || - (permission == Manifest.permission.POST_NOTIFICATIONS && Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) - ) { - onGranted() - return - } - - if (ContextCompat.checkSelfPermission( - activity, - permission - ) == PackageManager.PERMISSION_GRANTED - ) { - onGranted() - } else if (activity.shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS)) { - onShowRationale() - } else { - requestPermissionLauncher(activity, onGranted, onDenied).launch(permission) - } - } - - private fun requestPermissionLauncher( - activity: AppCompatActivity, - onGranted: () -> Unit, - onDenied: () -> Unit, - ) = activity.registerForActivityResult( - ActivityResultContracts.RequestPermission(), - ) { isGranted: Boolean -> - if (isGranted) { - onGranted() - } else { - onDenied() - } - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/AuthenticationFactor.kt b/library/src/main/java/io/appwrite/enums/AuthenticationFactor.kt index 3303e0b..7aca6e5 100644 --- a/library/src/main/java/io/appwrite/enums/AuthenticationFactor.kt +++ b/library/src/main/java/io/appwrite/enums/AuthenticationFactor.kt @@ -1,8 +1,13 @@ package io.appwrite.enums +import com.google.gson.annotations.SerializedName + enum class AuthenticationFactor(val value: String) { + @SerializedName("totp") TOTP("totp"), + @SerializedName("phone") PHONE("phone"), + @SerializedName("email") EMAIL("email"); override fun toString() = value diff --git a/library/src/main/java/io/appwrite/enums/AuthenticatorType.kt b/library/src/main/java/io/appwrite/enums/AuthenticatorType.kt index 27e1635..a7d37ae 100644 --- a/library/src/main/java/io/appwrite/enums/AuthenticatorType.kt +++ b/library/src/main/java/io/appwrite/enums/AuthenticatorType.kt @@ -1,6 +1,9 @@ package io.appwrite.enums +import com.google.gson.annotations.SerializedName + enum class AuthenticatorType(val value: String) { + @SerializedName("totp") TOTP("totp"); override fun toString() = value diff --git a/library/src/main/java/io/appwrite/enums/Browser.kt b/library/src/main/java/io/appwrite/enums/Browser.kt index 99f598e..f71024a 100644 --- a/library/src/main/java/io/appwrite/enums/Browser.kt +++ b/library/src/main/java/io/appwrite/enums/Browser.kt @@ -1,19 +1,35 @@ package io.appwrite.enums +import com.google.gson.annotations.SerializedName + enum class Browser(val value: String) { + @SerializedName("aa") AVANT_BROWSER("aa"), + @SerializedName("an") ANDROID_WEB_VIEW_BETA("an"), + @SerializedName("ch") GOOGLE_CHROME("ch"), + @SerializedName("ci") GOOGLE_CHROMEI_OS("ci"), + @SerializedName("cm") GOOGLE_CHROME_MOBILE("cm"), + @SerializedName("cr") CHROMIUM("cr"), + @SerializedName("ff") MOZILLA_FIREFOX("ff"), + @SerializedName("sf") SAFARI("sf"), + @SerializedName("mf") MOBILE_SAFARI("mf"), + @SerializedName("ps") MICROSOFT_EDGE("ps"), + @SerializedName("oi") MICROSOFT_EDGEI_OS("oi"), + @SerializedName("om") OPERA_MINI("om"), + @SerializedName("op") OPERA("op"), + @SerializedName("on") OPERA_NEXT("on"); override fun toString() = value diff --git a/library/src/main/java/io/appwrite/enums/CreditCard.kt b/library/src/main/java/io/appwrite/enums/CreditCard.kt index e99519b..7224778 100644 --- a/library/src/main/java/io/appwrite/enums/CreditCard.kt +++ b/library/src/main/java/io/appwrite/enums/CreditCard.kt @@ -1,21 +1,39 @@ package io.appwrite.enums +import com.google.gson.annotations.SerializedName + enum class CreditCard(val value: String) { + @SerializedName("amex") AMERICAN_EXPRESS("amex"), + @SerializedName("argencard") ARGENCARD("argencard"), + @SerializedName("cabal") CABAL("cabal"), + @SerializedName("censosud") CONSOSUD("censosud"), + @SerializedName("diners") DINERS_CLUB("diners"), + @SerializedName("discover") DISCOVER("discover"), + @SerializedName("elo") ELO("elo"), + @SerializedName("hipercard") HIPERCARD("hipercard"), + @SerializedName("jcb") JCB("jcb"), + @SerializedName("mastercard") MASTERCARD("mastercard"), + @SerializedName("naranja") NARANJA("naranja"), + @SerializedName("targeta-shopping") TARJETA_SHOPPING("targeta-shopping"), + @SerializedName("union-china-pay") UNION_CHINA_PAY("union-china-pay"), + @SerializedName("visa") VISA("visa"), + @SerializedName("mir") MIR("mir"), + @SerializedName("maestro") MAESTRO("maestro"); override fun toString() = value diff --git a/library/src/main/java/io/appwrite/enums/ExecutionMethod.kt b/library/src/main/java/io/appwrite/enums/ExecutionMethod.kt index edeb66b..946fdb3 100644 --- a/library/src/main/java/io/appwrite/enums/ExecutionMethod.kt +++ b/library/src/main/java/io/appwrite/enums/ExecutionMethod.kt @@ -1,11 +1,19 @@ package io.appwrite.enums +import com.google.gson.annotations.SerializedName + enum class ExecutionMethod(val value: String) { + @SerializedName("GET") GET("GET"), + @SerializedName("POST") POST("POST"), + @SerializedName("PUT") PUT("PUT"), + @SerializedName("PATCH") PATCH("PATCH"), + @SerializedName("DELETE") DELETE("DELETE"), + @SerializedName("OPTIONS") OPTIONS("OPTIONS"); override fun toString() = value diff --git a/library/src/main/java/io/appwrite/enums/Flag.kt b/library/src/main/java/io/appwrite/enums/Flag.kt index 4fcdd88..af5889a 100644 --- a/library/src/main/java/io/appwrite/enums/Flag.kt +++ b/library/src/main/java/io/appwrite/enums/Flag.kt @@ -1,199 +1,395 @@ package io.appwrite.enums +import com.google.gson.annotations.SerializedName + enum class Flag(val value: String) { + @SerializedName("af") AFGHANISTAN("af"), + @SerializedName("ao") ANGOLA("ao"), + @SerializedName("al") ALBANIA("al"), + @SerializedName("ad") ANDORRA("ad"), + @SerializedName("ae") UNITED_ARAB_EMIRATES("ae"), + @SerializedName("ar") ARGENTINA("ar"), + @SerializedName("am") ARMENIA("am"), + @SerializedName("ag") ANTIGUAAND_BARBUDA("ag"), + @SerializedName("au") AUSTRALIA("au"), + @SerializedName("at") AUSTRIA("at"), + @SerializedName("az") AZERBAIJAN("az"), + @SerializedName("bi") BURUNDI("bi"), + @SerializedName("be") BELGIUM("be"), + @SerializedName("bj") BENIN("bj"), + @SerializedName("bf") BURKINA_FASO("bf"), + @SerializedName("bd") BANGLADESH("bd"), + @SerializedName("bg") BULGARIA("bg"), + @SerializedName("bh") BAHRAIN("bh"), + @SerializedName("bs") BAHAMAS("bs"), + @SerializedName("ba") BOSNIAAND_HERZEGOVINA("ba"), + @SerializedName("by") BELARUS("by"), + @SerializedName("bz") BELIZE("bz"), + @SerializedName("bo") BOLIVIA("bo"), + @SerializedName("br") BRAZIL("br"), + @SerializedName("bb") BARBADOS("bb"), + @SerializedName("bn") BRUNEI_DARUSSALAM("bn"), + @SerializedName("bt") BHUTAN("bt"), + @SerializedName("bw") BOTSWANA("bw"), + @SerializedName("cf") CENTRAL_AFRICAN_REPUBLIC("cf"), + @SerializedName("ca") CANADA("ca"), + @SerializedName("ch") SWITZERLAND("ch"), + @SerializedName("cl") CHILE("cl"), + @SerializedName("cn") CHINA("cn"), + @SerializedName("ci") CTED_IVOIRE("ci"), + @SerializedName("cm") CAMEROON("cm"), + @SerializedName("cd") DEMOCRATIC_REPUBLICOFTHE_CONGO("cd"), + @SerializedName("cg") REPUBLICOFTHE_CONGO("cg"), + @SerializedName("co") COLOMBIA("co"), + @SerializedName("km") COMOROS("km"), + @SerializedName("cv") CAPE_VERDE("cv"), + @SerializedName("cr") COSTA_RICA("cr"), + @SerializedName("cu") CUBA("cu"), + @SerializedName("cy") CYPRUS("cy"), + @SerializedName("cz") CZECH_REPUBLIC("cz"), + @SerializedName("de") GERMANY("de"), + @SerializedName("dj") DJIBOUTI("dj"), + @SerializedName("dm") DOMINICA("dm"), + @SerializedName("dk") DENMARK("dk"), + @SerializedName("do") DOMINICAN_REPUBLIC("do"), + @SerializedName("dz") ALGERIA("dz"), + @SerializedName("ec") ECUADOR("ec"), + @SerializedName("eg") EGYPT("eg"), + @SerializedName("er") ERITREA("er"), + @SerializedName("es") SPAIN("es"), + @SerializedName("ee") ESTONIA("ee"), + @SerializedName("et") ETHIOPIA("et"), + @SerializedName("fi") FINLAND("fi"), + @SerializedName("fj") FIJI("fj"), + @SerializedName("fr") FRANCE("fr"), + @SerializedName("fm") MICRONESIA_FEDERATED_STATESOF("fm"), + @SerializedName("ga") GABON("ga"), + @SerializedName("gb") UNITED_KINGDOM("gb"), + @SerializedName("ge") GEORGIA("ge"), + @SerializedName("gh") GHANA("gh"), + @SerializedName("gn") GUINEA("gn"), + @SerializedName("gm") GAMBIA("gm"), + @SerializedName("gw") GUINEA_BISSAU("gw"), + @SerializedName("gq") EQUATORIAL_GUINEA("gq"), + @SerializedName("gr") GREECE("gr"), + @SerializedName("gd") GRENADA("gd"), + @SerializedName("gt") GUATEMALA("gt"), + @SerializedName("gy") GUYANA("gy"), + @SerializedName("hn") HONDURAS("hn"), + @SerializedName("hr") CROATIA("hr"), + @SerializedName("ht") HAITI("ht"), + @SerializedName("hu") HUNGARY("hu"), + @SerializedName("id") INDONESIA("id"), + @SerializedName("in") INDIA("in"), + @SerializedName("ie") IRELAND("ie"), + @SerializedName("ir") IRAN_ISLAMIC_REPUBLICOF("ir"), + @SerializedName("iq") IRAQ("iq"), + @SerializedName("is") ICELAND("is"), + @SerializedName("il") ISRAEL("il"), + @SerializedName("it") ITALY("it"), + @SerializedName("jm") JAMAICA("jm"), + @SerializedName("jo") JORDAN("jo"), + @SerializedName("jp") JAPAN("jp"), + @SerializedName("kz") KAZAKHSTAN("kz"), + @SerializedName("ke") KENYA("ke"), + @SerializedName("kg") KYRGYZSTAN("kg"), + @SerializedName("kh") CAMBODIA("kh"), + @SerializedName("ki") KIRIBATI("ki"), + @SerializedName("kn") SAINT_KITTSAND_NEVIS("kn"), + @SerializedName("kr") SOUTH_KOREA("kr"), + @SerializedName("kw") KUWAIT("kw"), + @SerializedName("la") LAO_PEOPLES_DEMOCRATIC_REPUBLIC("la"), + @SerializedName("lb") LEBANON("lb"), + @SerializedName("lr") LIBERIA("lr"), + @SerializedName("ly") LIBYA("ly"), + @SerializedName("lc") SAINT_LUCIA("lc"), + @SerializedName("li") LIECHTENSTEIN("li"), + @SerializedName("lk") SRI_LANKA("lk"), + @SerializedName("ls") LESOTHO("ls"), + @SerializedName("lt") LITHUANIA("lt"), + @SerializedName("lu") LUXEMBOURG("lu"), + @SerializedName("lv") LATVIA("lv"), + @SerializedName("ma") MOROCCO("ma"), + @SerializedName("mc") MONACO("mc"), + @SerializedName("md") MOLDOVA("md"), + @SerializedName("mg") MADAGASCAR("mg"), + @SerializedName("mv") MALDIVES("mv"), + @SerializedName("mx") MEXICO("mx"), + @SerializedName("mh") MARSHALL_ISLANDS("mh"), + @SerializedName("mk") NORTH_MACEDONIA("mk"), + @SerializedName("ml") MALI("ml"), + @SerializedName("mt") MALTA("mt"), + @SerializedName("mm") MYANMAR("mm"), + @SerializedName("me") MONTENEGRO("me"), + @SerializedName("mn") MONGOLIA("mn"), + @SerializedName("mz") MOZAMBIQUE("mz"), + @SerializedName("mr") MAURITANIA("mr"), + @SerializedName("mu") MAURITIUS("mu"), + @SerializedName("mw") MALAWI("mw"), + @SerializedName("my") MALAYSIA("my"), + @SerializedName("na") NAMIBIA("na"), + @SerializedName("ne") NIGER("ne"), + @SerializedName("ng") NIGERIA("ng"), + @SerializedName("ni") NICARAGUA("ni"), + @SerializedName("nl") NETHERLANDS("nl"), + @SerializedName("no") NORWAY("no"), + @SerializedName("np") NEPAL("np"), + @SerializedName("nr") NAURU("nr"), + @SerializedName("nz") NEW_ZEALAND("nz"), + @SerializedName("om") OMAN("om"), + @SerializedName("pk") PAKISTAN("pk"), + @SerializedName("pa") PANAMA("pa"), + @SerializedName("pe") PERU("pe"), + @SerializedName("ph") PHILIPPINES("ph"), + @SerializedName("pw") PALAU("pw"), + @SerializedName("pg") PAPUA_NEW_GUINEA("pg"), + @SerializedName("pl") POLAND("pl"), + @SerializedName("kp") NORTH_KOREA("kp"), + @SerializedName("pt") PORTUGAL("pt"), + @SerializedName("py") PARAGUAY("py"), + @SerializedName("qa") QATAR("qa"), + @SerializedName("ro") ROMANIA("ro"), + @SerializedName("ru") RUSSIA("ru"), + @SerializedName("rw") RWANDA("rw"), + @SerializedName("sa") SAUDI_ARABIA("sa"), + @SerializedName("sd") SUDAN("sd"), + @SerializedName("sn") SENEGAL("sn"), + @SerializedName("sg") SINGAPORE("sg"), + @SerializedName("sb") SOLOMON_ISLANDS("sb"), + @SerializedName("sl") SIERRA_LEONE("sl"), + @SerializedName("sv") EL_SALVADOR("sv"), + @SerializedName("sm") SAN_MARINO("sm"), + @SerializedName("so") SOMALIA("so"), + @SerializedName("rs") SERBIA("rs"), + @SerializedName("ss") SOUTH_SUDAN("ss"), + @SerializedName("st") SAO_TOMEAND_PRINCIPE("st"), + @SerializedName("sr") SURINAME("sr"), + @SerializedName("sk") SLOVAKIA("sk"), + @SerializedName("si") SLOVENIA("si"), + @SerializedName("se") SWEDEN("se"), + @SerializedName("sz") ESWATINI("sz"), + @SerializedName("sc") SEYCHELLES("sc"), + @SerializedName("sy") SYRIA("sy"), + @SerializedName("td") CHAD("td"), + @SerializedName("tg") TOGO("tg"), + @SerializedName("th") THAILAND("th"), + @SerializedName("tj") TAJIKISTAN("tj"), + @SerializedName("tm") TURKMENISTAN("tm"), + @SerializedName("tl") TIMOR_LESTE("tl"), + @SerializedName("to") TONGA("to"), + @SerializedName("tt") TRINIDADAND_TOBAGO("tt"), + @SerializedName("tn") TUNISIA("tn"), + @SerializedName("tr") TURKEY("tr"), + @SerializedName("tv") TUVALU("tv"), + @SerializedName("tz") TANZANIA("tz"), + @SerializedName("ug") UGANDA("ug"), + @SerializedName("ua") UKRAINE("ua"), + @SerializedName("uy") URUGUAY("uy"), + @SerializedName("us") UNITED_STATES("us"), + @SerializedName("uz") UZBEKISTAN("uz"), + @SerializedName("va") VATICAN_CITY("va"), + @SerializedName("vc") SAINT_VINCENTANDTHE_GRENADINES("vc"), + @SerializedName("ve") VENEZUELA("ve"), + @SerializedName("vn") VIETNAM("vn"), + @SerializedName("vu") VANUATU("vu"), + @SerializedName("ws") SAMOA("ws"), + @SerializedName("ye") YEMEN("ye"), + @SerializedName("za") SOUTH_AFRICA("za"), + @SerializedName("zm") ZAMBIA("zm"), + @SerializedName("zw") ZIMBABWE("zw"); override fun toString() = value diff --git a/library/src/main/java/io/appwrite/enums/ImageFormat.kt b/library/src/main/java/io/appwrite/enums/ImageFormat.kt index 6a4c422..c6a3b0f 100644 --- a/library/src/main/java/io/appwrite/enums/ImageFormat.kt +++ b/library/src/main/java/io/appwrite/enums/ImageFormat.kt @@ -1,10 +1,17 @@ package io.appwrite.enums +import com.google.gson.annotations.SerializedName + enum class ImageFormat(val value: String) { + @SerializedName("jpg") JPG("jpg"), + @SerializedName("jpeg") JPEG("jpeg"), + @SerializedName("gif") GIF("gif"), + @SerializedName("png") PNG("png"), + @SerializedName("webp") WEBP("webp"); override fun toString() = value diff --git a/library/src/main/java/io/appwrite/enums/ImageGravity.kt b/library/src/main/java/io/appwrite/enums/ImageGravity.kt index a8fa441..0e8325d 100644 --- a/library/src/main/java/io/appwrite/enums/ImageGravity.kt +++ b/library/src/main/java/io/appwrite/enums/ImageGravity.kt @@ -1,14 +1,25 @@ package io.appwrite.enums +import com.google.gson.annotations.SerializedName + enum class ImageGravity(val value: String) { + @SerializedName("center") CENTER("center"), + @SerializedName("top-left") TOPLEFT("top-left"), + @SerializedName("top") TOP("top"), + @SerializedName("top-right") TOPRIGHT("top-right"), + @SerializedName("left") LEFT("left"), + @SerializedName("right") RIGHT("right"), + @SerializedName("bottom-left") BOTTOMLEFT("bottom-left"), + @SerializedName("bottom") BOTTOM("bottom"), + @SerializedName("bottom-right") BOTTOMRIGHT("bottom-right"); override fun toString() = value diff --git a/library/src/main/java/io/appwrite/enums/OAuthProvider.kt b/library/src/main/java/io/appwrite/enums/OAuthProvider.kt index 4a38a2e..2b96d63 100644 --- a/library/src/main/java/io/appwrite/enums/OAuthProvider.kt +++ b/library/src/main/java/io/appwrite/enums/OAuthProvider.kt @@ -1,44 +1,85 @@ package io.appwrite.enums +import com.google.gson.annotations.SerializedName + enum class OAuthProvider(val value: String) { + @SerializedName("amazon") AMAZON("amazon"), + @SerializedName("apple") APPLE("apple"), + @SerializedName("auth0") AUTH0("auth0"), + @SerializedName("authentik") AUTHENTIK("authentik"), + @SerializedName("autodesk") AUTODESK("autodesk"), + @SerializedName("bitbucket") BITBUCKET("bitbucket"), + @SerializedName("bitly") BITLY("bitly"), + @SerializedName("box") BOX("box"), + @SerializedName("dailymotion") DAILYMOTION("dailymotion"), + @SerializedName("discord") DISCORD("discord"), + @SerializedName("disqus") DISQUS("disqus"), + @SerializedName("dropbox") DROPBOX("dropbox"), + @SerializedName("etsy") ETSY("etsy"), + @SerializedName("facebook") FACEBOOK("facebook"), + @SerializedName("github") GITHUB("github"), + @SerializedName("gitlab") GITLAB("gitlab"), + @SerializedName("google") GOOGLE("google"), + @SerializedName("linkedin") LINKEDIN("linkedin"), + @SerializedName("microsoft") MICROSOFT("microsoft"), + @SerializedName("notion") NOTION("notion"), + @SerializedName("oidc") OIDC("oidc"), + @SerializedName("okta") OKTA("okta"), + @SerializedName("paypal") PAYPAL("paypal"), + @SerializedName("paypalSandbox") PAYPAL_SANDBOX("paypalSandbox"), + @SerializedName("podio") PODIO("podio"), + @SerializedName("salesforce") SALESFORCE("salesforce"), + @SerializedName("slack") SLACK("slack"), + @SerializedName("spotify") SPOTIFY("spotify"), + @SerializedName("stripe") STRIPE("stripe"), + @SerializedName("tradeshift") TRADESHIFT("tradeshift"), + @SerializedName("tradeshiftBox") TRADESHIFT_BOX("tradeshiftBox"), + @SerializedName("twitch") TWITCH("twitch"), + @SerializedName("wordpress") WORDPRESS("wordpress"), + @SerializedName("yahoo") YAHOO("yahoo"), + @SerializedName("yammer") YAMMER("yammer"), + @SerializedName("yandex") YANDEX("yandex"), + @SerializedName("zoho") ZOHO("zoho"), + @SerializedName("zoom") ZOOM("zoom"), + @SerializedName("mock") MOCK("mock"); override fun toString() = value diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index ccc2c29..ac37eb1 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -377,7 +377,7 @@ class Account(client: Client) : Service(client) { * @param factor Factor used for verification. * @return [io.appwrite.models.MfaChallenge] */ - suspend fun create2FAChallenge( + suspend fun createChallenge( factor: AuthenticationFactor, ): io.appwrite.models.MfaChallenge { val apiPath = "/account/mfa/challenge" @@ -1117,7 +1117,6 @@ class Account(client: Client) : Service(client) { * @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, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom. * @param success URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's 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's 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 token Include token credentials in the final redirect, useful for server-side integrations, or when cookies are not available. * @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 @@ -1126,7 +1125,6 @@ class Account(client: Client) : Service(client) { provider: OAuthProvider, success: String? = null, failure: String? = null, - token: Boolean? = null, scopes: List? = null, ) { val apiPath = "/account/sessions/oauth2/{provider}" @@ -1135,7 +1133,6 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( "success" to success, "failure" to failure, - "token" to token, "scopes" to scopes, "project" to client.config["project"], ) @@ -1554,6 +1551,78 @@ class Account(client: Client) : Service(client) { } + /** + * Create OAuth2 token + * + * Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * + * @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, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom. + * @param success URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's 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's 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 + suspend fun createOAuth2Token( + activity: ComponentActivity, + provider: OAuthProvider, + success: String? = null, + failure: String? = null, + scopes: List? = null, + ) { + val apiPath = "/account/tokens/oauth2/{provider}" + .replace("{provider}", provider.value) + + val apiParams = mutableMapOf( + "success" to success, + "failure" to failure, + "scopes" to scopes, + "project" to client.config["project"], + ) + val apiQuery = mutableListOf() + apiParams.forEach { + when (it.value) { + null -> { + return@forEach + } + is List<*> -> { + apiQuery.add("${it.key}[]=${it.value.toString()}") + } + else -> { + apiQuery.add("${it.key}=${it.value.toString()}") + } + } + } + + val apiUrl = Uri.parse("${client.endpoint}${apiPath}?${apiQuery.joinToString("&")}") + val callbackUrlScheme = "appwrite-callback-${client.config["project"]}" + + WebAuthComponent.authenticate(activity, apiUrl, callbackUrlScheme) { + if (it.isFailure) { + throw it.exceptionOrNull()!! + } + + val resultUrl = it.getOrNull()!! + val uri = Uri.parse(resultUrl) + val key = uri.getQueryParameter("key") + val secret = uri.getQueryParameter("secret") + if (key == null || secret == null) { + throw AppwriteException("Authentication cookie missing!") + } + val cookie = Cookie.Builder() + .name(key) + .value(secret) + .domain(Uri.parse(client.endpoint).host!!) + .httpOnly() + .build() + + client.http.cookieJar.saveFromResponse( + client.endpoint.toHttpUrl(), + listOf(cookie) + ) + } + } + + /** * Create phone token * From 1001681968c323b46b0d517053970baae9e3e641 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 27 Feb 2024 20:33:43 +1300 Subject: [PATCH 067/118] Release candidate for 1.5.x --- README.md | 4 +- .../java/account/update-phone-session.md | 23 +++++++ .../kotlin/account/add-authenticator.md | 2 +- .../account/create-anonymous-session.md | 2 +- .../kotlin/account/create-challenge.md | 2 +- .../account/create-email-password-session.md | 2 +- .../kotlin/account/create-email-token.md | 2 +- docs/examples/kotlin/account/create-j-w-t.md | 2 +- .../account/create-magic-u-r-l-token.md | 2 +- .../kotlin/account/create-phone-token.md | 2 +- .../account/create-phone-verification.md | 2 +- .../kotlin/account/create-push-target.md | 2 +- .../kotlin/account/create-recovery.md | 2 +- .../examples/kotlin/account/create-session.md | 2 +- .../kotlin/account/create-verification.md | 2 +- docs/examples/kotlin/account/create.md | 2 +- .../kotlin/account/delete-authenticator.md | 2 +- .../kotlin/account/delete-identity.md | 2 +- .../kotlin/account/delete-push-target.md | 2 +- .../examples/kotlin/account/delete-session.md | 2 +- .../kotlin/account/delete-sessions.md | 2 +- docs/examples/kotlin/account/get-prefs.md | 2 +- docs/examples/kotlin/account/get-session.md | 2 +- docs/examples/kotlin/account/get.md | 2 +- docs/examples/kotlin/account/list-factors.md | 2 +- .../kotlin/account/list-identities.md | 2 +- docs/examples/kotlin/account/list-logs.md | 2 +- docs/examples/kotlin/account/list-sessions.md | 2 +- .../kotlin/account/update-challenge.md | 2 +- docs/examples/kotlin/account/update-email.md | 2 +- docs/examples/kotlin/account/update-m-f-a.md | 2 +- .../account/update-magic-u-r-l-session.md | 2 +- docs/examples/kotlin/account/update-name.md | 2 +- .../kotlin/account/update-password.md | 2 +- .../kotlin/account/update-phone-session.md | 14 ++++ .../account/update-phone-verification.md | 2 +- docs/examples/kotlin/account/update-phone.md | 2 +- docs/examples/kotlin/account/update-prefs.md | 2 +- .../kotlin/account/update-push-target.md | 2 +- .../kotlin/account/update-recovery.md | 2 +- .../examples/kotlin/account/update-session.md | 2 +- docs/examples/kotlin/account/update-status.md | 2 +- .../kotlin/account/update-verification.md | 2 +- .../kotlin/account/verify-authenticator.md | 2 +- docs/examples/kotlin/avatars/get-browser.md | 2 +- .../kotlin/avatars/get-credit-card.md | 2 +- docs/examples/kotlin/avatars/get-favicon.md | 2 +- docs/examples/kotlin/avatars/get-flag.md | 2 +- docs/examples/kotlin/avatars/get-image.md | 2 +- docs/examples/kotlin/avatars/get-initials.md | 2 +- docs/examples/kotlin/avatars/get-q-r.md | 2 +- .../kotlin/databases/create-document.md | 2 +- .../kotlin/databases/delete-document.md | 2 +- .../examples/kotlin/databases/get-document.md | 2 +- .../kotlin/databases/list-documents.md | 2 +- .../kotlin/databases/update-document.md | 2 +- .../kotlin/functions/create-execution.md | 2 +- .../kotlin/functions/get-execution.md | 2 +- .../kotlin/functions/list-executions.md | 2 +- docs/examples/kotlin/graphql/mutation.md | 2 +- docs/examples/kotlin/graphql/query.md | 2 +- docs/examples/kotlin/locale/get.md | 2 +- docs/examples/kotlin/locale/list-codes.md | 2 +- .../examples/kotlin/locale/list-continents.md | 2 +- .../kotlin/locale/list-countries-e-u.md | 2 +- .../kotlin/locale/list-countries-phones.md | 2 +- docs/examples/kotlin/locale/list-countries.md | 2 +- .../examples/kotlin/locale/list-currencies.md | 2 +- docs/examples/kotlin/locale/list-languages.md | 2 +- .../kotlin/messaging/create-subscriber.md | 2 +- .../kotlin/messaging/delete-subscriber.md | 2 +- docs/examples/kotlin/storage/create-file.md | 2 +- docs/examples/kotlin/storage/delete-file.md | 2 +- .../kotlin/storage/get-file-download.md | 2 +- .../kotlin/storage/get-file-preview.md | 2 +- docs/examples/kotlin/storage/get-file-view.md | 2 +- docs/examples/kotlin/storage/get-file.md | 2 +- docs/examples/kotlin/storage/list-files.md | 2 +- docs/examples/kotlin/storage/update-file.md | 2 +- .../kotlin/teams/create-membership.md | 2 +- docs/examples/kotlin/teams/create.md | 2 +- .../kotlin/teams/delete-membership.md | 2 +- docs/examples/kotlin/teams/delete.md | 2 +- docs/examples/kotlin/teams/get-membership.md | 2 +- docs/examples/kotlin/teams/get-prefs.md | 2 +- docs/examples/kotlin/teams/get.md | 2 +- .../examples/kotlin/teams/list-memberships.md | 2 +- docs/examples/kotlin/teams/list.md | 2 +- .../kotlin/teams/update-membership-status.md | 2 +- .../kotlin/teams/update-membership.md | 2 +- docs/examples/kotlin/teams/update-name.md | 2 +- docs/examples/kotlin/teams/update-prefs.md | 2 +- library/src/main/java/io/appwrite/Client.kt | 2 +- .../main/java/io/appwrite/services/Account.kt | 65 +++++++++++++++---- .../java/io/appwrite/services/Messaging.kt | 4 +- 95 files changed, 182 insertions(+), 108 deletions(-) create mode 100644 docs/examples/java/account/update-phone-session.md create mode 100644 docs/examples/kotlin/account/update-phone-session.md diff --git a/README.md b/README.md index c8363ac..a3537d0 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:5.0.0-rc.5") +implementation("io.appwrite:sdk-for-android:5.0.0-rc.6") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 5.0.0-rc.5 + 5.0.0-rc.6 ``` diff --git a/docs/examples/java/account/update-phone-session.md b/docs/examples/java/account/update-phone-session.md new file mode 100644 index 0000000..69d2dd7 --- /dev/null +++ b/docs/examples/java/account/update-phone-session.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.updatePhoneSession( + "", // userId + "", // secret + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/kotlin/account/add-authenticator.md b/docs/examples/kotlin/account/add-authenticator.md index 08e83a4..f96c175 100644 --- a/docs/examples/kotlin/account/add-authenticator.md +++ b/docs/examples/kotlin/account/add-authenticator.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) -val response = account.addAuthenticator( +val result = account.addAuthenticator( type = AuthenticatorType.TOTP, ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-anonymous-session.md b/docs/examples/kotlin/account/create-anonymous-session.md index 6d1e632..7961cc0 100644 --- a/docs/examples/kotlin/account/create-anonymous-session.md +++ b/docs/examples/kotlin/account/create-anonymous-session.md @@ -8,4 +8,4 @@ val client = Client(context) val account = Account(client) -val response = account.createAnonymousSession() +val result = account.createAnonymousSession() diff --git a/docs/examples/kotlin/account/create-challenge.md b/docs/examples/kotlin/account/create-challenge.md index 273d062..1018b96 100644 --- a/docs/examples/kotlin/account/create-challenge.md +++ b/docs/examples/kotlin/account/create-challenge.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) -val response = account.createChallenge( +val result = account.createChallenge( factor = AuthenticationFactor.TOTP, ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-email-password-session.md b/docs/examples/kotlin/account/create-email-password-session.md index d226101..57bc99b 100644 --- a/docs/examples/kotlin/account/create-email-password-session.md +++ b/docs/examples/kotlin/account/create-email-password-session.md @@ -8,7 +8,7 @@ val client = Client(context) val account = Account(client) -val response = account.createEmailPasswordSession( +val result = account.createEmailPasswordSession( email = "email@example.com", password = "password", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-email-token.md b/docs/examples/kotlin/account/create-email-token.md index 750be55..dd0bdf3 100644 --- a/docs/examples/kotlin/account/create-email-token.md +++ b/docs/examples/kotlin/account/create-email-token.md @@ -8,7 +8,7 @@ val client = Client(context) val account = Account(client) -val response = account.createEmailToken( +val result = account.createEmailToken( userId = "", email = "email@example.com", phrase = false, // (optional) diff --git a/docs/examples/kotlin/account/create-j-w-t.md b/docs/examples/kotlin/account/create-j-w-t.md index c3131e6..3aefe4a 100644 --- a/docs/examples/kotlin/account/create-j-w-t.md +++ b/docs/examples/kotlin/account/create-j-w-t.md @@ -8,4 +8,4 @@ val client = Client(context) val account = Account(client) -val response = account.createJWT() +val result = account.createJWT() diff --git a/docs/examples/kotlin/account/create-magic-u-r-l-token.md b/docs/examples/kotlin/account/create-magic-u-r-l-token.md index 99ce7ae..dad908e 100644 --- a/docs/examples/kotlin/account/create-magic-u-r-l-token.md +++ b/docs/examples/kotlin/account/create-magic-u-r-l-token.md @@ -8,7 +8,7 @@ val client = Client(context) val account = Account(client) -val response = account.createMagicURLToken( +val result = account.createMagicURLToken( userId = "", email = "email@example.com", url = "https://example.com", // (optional) diff --git a/docs/examples/kotlin/account/create-phone-token.md b/docs/examples/kotlin/account/create-phone-token.md index acef3bd..9e72059 100644 --- a/docs/examples/kotlin/account/create-phone-token.md +++ b/docs/examples/kotlin/account/create-phone-token.md @@ -8,7 +8,7 @@ val client = Client(context) val account = Account(client) -val response = account.createPhoneToken( +val result = account.createPhoneToken( userId = "", phone = "+12065550100", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-phone-verification.md b/docs/examples/kotlin/account/create-phone-verification.md index 3fb5064..3c94fb8 100644 --- a/docs/examples/kotlin/account/create-phone-verification.md +++ b/docs/examples/kotlin/account/create-phone-verification.md @@ -8,4 +8,4 @@ val client = Client(context) val account = Account(client) -val response = account.createPhoneVerification() +val result = account.createPhoneVerification() diff --git a/docs/examples/kotlin/account/create-push-target.md b/docs/examples/kotlin/account/create-push-target.md index de9b5a2..66729cc 100644 --- a/docs/examples/kotlin/account/create-push-target.md +++ b/docs/examples/kotlin/account/create-push-target.md @@ -8,7 +8,7 @@ val client = Client(context) val account = Account(client) -val response = account.createPushTarget( +val result = account.createPushTarget( targetId = "", identifier = "", providerId = "", // (optional) diff --git a/docs/examples/kotlin/account/create-recovery.md b/docs/examples/kotlin/account/create-recovery.md index 833edc5..8afb76c 100644 --- a/docs/examples/kotlin/account/create-recovery.md +++ b/docs/examples/kotlin/account/create-recovery.md @@ -8,7 +8,7 @@ val client = Client(context) val account = Account(client) -val response = account.createRecovery( +val result = account.createRecovery( email = "email@example.com", url = "https://example.com", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-session.md b/docs/examples/kotlin/account/create-session.md index 1ea8d22..49daa6b 100644 --- a/docs/examples/kotlin/account/create-session.md +++ b/docs/examples/kotlin/account/create-session.md @@ -8,7 +8,7 @@ val client = Client(context) val account = Account(client) -val response = account.createSession( +val result = account.createSession( userId = "", secret = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-verification.md b/docs/examples/kotlin/account/create-verification.md index 1f66931..0638a36 100644 --- a/docs/examples/kotlin/account/create-verification.md +++ b/docs/examples/kotlin/account/create-verification.md @@ -8,6 +8,6 @@ val client = Client(context) val account = Account(client) -val response = account.createVerification( +val result = account.createVerification( url = "https://example.com", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create.md b/docs/examples/kotlin/account/create.md index 21718ef..48b8b66 100644 --- a/docs/examples/kotlin/account/create.md +++ b/docs/examples/kotlin/account/create.md @@ -8,7 +8,7 @@ val client = Client(context) val account = Account(client) -val response = account.create( +val result = account.create( userId = "", email = "email@example.com", password = "", diff --git a/docs/examples/kotlin/account/delete-authenticator.md b/docs/examples/kotlin/account/delete-authenticator.md index 6cb24db..bc532b8 100644 --- a/docs/examples/kotlin/account/delete-authenticator.md +++ b/docs/examples/kotlin/account/delete-authenticator.md @@ -9,7 +9,7 @@ val client = Client(context) val account = Account(client) -val response = account.deleteAuthenticator( +val result = account.deleteAuthenticator( type = AuthenticatorType.TOTP, otp = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-identity.md b/docs/examples/kotlin/account/delete-identity.md index 1507342..099b5ac 100644 --- a/docs/examples/kotlin/account/delete-identity.md +++ b/docs/examples/kotlin/account/delete-identity.md @@ -8,6 +8,6 @@ val client = Client(context) val account = Account(client) -val response = account.deleteIdentity( +val result = account.deleteIdentity( identityId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-push-target.md b/docs/examples/kotlin/account/delete-push-target.md index c774d02..c20d04a 100644 --- a/docs/examples/kotlin/account/delete-push-target.md +++ b/docs/examples/kotlin/account/delete-push-target.md @@ -8,6 +8,6 @@ val client = Client(context) val account = Account(client) -val response = account.deletePushTarget( +val result = account.deletePushTarget( targetId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-session.md b/docs/examples/kotlin/account/delete-session.md index b49b3a5..ae2ed67 100644 --- a/docs/examples/kotlin/account/delete-session.md +++ b/docs/examples/kotlin/account/delete-session.md @@ -8,6 +8,6 @@ val client = Client(context) val account = Account(client) -val response = account.deleteSession( +val result = account.deleteSession( sessionId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-sessions.md b/docs/examples/kotlin/account/delete-sessions.md index db8e00d..7caaea4 100644 --- a/docs/examples/kotlin/account/delete-sessions.md +++ b/docs/examples/kotlin/account/delete-sessions.md @@ -8,4 +8,4 @@ val client = Client(context) val account = Account(client) -val response = account.deleteSessions() +val result = account.deleteSessions() diff --git a/docs/examples/kotlin/account/get-prefs.md b/docs/examples/kotlin/account/get-prefs.md index 0112f8b..08fdd13 100644 --- a/docs/examples/kotlin/account/get-prefs.md +++ b/docs/examples/kotlin/account/get-prefs.md @@ -8,4 +8,4 @@ val client = Client(context) val account = Account(client) -val response = account.getPrefs() +val result = account.getPrefs() diff --git a/docs/examples/kotlin/account/get-session.md b/docs/examples/kotlin/account/get-session.md index 38a5fa6..d0520ce 100644 --- a/docs/examples/kotlin/account/get-session.md +++ b/docs/examples/kotlin/account/get-session.md @@ -8,6 +8,6 @@ val client = Client(context) val account = Account(client) -val response = account.getSession( +val result = account.getSession( sessionId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/get.md b/docs/examples/kotlin/account/get.md index 6c08a1c..ed4874b 100644 --- a/docs/examples/kotlin/account/get.md +++ b/docs/examples/kotlin/account/get.md @@ -8,4 +8,4 @@ val client = Client(context) val account = Account(client) -val response = account.get() +val result = account.get() diff --git a/docs/examples/kotlin/account/list-factors.md b/docs/examples/kotlin/account/list-factors.md index e30f652..05ba2b8 100644 --- a/docs/examples/kotlin/account/list-factors.md +++ b/docs/examples/kotlin/account/list-factors.md @@ -8,4 +8,4 @@ val client = Client(context) val account = Account(client) -val response = account.listFactors() +val result = account.listFactors() diff --git a/docs/examples/kotlin/account/list-identities.md b/docs/examples/kotlin/account/list-identities.md index 3b5e7ca..bde6023 100644 --- a/docs/examples/kotlin/account/list-identities.md +++ b/docs/examples/kotlin/account/list-identities.md @@ -8,6 +8,6 @@ val client = Client(context) val account = Account(client) -val response = account.listIdentities( +val result = account.listIdentities( queries = listOf(), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/list-logs.md b/docs/examples/kotlin/account/list-logs.md index abf89b2..56238f9 100644 --- a/docs/examples/kotlin/account/list-logs.md +++ b/docs/examples/kotlin/account/list-logs.md @@ -8,6 +8,6 @@ val client = Client(context) val account = Account(client) -val response = account.listLogs( +val result = account.listLogs( queries = listOf(), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/list-sessions.md b/docs/examples/kotlin/account/list-sessions.md index 2c692b8..9d64c74 100644 --- a/docs/examples/kotlin/account/list-sessions.md +++ b/docs/examples/kotlin/account/list-sessions.md @@ -8,4 +8,4 @@ val client = Client(context) val account = Account(client) -val response = account.listSessions() +val result = account.listSessions() diff --git a/docs/examples/kotlin/account/update-challenge.md b/docs/examples/kotlin/account/update-challenge.md index 2bf6754..2a82bfb 100644 --- a/docs/examples/kotlin/account/update-challenge.md +++ b/docs/examples/kotlin/account/update-challenge.md @@ -8,7 +8,7 @@ val client = Client(context) val account = Account(client) -val response = account.updateChallenge( +val result = account.updateChallenge( challengeId = "", otp = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-email.md b/docs/examples/kotlin/account/update-email.md index aa4679c..5068962 100644 --- a/docs/examples/kotlin/account/update-email.md +++ b/docs/examples/kotlin/account/update-email.md @@ -8,7 +8,7 @@ val client = Client(context) val account = Account(client) -val response = account.updateEmail( +val result = account.updateEmail( email = "email@example.com", password = "password", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-m-f-a.md b/docs/examples/kotlin/account/update-m-f-a.md index 0327757..7949490 100644 --- a/docs/examples/kotlin/account/update-m-f-a.md +++ b/docs/examples/kotlin/account/update-m-f-a.md @@ -8,6 +8,6 @@ val client = Client(context) val account = Account(client) -val response = account.updateMFA( +val result = account.updateMFA( mfa = false, ) \ No newline at end of file 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 9226177..0abb033 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 @@ -8,7 +8,7 @@ val client = Client(context) val account = Account(client) -val response = account.updateMagicURLSession( +val result = account.updateMagicURLSession( userId = "", secret = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-name.md b/docs/examples/kotlin/account/update-name.md index 5af1deb..20aab9d 100644 --- a/docs/examples/kotlin/account/update-name.md +++ b/docs/examples/kotlin/account/update-name.md @@ -8,6 +8,6 @@ val client = Client(context) val account = Account(client) -val response = account.updateName( +val result = account.updateName( name = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-password.md b/docs/examples/kotlin/account/update-password.md index 646ebe7..86c862c 100644 --- a/docs/examples/kotlin/account/update-password.md +++ b/docs/examples/kotlin/account/update-password.md @@ -8,7 +8,7 @@ val client = Client(context) val account = Account(client) -val response = account.updatePassword( +val result = account.updatePassword( password = "", oldPassword = "password", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-phone-session.md b/docs/examples/kotlin/account/update-phone-session.md new file mode 100644 index 0000000..6c8fa65 --- /dev/null +++ b/docs/examples/kotlin/account/update-phone-session.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val result = account.updatePhoneSession( + userId = "", + secret = "", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-phone-verification.md b/docs/examples/kotlin/account/update-phone-verification.md index 0ef08ce..445a47e 100644 --- a/docs/examples/kotlin/account/update-phone-verification.md +++ b/docs/examples/kotlin/account/update-phone-verification.md @@ -8,7 +8,7 @@ val client = Client(context) val account = Account(client) -val response = account.updatePhoneVerification( +val result = account.updatePhoneVerification( userId = "", secret = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-phone.md b/docs/examples/kotlin/account/update-phone.md index 834d826..c8f50c3 100644 --- a/docs/examples/kotlin/account/update-phone.md +++ b/docs/examples/kotlin/account/update-phone.md @@ -8,7 +8,7 @@ val client = Client(context) val account = Account(client) -val response = account.updatePhone( +val result = account.updatePhone( phone = "+12065550100", password = "password", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-prefs.md b/docs/examples/kotlin/account/update-prefs.md index 02ddc58..f449ccb 100644 --- a/docs/examples/kotlin/account/update-prefs.md +++ b/docs/examples/kotlin/account/update-prefs.md @@ -8,6 +8,6 @@ val client = Client(context) val account = Account(client) -val response = account.updatePrefs( +val result = account.updatePrefs( prefs = mapOf( "a" to "b" ), ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-push-target.md b/docs/examples/kotlin/account/update-push-target.md index 2a7d4d7..5fff554 100644 --- a/docs/examples/kotlin/account/update-push-target.md +++ b/docs/examples/kotlin/account/update-push-target.md @@ -8,7 +8,7 @@ val client = Client(context) val account = Account(client) -val response = account.updatePushTarget( +val result = account.updatePushTarget( targetId = "", identifier = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-recovery.md b/docs/examples/kotlin/account/update-recovery.md index 646c3a5..da1f27e 100644 --- a/docs/examples/kotlin/account/update-recovery.md +++ b/docs/examples/kotlin/account/update-recovery.md @@ -8,7 +8,7 @@ val client = Client(context) val account = Account(client) -val response = account.updateRecovery( +val result = account.updateRecovery( userId = "", secret = "", password = "", diff --git a/docs/examples/kotlin/account/update-session.md b/docs/examples/kotlin/account/update-session.md index 2bad6e8..3252039 100644 --- a/docs/examples/kotlin/account/update-session.md +++ b/docs/examples/kotlin/account/update-session.md @@ -8,6 +8,6 @@ val client = Client(context) val account = Account(client) -val response = account.updateSession( +val result = account.updateSession( sessionId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-status.md b/docs/examples/kotlin/account/update-status.md index e822de9..2b54214 100644 --- a/docs/examples/kotlin/account/update-status.md +++ b/docs/examples/kotlin/account/update-status.md @@ -8,4 +8,4 @@ val client = Client(context) val account = Account(client) -val response = account.updateStatus() +val result = account.updateStatus() diff --git a/docs/examples/kotlin/account/update-verification.md b/docs/examples/kotlin/account/update-verification.md index 129b825..5f7f902 100644 --- a/docs/examples/kotlin/account/update-verification.md +++ b/docs/examples/kotlin/account/update-verification.md @@ -8,7 +8,7 @@ val client = Client(context) val account = Account(client) -val response = account.updateVerification( +val result = account.updateVerification( userId = "", secret = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/verify-authenticator.md b/docs/examples/kotlin/account/verify-authenticator.md index a0f5dd3..9c306d4 100644 --- a/docs/examples/kotlin/account/verify-authenticator.md +++ b/docs/examples/kotlin/account/verify-authenticator.md @@ -9,7 +9,7 @@ val client = Client(context) val account = Account(client) -val response = account.verifyAuthenticator( +val result = account.verifyAuthenticator( type = AuthenticatorType.TOTP, otp = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-browser.md b/docs/examples/kotlin/avatars/get-browser.md index ab443c3..1e63217 100644 --- a/docs/examples/kotlin/avatars/get-browser.md +++ b/docs/examples/kotlin/avatars/get-browser.md @@ -9,7 +9,7 @@ val client = Client(context) val avatars = Avatars(client) -val result =avatars.getBrowser( +val result = avatars.getBrowser( code = Browser.AVANT_BROWSER, width = 0, // (optional) height = 0, // (optional) diff --git a/docs/examples/kotlin/avatars/get-credit-card.md b/docs/examples/kotlin/avatars/get-credit-card.md index cb4a3f2..23fbbfd 100644 --- a/docs/examples/kotlin/avatars/get-credit-card.md +++ b/docs/examples/kotlin/avatars/get-credit-card.md @@ -9,7 +9,7 @@ val client = Client(context) val avatars = Avatars(client) -val result =avatars.getCreditCard( +val result = avatars.getCreditCard( code = CreditCard.AMERICAN_EXPRESS, width = 0, // (optional) height = 0, // (optional) diff --git a/docs/examples/kotlin/avatars/get-favicon.md b/docs/examples/kotlin/avatars/get-favicon.md index aa4bac3..a2d5e18 100644 --- a/docs/examples/kotlin/avatars/get-favicon.md +++ b/docs/examples/kotlin/avatars/get-favicon.md @@ -8,6 +8,6 @@ val client = Client(context) val avatars = Avatars(client) -val result =avatars.getFavicon( +val result = avatars.getFavicon( url = "https://example.com", ) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-flag.md b/docs/examples/kotlin/avatars/get-flag.md index f54b952..b1ac632 100644 --- a/docs/examples/kotlin/avatars/get-flag.md +++ b/docs/examples/kotlin/avatars/get-flag.md @@ -9,7 +9,7 @@ val client = Client(context) val avatars = Avatars(client) -val result =avatars.getFlag( +val result = avatars.getFlag( code = Flag.AFGHANISTAN, width = 0, // (optional) height = 0, // (optional) diff --git a/docs/examples/kotlin/avatars/get-image.md b/docs/examples/kotlin/avatars/get-image.md index 18b1c78..bb76b4c 100644 --- a/docs/examples/kotlin/avatars/get-image.md +++ b/docs/examples/kotlin/avatars/get-image.md @@ -8,7 +8,7 @@ val client = Client(context) val avatars = Avatars(client) -val result =avatars.getImage( +val result = avatars.getImage( url = "https://example.com", width = 0, // (optional) height = 0, // (optional) diff --git a/docs/examples/kotlin/avatars/get-initials.md b/docs/examples/kotlin/avatars/get-initials.md index 69f2f9b..b2a1c25 100644 --- a/docs/examples/kotlin/avatars/get-initials.md +++ b/docs/examples/kotlin/avatars/get-initials.md @@ -8,7 +8,7 @@ val client = Client(context) val avatars = Avatars(client) -val result =avatars.getInitials( +val result = avatars.getInitials( name = "", // (optional) width = 0, // (optional) height = 0, // (optional) diff --git a/docs/examples/kotlin/avatars/get-q-r.md b/docs/examples/kotlin/avatars/get-q-r.md index e54b0c4..853d94e 100644 --- a/docs/examples/kotlin/avatars/get-q-r.md +++ b/docs/examples/kotlin/avatars/get-q-r.md @@ -8,7 +8,7 @@ val client = Client(context) val avatars = Avatars(client) -val result =avatars.getQR( +val result = avatars.getQR( text = "", size = 1, // (optional) margin = 0, // (optional) diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index 6a36558..10b6fdf 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -8,7 +8,7 @@ val client = Client(context) val databases = Databases(client) -val response = databases.createDocument( +val result = databases.createDocument( databaseId = "", collectionId = "", documentId = "", diff --git a/docs/examples/kotlin/databases/delete-document.md b/docs/examples/kotlin/databases/delete-document.md index f8859a5..3eb1147 100644 --- a/docs/examples/kotlin/databases/delete-document.md +++ b/docs/examples/kotlin/databases/delete-document.md @@ -8,7 +8,7 @@ val client = Client(context) val databases = Databases(client) -val response = databases.deleteDocument( +val result = databases.deleteDocument( databaseId = "", collectionId = "", documentId = "", diff --git a/docs/examples/kotlin/databases/get-document.md b/docs/examples/kotlin/databases/get-document.md index 5a8e260..6c5f92a 100644 --- a/docs/examples/kotlin/databases/get-document.md +++ b/docs/examples/kotlin/databases/get-document.md @@ -8,7 +8,7 @@ val client = Client(context) val databases = Databases(client) -val response = databases.getDocument( +val result = databases.getDocument( databaseId = "", collectionId = "", documentId = "", diff --git a/docs/examples/kotlin/databases/list-documents.md b/docs/examples/kotlin/databases/list-documents.md index 5601f06..7b1e851 100644 --- a/docs/examples/kotlin/databases/list-documents.md +++ b/docs/examples/kotlin/databases/list-documents.md @@ -8,7 +8,7 @@ val client = Client(context) val databases = Databases(client) -val response = databases.listDocuments( +val result = databases.listDocuments( databaseId = "", collectionId = "", queries = listOf(), // (optional) diff --git a/docs/examples/kotlin/databases/update-document.md b/docs/examples/kotlin/databases/update-document.md index 583ba3f..de6b192 100644 --- a/docs/examples/kotlin/databases/update-document.md +++ b/docs/examples/kotlin/databases/update-document.md @@ -8,7 +8,7 @@ val client = Client(context) val databases = Databases(client) -val response = databases.updateDocument( +val result = databases.updateDocument( databaseId = "", collectionId = "", documentId = "", diff --git a/docs/examples/kotlin/functions/create-execution.md b/docs/examples/kotlin/functions/create-execution.md index b0b5538..de84186 100644 --- a/docs/examples/kotlin/functions/create-execution.md +++ b/docs/examples/kotlin/functions/create-execution.md @@ -8,7 +8,7 @@ val client = Client(context) val functions = Functions(client) -val response = functions.createExecution( +val result = functions.createExecution( functionId = "", body = "", // (optional) async = false, // (optional) diff --git a/docs/examples/kotlin/functions/get-execution.md b/docs/examples/kotlin/functions/get-execution.md index 2adbf9a..0c4de1e 100644 --- a/docs/examples/kotlin/functions/get-execution.md +++ b/docs/examples/kotlin/functions/get-execution.md @@ -8,7 +8,7 @@ val client = Client(context) val functions = Functions(client) -val response = functions.getExecution( +val result = functions.getExecution( functionId = "", executionId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/list-executions.md b/docs/examples/kotlin/functions/list-executions.md index 8e02409..d28b32c 100644 --- a/docs/examples/kotlin/functions/list-executions.md +++ b/docs/examples/kotlin/functions/list-executions.md @@ -8,7 +8,7 @@ val client = Client(context) val functions = Functions(client) -val response = functions.listExecutions( +val result = functions.listExecutions( functionId = "", queries = listOf(), // (optional) search = "", // (optional) diff --git a/docs/examples/kotlin/graphql/mutation.md b/docs/examples/kotlin/graphql/mutation.md index c22a403..a429a66 100644 --- a/docs/examples/kotlin/graphql/mutation.md +++ b/docs/examples/kotlin/graphql/mutation.md @@ -8,6 +8,6 @@ val client = Client(context) val graphql = Graphql(client) -val response = graphql.mutation( +val result = graphql.mutation( query = mapOf( "a" to "b" ), ) \ No newline at end of file diff --git a/docs/examples/kotlin/graphql/query.md b/docs/examples/kotlin/graphql/query.md index 00850c4..0c39edd 100644 --- a/docs/examples/kotlin/graphql/query.md +++ b/docs/examples/kotlin/graphql/query.md @@ -8,6 +8,6 @@ val client = Client(context) val graphql = Graphql(client) -val response = graphql.query( +val result = graphql.query( query = mapOf( "a" to "b" ), ) \ No newline at end of file diff --git a/docs/examples/kotlin/locale/get.md b/docs/examples/kotlin/locale/get.md index ec7f625..d38572a 100644 --- a/docs/examples/kotlin/locale/get.md +++ b/docs/examples/kotlin/locale/get.md @@ -8,4 +8,4 @@ val client = Client(context) val locale = Locale(client) -val response = locale.get() +val result = locale.get() diff --git a/docs/examples/kotlin/locale/list-codes.md b/docs/examples/kotlin/locale/list-codes.md index e81e106..9f506f0 100644 --- a/docs/examples/kotlin/locale/list-codes.md +++ b/docs/examples/kotlin/locale/list-codes.md @@ -8,4 +8,4 @@ val client = Client(context) val locale = Locale(client) -val response = locale.listCodes() +val result = locale.listCodes() diff --git a/docs/examples/kotlin/locale/list-continents.md b/docs/examples/kotlin/locale/list-continents.md index 0255e65..96cfda5 100644 --- a/docs/examples/kotlin/locale/list-continents.md +++ b/docs/examples/kotlin/locale/list-continents.md @@ -8,4 +8,4 @@ val client = Client(context) val locale = Locale(client) -val response = locale.listContinents() +val result = 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 4cf60d9..54faf5e 100644 --- a/docs/examples/kotlin/locale/list-countries-e-u.md +++ b/docs/examples/kotlin/locale/list-countries-e-u.md @@ -8,4 +8,4 @@ val client = Client(context) val locale = Locale(client) -val response = locale.listCountriesEU() +val result = locale.listCountriesEU() diff --git a/docs/examples/kotlin/locale/list-countries-phones.md b/docs/examples/kotlin/locale/list-countries-phones.md index 1f8f75b..9e4bec1 100644 --- a/docs/examples/kotlin/locale/list-countries-phones.md +++ b/docs/examples/kotlin/locale/list-countries-phones.md @@ -8,4 +8,4 @@ val client = Client(context) val locale = Locale(client) -val response = locale.listCountriesPhones() +val result = locale.listCountriesPhones() diff --git a/docs/examples/kotlin/locale/list-countries.md b/docs/examples/kotlin/locale/list-countries.md index f221fc6..4299efb 100644 --- a/docs/examples/kotlin/locale/list-countries.md +++ b/docs/examples/kotlin/locale/list-countries.md @@ -8,4 +8,4 @@ val client = Client(context) val locale = Locale(client) -val response = locale.listCountries() +val result = locale.listCountries() diff --git a/docs/examples/kotlin/locale/list-currencies.md b/docs/examples/kotlin/locale/list-currencies.md index 6e5ab0d..2bb7ca7 100644 --- a/docs/examples/kotlin/locale/list-currencies.md +++ b/docs/examples/kotlin/locale/list-currencies.md @@ -8,4 +8,4 @@ val client = Client(context) val locale = Locale(client) -val response = locale.listCurrencies() +val result = locale.listCurrencies() diff --git a/docs/examples/kotlin/locale/list-languages.md b/docs/examples/kotlin/locale/list-languages.md index 97a9eb7..a9035e9 100644 --- a/docs/examples/kotlin/locale/list-languages.md +++ b/docs/examples/kotlin/locale/list-languages.md @@ -8,4 +8,4 @@ val client = Client(context) val locale = Locale(client) -val response = locale.listLanguages() +val result = locale.listLanguages() diff --git a/docs/examples/kotlin/messaging/create-subscriber.md b/docs/examples/kotlin/messaging/create-subscriber.md index 20771e5..3f1d476 100644 --- a/docs/examples/kotlin/messaging/create-subscriber.md +++ b/docs/examples/kotlin/messaging/create-subscriber.md @@ -8,7 +8,7 @@ val client = Client(context) val messaging = Messaging(client) -val response = messaging.createSubscriber( +val result = messaging.createSubscriber( topicId = "", subscriberId = "", targetId = "", diff --git a/docs/examples/kotlin/messaging/delete-subscriber.md b/docs/examples/kotlin/messaging/delete-subscriber.md index 02487c7..febf622 100644 --- a/docs/examples/kotlin/messaging/delete-subscriber.md +++ b/docs/examples/kotlin/messaging/delete-subscriber.md @@ -8,7 +8,7 @@ val client = Client(context) val messaging = Messaging(client) -val response = messaging.deleteSubscriber( +val result = messaging.deleteSubscriber( topicId = "", subscriberId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/create-file.md b/docs/examples/kotlin/storage/create-file.md index b5e4663..ccd342e 100644 --- a/docs/examples/kotlin/storage/create-file.md +++ b/docs/examples/kotlin/storage/create-file.md @@ -9,7 +9,7 @@ val client = Client(context) val storage = Storage(client) -val response = storage.createFile( +val result = storage.createFile( bucketId = "", fileId = "", file = InputFile.fromPath("file.png"), diff --git a/docs/examples/kotlin/storage/delete-file.md b/docs/examples/kotlin/storage/delete-file.md index 49a2505..8def7d9 100644 --- a/docs/examples/kotlin/storage/delete-file.md +++ b/docs/examples/kotlin/storage/delete-file.md @@ -8,7 +8,7 @@ val client = Client(context) val storage = Storage(client) -val response = storage.deleteFile( +val result = storage.deleteFile( bucketId = "", fileId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file-download.md b/docs/examples/kotlin/storage/get-file-download.md index c6fe106..c6e8fa4 100644 --- a/docs/examples/kotlin/storage/get-file-download.md +++ b/docs/examples/kotlin/storage/get-file-download.md @@ -8,7 +8,7 @@ val client = Client(context) val storage = Storage(client) -val result =storage.getFileDownload( +val result = storage.getFileDownload( bucketId = "", fileId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file-preview.md b/docs/examples/kotlin/storage/get-file-preview.md index 545391f..9c9993c 100644 --- a/docs/examples/kotlin/storage/get-file-preview.md +++ b/docs/examples/kotlin/storage/get-file-preview.md @@ -8,7 +8,7 @@ val client = Client(context) val storage = Storage(client) -val result =storage.getFilePreview( +val result = storage.getFilePreview( bucketId = "", fileId = "", width = 0, // (optional) diff --git a/docs/examples/kotlin/storage/get-file-view.md b/docs/examples/kotlin/storage/get-file-view.md index 307739d..83f8b31 100644 --- a/docs/examples/kotlin/storage/get-file-view.md +++ b/docs/examples/kotlin/storage/get-file-view.md @@ -8,7 +8,7 @@ val client = Client(context) val storage = Storage(client) -val result =storage.getFileView( +val result = storage.getFileView( bucketId = "", fileId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file.md b/docs/examples/kotlin/storage/get-file.md index e82eb56..df662ea 100644 --- a/docs/examples/kotlin/storage/get-file.md +++ b/docs/examples/kotlin/storage/get-file.md @@ -8,7 +8,7 @@ val client = Client(context) val storage = Storage(client) -val response = storage.getFile( +val result = storage.getFile( bucketId = "", fileId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/list-files.md b/docs/examples/kotlin/storage/list-files.md index 54dbaa0..4e28fc5 100644 --- a/docs/examples/kotlin/storage/list-files.md +++ b/docs/examples/kotlin/storage/list-files.md @@ -8,7 +8,7 @@ val client = Client(context) val storage = Storage(client) -val response = storage.listFiles( +val result = storage.listFiles( bucketId = "", queries = listOf(), // (optional) search = "", // (optional) diff --git a/docs/examples/kotlin/storage/update-file.md b/docs/examples/kotlin/storage/update-file.md index 351ea52..c84dadb 100644 --- a/docs/examples/kotlin/storage/update-file.md +++ b/docs/examples/kotlin/storage/update-file.md @@ -8,7 +8,7 @@ val client = Client(context) val storage = Storage(client) -val response = storage.updateFile( +val result = storage.updateFile( bucketId = "", fileId = "", name = "", // (optional) diff --git a/docs/examples/kotlin/teams/create-membership.md b/docs/examples/kotlin/teams/create-membership.md index 1a49b3e..a892663 100644 --- a/docs/examples/kotlin/teams/create-membership.md +++ b/docs/examples/kotlin/teams/create-membership.md @@ -8,7 +8,7 @@ val client = Client(context) val teams = Teams(client) -val response = teams.createMembership( +val result = teams.createMembership( teamId = "", roles = listOf(), email = "email@example.com", // (optional) diff --git a/docs/examples/kotlin/teams/create.md b/docs/examples/kotlin/teams/create.md index 1dce8a5..22d6e7f 100644 --- a/docs/examples/kotlin/teams/create.md +++ b/docs/examples/kotlin/teams/create.md @@ -8,7 +8,7 @@ val client = Client(context) val teams = Teams(client) -val response = teams.create( +val result = teams.create( teamId = "", name = "", roles = listOf(), // (optional) diff --git a/docs/examples/kotlin/teams/delete-membership.md b/docs/examples/kotlin/teams/delete-membership.md index 1548551..66e5716 100644 --- a/docs/examples/kotlin/teams/delete-membership.md +++ b/docs/examples/kotlin/teams/delete-membership.md @@ -8,7 +8,7 @@ val client = Client(context) val teams = Teams(client) -val response = teams.deleteMembership( +val result = teams.deleteMembership( teamId = "", membershipId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/delete.md b/docs/examples/kotlin/teams/delete.md index 3709d7b..a73fa75 100644 --- a/docs/examples/kotlin/teams/delete.md +++ b/docs/examples/kotlin/teams/delete.md @@ -8,6 +8,6 @@ val client = Client(context) val teams = Teams(client) -val response = teams.delete( +val result = teams.delete( teamId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/get-membership.md b/docs/examples/kotlin/teams/get-membership.md index b77e813..80640c7 100644 --- a/docs/examples/kotlin/teams/get-membership.md +++ b/docs/examples/kotlin/teams/get-membership.md @@ -8,7 +8,7 @@ val client = Client(context) val teams = Teams(client) -val response = teams.getMembership( +val result = teams.getMembership( teamId = "", membershipId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/get-prefs.md b/docs/examples/kotlin/teams/get-prefs.md index 11ecc61..31001bd 100644 --- a/docs/examples/kotlin/teams/get-prefs.md +++ b/docs/examples/kotlin/teams/get-prefs.md @@ -8,6 +8,6 @@ val client = Client(context) val teams = Teams(client) -val response = teams.getPrefs( +val result = teams.getPrefs( teamId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/get.md b/docs/examples/kotlin/teams/get.md index ff885e8..4387118 100644 --- a/docs/examples/kotlin/teams/get.md +++ b/docs/examples/kotlin/teams/get.md @@ -8,6 +8,6 @@ val client = Client(context) val teams = Teams(client) -val response = teams.get( +val result = teams.get( teamId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/list-memberships.md b/docs/examples/kotlin/teams/list-memberships.md index f143426..7c8c686 100644 --- a/docs/examples/kotlin/teams/list-memberships.md +++ b/docs/examples/kotlin/teams/list-memberships.md @@ -8,7 +8,7 @@ val client = Client(context) val teams = Teams(client) -val response = teams.listMemberships( +val result = teams.listMemberships( teamId = "", queries = listOf(), // (optional) search = "", // (optional) diff --git a/docs/examples/kotlin/teams/list.md b/docs/examples/kotlin/teams/list.md index 91475e2..e73d9e4 100644 --- a/docs/examples/kotlin/teams/list.md +++ b/docs/examples/kotlin/teams/list.md @@ -8,7 +8,7 @@ val client = Client(context) val teams = Teams(client) -val response = teams.list( +val result = teams.list( queries = listOf(), // (optional) search = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-membership-status.md b/docs/examples/kotlin/teams/update-membership-status.md index 22b1c81..0866892 100644 --- a/docs/examples/kotlin/teams/update-membership-status.md +++ b/docs/examples/kotlin/teams/update-membership-status.md @@ -8,7 +8,7 @@ val client = Client(context) val teams = Teams(client) -val response = teams.updateMembershipStatus( +val result = teams.updateMembershipStatus( teamId = "", membershipId = "", userId = "", diff --git a/docs/examples/kotlin/teams/update-membership.md b/docs/examples/kotlin/teams/update-membership.md index 035bdff..799c594 100644 --- a/docs/examples/kotlin/teams/update-membership.md +++ b/docs/examples/kotlin/teams/update-membership.md @@ -8,7 +8,7 @@ val client = Client(context) val teams = Teams(client) -val response = teams.updateMembership( +val result = teams.updateMembership( teamId = "", membershipId = "", roles = listOf(), diff --git a/docs/examples/kotlin/teams/update-name.md b/docs/examples/kotlin/teams/update-name.md index 77ccd47..5e2399a 100644 --- a/docs/examples/kotlin/teams/update-name.md +++ b/docs/examples/kotlin/teams/update-name.md @@ -8,7 +8,7 @@ val client = Client(context) val teams = Teams(client) -val response = teams.updateName( +val result = teams.updateName( teamId = "", name = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-prefs.md b/docs/examples/kotlin/teams/update-prefs.md index 702bc9c..62febab 100644 --- a/docs/examples/kotlin/teams/update-prefs.md +++ b/docs/examples/kotlin/teams/update-prefs.md @@ -8,7 +8,7 @@ val client = Client(context) val teams = Teams(client) -val response = teams.updatePrefs( +val result = teams.updatePrefs( teamId = "", prefs = mapOf( "a" to "b" ), ) \ 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 a191ff0..68e4233 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -83,7 +83,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "5.0.0-rc.5", + "x-sdk-version" to "5.0.0-rc.6", "x-appwrite-response-format" to "1.5.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index ac37eb1..0abdfd2 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -322,7 +322,7 @@ class Account(client: Client) : Service(client) { /** * Update MFA * - * + * Enable or disable MFA on an account. * * @param mfa Enable or disable MFA. * @return [io.appwrite.models.User] @@ -356,7 +356,7 @@ class Account(client: Client) : Service(client) { /** * Update MFA * - * + * Enable or disable MFA on an account. * * @param mfa Enable or disable MFA. * @return [io.appwrite.models.User] @@ -406,7 +406,7 @@ class Account(client: Client) : Service(client) { /** * Create MFA Challenge (confirmation) * - * + * Complete the MFA challenge by providing the one-time password. * * @param challengeId ID of the challenge. * @param otp Valid verification token. @@ -438,7 +438,7 @@ class Account(client: Client) : Service(client) { /** * List Factors * - * + * List the factors available on the account to be used as a MFA challange. * * @return [io.appwrite.models.MfaFactors] */ @@ -469,7 +469,7 @@ class Account(client: Client) : Service(client) { /** * Add Authenticator * - * + * Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#verifyAuthenticator) method. * * @param type Type of authenticator. * @return [io.appwrite.models.MfaType] @@ -503,7 +503,7 @@ class Account(client: Client) : Service(client) { /** * Verify Authenticator * - * + * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#addAuthenticator) method. * * @param type Type of authenticator. * @param otp Valid verification token. @@ -540,7 +540,7 @@ class Account(client: Client) : Service(client) { /** * Verify Authenticator * - * + * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#addAuthenticator) method. * * @param type Type of authenticator. * @param otp Valid verification token. @@ -559,7 +559,7 @@ class Account(client: Client) : Service(client) { /** * Delete Authenticator * - * + * Delete an authenticator for a user by ID. * * @param type Type of authenticator. * @param otp Valid verification token. @@ -596,7 +596,7 @@ class Account(client: Client) : Service(client) { /** * Delete Authenticator * - * + * Delete an authenticator for a user by ID. * * @param type Type of authenticator. * @param otp Valid verification token. @@ -1073,7 +1073,7 @@ class Account(client: Client) : Service(client) { /** - * Create session (deprecated) + * Update magic URL session * * Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. * @@ -1181,6 +1181,43 @@ class Account(client: Client) : Service(client) { } + /** + * Update phone session + * + * Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. + * + * @param userId User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 secret Valid verification token. + * @return [io.appwrite.models.Session] + */ + suspend fun updatePhoneSession( + userId: String, + secret: String, + ): io.appwrite.models.Session { + val apiPath = "/account/sessions/phone" + + val apiParams = mutableMapOf( + "userId" to userId, + "secret" to secret, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Session = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Session.from(map = it as Map) + } + return client.call( + "PUT", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Session::class.java, + converter, + ) + } + + /** * Create session * @@ -1253,7 +1290,7 @@ class Account(client: Client) : Service(client) { /** - * Update (or renew) a session + * Update (or renew) session * * Extend session's expiry to increase it's lifespan. Extending a session is useful when session length is short such as 5 minutes. * @@ -1360,7 +1397,7 @@ class Account(client: Client) : Service(client) { ) /** - * Create a push target + * Create push target * * * @@ -1401,7 +1438,7 @@ class Account(client: Client) : Service(client) { /** - * Update a push target + * Update push target * * * @@ -1438,7 +1475,7 @@ class Account(client: Client) : Service(client) { /** - * Delete a push target + * Delete push target * * * diff --git a/library/src/main/java/io/appwrite/services/Messaging.kt b/library/src/main/java/io/appwrite/services/Messaging.kt index 6e11bd7..baca2c4 100644 --- a/library/src/main/java/io/appwrite/services/Messaging.kt +++ b/library/src/main/java/io/appwrite/services/Messaging.kt @@ -16,7 +16,7 @@ import java.io.File class Messaging(client: Client) : Service(client) { /** - * Create a subscriber + * Create subscriber * * Create a new subscriber. * @@ -56,7 +56,7 @@ class Messaging(client: Client) : Service(client) { /** - * Delete a subscriber + * Delete subscriber * * Delete a subscriber by its unique ID. * From 0468a1bab2e1bbe872b3e7e64f8472ddd537a52c Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 8 Mar 2024 10:44:19 +0100 Subject: [PATCH 068/118] Appwite 1.5 support --- README.md | 6 +- ...ticator.md => create-mfa-authenticator.md} | 2 +- ...e-challenge.md => create-mfa-challenge.md} | 4 +- .../java/account/create-mfa-recovery-codes.md | 18 ++ ...ticator.md => delete-mfa-authenticator.md} | 2 +- .../java/account/get-mfa-recovery-codes.md | 18 ++ .../{list-factors.md => list-mfa-factors.md} | 2 +- ...ticator.md => update-mfa-authenticator.md} | 2 +- ...e-challenge.md => update-mfa-challenge.md} | 2 +- .../java/account/update-mfa-recovery-codes.md | 18 ++ ...ticator.md => create-mfa-authenticator.md} | 2 +- ...e-challenge.md => create-mfa-challenge.md} | 4 +- .../account/create-mfa-recovery-codes.md | 11 + ...ticator.md => delete-mfa-authenticator.md} | 2 +- .../kotlin/account/get-mfa-recovery-codes.md | 11 + .../{list-factors.md => list-mfa-factors.md} | 2 +- ...ticator.md => update-mfa-authenticator.md} | 2 +- ...e-challenge.md => update-mfa-challenge.md} | 2 +- .../account/update-mfa-recovery-codes.md | 11 + library/src/main/java/io/appwrite/Client.kt | 2 +- .../io/appwrite/enums/AuthenticationFactor.kt | 10 +- .../main/java/io/appwrite/enums/Browser.kt | 6 +- .../src/main/java/io/appwrite/enums/Flag.kt | 22 +- .../java/io/appwrite/enums/ImageGravity.kt | 8 +- .../java/io/appwrite/enums/OAuthProvider.kt | 4 +- .../io/appwrite/models/MfaRecoveryCodes.kt | 30 ++ .../main/java/io/appwrite/models/MfaType.kt | 8 - .../main/java/io/appwrite/models/Session.kt | 8 + .../src/main/java/io/appwrite/models/User.kt | 10 - .../main/java/io/appwrite/services/Account.kt | 275 ++++++++++++------ 30 files changed, 353 insertions(+), 151 deletions(-) rename docs/examples/java/account/{add-authenticator.md => create-mfa-authenticator.md} (94%) rename docs/examples/java/account/{create-challenge.md => create-mfa-challenge.md} (88%) create mode 100644 docs/examples/java/account/create-mfa-recovery-codes.md rename docs/examples/java/account/{verify-authenticator.md => delete-mfa-authenticator.md} (95%) create mode 100644 docs/examples/java/account/get-mfa-recovery-codes.md rename docs/examples/java/account/{list-factors.md => list-mfa-factors.md} (86%) rename docs/examples/java/account/{delete-authenticator.md => update-mfa-authenticator.md} (95%) rename docs/examples/java/account/{update-challenge.md => update-mfa-challenge.md} (95%) create mode 100644 docs/examples/java/account/update-mfa-recovery-codes.md rename docs/examples/kotlin/account/{add-authenticator.md => create-mfa-authenticator.md} (89%) rename docs/examples/kotlin/account/{create-challenge.md => create-mfa-challenge.md} (80%) create mode 100644 docs/examples/kotlin/account/create-mfa-recovery-codes.md rename docs/examples/kotlin/account/{verify-authenticator.md => delete-mfa-authenticator.md} (89%) create mode 100644 docs/examples/kotlin/account/get-mfa-recovery-codes.md rename docs/examples/kotlin/account/{list-factors.md => list-mfa-factors.md} (88%) rename docs/examples/kotlin/account/{delete-authenticator.md => update-mfa-authenticator.md} (89%) rename docs/examples/kotlin/account/{update-challenge.md => update-mfa-challenge.md} (89%) create mode 100644 docs/examples/kotlin/account/update-mfa-recovery-codes.md create mode 100644 library/src/main/java/io/appwrite/models/MfaRecoveryCodes.kt diff --git a/README.md b/README.md index a3537d0..d2e0903 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Android SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) -![Appwrite](https://appwrite.io/images/github.png) +![Appwrite](https://github.com/appwrite/appwrite/raw/main/public/images/github.png) ## Installation @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:5.0.0-rc.6") +implementation("io.appwrite:sdk-for-android:5.0.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 5.0.0-rc.6 + 5.0.0 ``` diff --git a/docs/examples/java/account/add-authenticator.md b/docs/examples/java/account/create-mfa-authenticator.md similarity index 94% rename from docs/examples/java/account/add-authenticator.md rename to docs/examples/java/account/create-mfa-authenticator.md index e81255d..cc64341 100644 --- a/docs/examples/java/account/add-authenticator.md +++ b/docs/examples/java/account/create-mfa-authenticator.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); -account.addAuthenticator( +account.createMfaAuthenticator( AuthenticatorType.TOTP, // type new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/account/create-challenge.md b/docs/examples/java/account/create-mfa-challenge.md similarity index 88% rename from docs/examples/java/account/create-challenge.md rename to docs/examples/java/account/create-mfa-challenge.md index 7a31920..a2c2aa4 100644 --- a/docs/examples/java/account/create-challenge.md +++ b/docs/examples/java/account/create-mfa-challenge.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); -account.createChallenge( - AuthenticationFactor.TOTP, // factor +account.createMfaChallenge( + AuthenticationFactor.EMAIL, // factor new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/create-mfa-recovery-codes.md b/docs/examples/java/account/create-mfa-recovery-codes.md new file mode 100644 index 0000000..8ed8573 --- /dev/null +++ b/docs/examples/java/account/create-mfa-recovery-codes.md @@ -0,0 +1,18 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.createMfaRecoveryCodes(new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/account/verify-authenticator.md b/docs/examples/java/account/delete-mfa-authenticator.md similarity index 95% rename from docs/examples/java/account/verify-authenticator.md rename to docs/examples/java/account/delete-mfa-authenticator.md index c73ac43..e821930 100644 --- a/docs/examples/java/account/verify-authenticator.md +++ b/docs/examples/java/account/delete-mfa-authenticator.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); -account.verifyAuthenticator( +account.deleteMfaAuthenticator( AuthenticatorType.TOTP, // type "", // otp new CoroutineCallback<>((result, error) -> { diff --git a/docs/examples/java/account/get-mfa-recovery-codes.md b/docs/examples/java/account/get-mfa-recovery-codes.md new file mode 100644 index 0000000..14e5023 --- /dev/null +++ b/docs/examples/java/account/get-mfa-recovery-codes.md @@ -0,0 +1,18 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.getMfaRecoveryCodes(new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/account/list-factors.md b/docs/examples/java/account/list-mfa-factors.md similarity index 86% rename from docs/examples/java/account/list-factors.md rename to docs/examples/java/account/list-mfa-factors.md index e2d92b5..e1a6fa6 100644 --- a/docs/examples/java/account/list-factors.md +++ b/docs/examples/java/account/list-mfa-factors.md @@ -8,7 +8,7 @@ Client client = new Client(context) Account account = new Account(client); -account.listFactors(new CoroutineCallback<>((result, error) -> { +account.listMfaFactors(new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); return; diff --git a/docs/examples/java/account/delete-authenticator.md b/docs/examples/java/account/update-mfa-authenticator.md similarity index 95% rename from docs/examples/java/account/delete-authenticator.md rename to docs/examples/java/account/update-mfa-authenticator.md index c988cfa..44bb7f0 100644 --- a/docs/examples/java/account/delete-authenticator.md +++ b/docs/examples/java/account/update-mfa-authenticator.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); -account.deleteAuthenticator( +account.updateMfaAuthenticator( AuthenticatorType.TOTP, // type "", // otp new CoroutineCallback<>((result, error) -> { diff --git a/docs/examples/java/account/update-challenge.md b/docs/examples/java/account/update-mfa-challenge.md similarity index 95% rename from docs/examples/java/account/update-challenge.md rename to docs/examples/java/account/update-mfa-challenge.md index b2953e3..e30c733 100644 --- a/docs/examples/java/account/update-challenge.md +++ b/docs/examples/java/account/update-mfa-challenge.md @@ -8,7 +8,7 @@ Client client = new Client(context) Account account = new Account(client); -account.updateChallenge( +account.updateMfaChallenge( "", // challengeId "", // otp new CoroutineCallback<>((result, error) -> { diff --git a/docs/examples/java/account/update-mfa-recovery-codes.md b/docs/examples/java/account/update-mfa-recovery-codes.md new file mode 100644 index 0000000..880d478 --- /dev/null +++ b/docs/examples/java/account/update-mfa-recovery-codes.md @@ -0,0 +1,18 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + +Account account = new Account(client); + +account.updateMfaRecoveryCodes(new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/kotlin/account/add-authenticator.md b/docs/examples/kotlin/account/create-mfa-authenticator.md similarity index 89% rename from docs/examples/kotlin/account/add-authenticator.md rename to docs/examples/kotlin/account/create-mfa-authenticator.md index f96c175..f2ff748 100644 --- a/docs/examples/kotlin/account/add-authenticator.md +++ b/docs/examples/kotlin/account/create-mfa-authenticator.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) -val result = account.addAuthenticator( +val result = account.createMfaAuthenticator( type = AuthenticatorType.TOTP, ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-challenge.md b/docs/examples/kotlin/account/create-mfa-challenge.md similarity index 80% rename from docs/examples/kotlin/account/create-challenge.md rename to docs/examples/kotlin/account/create-mfa-challenge.md index 1018b96..d43aa39 100644 --- a/docs/examples/kotlin/account/create-challenge.md +++ b/docs/examples/kotlin/account/create-mfa-challenge.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) -val result = account.createChallenge( - factor = AuthenticationFactor.TOTP, +val result = account.createMfaChallenge( + factor = AuthenticationFactor.EMAIL, ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-mfa-recovery-codes.md b/docs/examples/kotlin/account/create-mfa-recovery-codes.md new file mode 100644 index 0000000..be25e74 --- /dev/null +++ b/docs/examples/kotlin/account/create-mfa-recovery-codes.md @@ -0,0 +1,11 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val result = account.createMfaRecoveryCodes() diff --git a/docs/examples/kotlin/account/verify-authenticator.md b/docs/examples/kotlin/account/delete-mfa-authenticator.md similarity index 89% rename from docs/examples/kotlin/account/verify-authenticator.md rename to docs/examples/kotlin/account/delete-mfa-authenticator.md index 9c306d4..c07afd0 100644 --- a/docs/examples/kotlin/account/verify-authenticator.md +++ b/docs/examples/kotlin/account/delete-mfa-authenticator.md @@ -9,7 +9,7 @@ val client = Client(context) val account = Account(client) -val result = account.verifyAuthenticator( +val result = account.deleteMfaAuthenticator( type = AuthenticatorType.TOTP, otp = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/get-mfa-recovery-codes.md b/docs/examples/kotlin/account/get-mfa-recovery-codes.md new file mode 100644 index 0000000..4a1652c --- /dev/null +++ b/docs/examples/kotlin/account/get-mfa-recovery-codes.md @@ -0,0 +1,11 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val result = account.getMfaRecoveryCodes() diff --git a/docs/examples/kotlin/account/list-factors.md b/docs/examples/kotlin/account/list-mfa-factors.md similarity index 88% rename from docs/examples/kotlin/account/list-factors.md rename to docs/examples/kotlin/account/list-mfa-factors.md index 05ba2b8..9f8572c 100644 --- a/docs/examples/kotlin/account/list-factors.md +++ b/docs/examples/kotlin/account/list-mfa-factors.md @@ -8,4 +8,4 @@ val client = Client(context) val account = Account(client) -val result = account.listFactors() +val result = account.listMfaFactors() diff --git a/docs/examples/kotlin/account/delete-authenticator.md b/docs/examples/kotlin/account/update-mfa-authenticator.md similarity index 89% rename from docs/examples/kotlin/account/delete-authenticator.md rename to docs/examples/kotlin/account/update-mfa-authenticator.md index bc532b8..8b19680 100644 --- a/docs/examples/kotlin/account/delete-authenticator.md +++ b/docs/examples/kotlin/account/update-mfa-authenticator.md @@ -9,7 +9,7 @@ val client = Client(context) val account = Account(client) -val result = account.deleteAuthenticator( +val result = account.updateMfaAuthenticator( type = AuthenticatorType.TOTP, otp = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-challenge.md b/docs/examples/kotlin/account/update-mfa-challenge.md similarity index 89% rename from docs/examples/kotlin/account/update-challenge.md rename to docs/examples/kotlin/account/update-mfa-challenge.md index 2a82bfb..fe4cb1e 100644 --- a/docs/examples/kotlin/account/update-challenge.md +++ b/docs/examples/kotlin/account/update-mfa-challenge.md @@ -8,7 +8,7 @@ val client = Client(context) val account = Account(client) -val result = account.updateChallenge( +val result = account.updateMfaChallenge( challengeId = "", otp = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-mfa-recovery-codes.md b/docs/examples/kotlin/account/update-mfa-recovery-codes.md new file mode 100644 index 0000000..f39b7c6 --- /dev/null +++ b/docs/examples/kotlin/account/update-mfa-recovery-codes.md @@ -0,0 +1,11 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + +val account = Account(client) + +val result = account.updateMfaRecoveryCodes() diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 68e4233..4eb2557 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -83,7 +83,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "5.0.0-rc.6", + "x-sdk-version" to "5.0.0", "x-appwrite-response-format" to "1.5.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/enums/AuthenticationFactor.kt b/library/src/main/java/io/appwrite/enums/AuthenticationFactor.kt index 7aca6e5..cf294ca 100644 --- a/library/src/main/java/io/appwrite/enums/AuthenticationFactor.kt +++ b/library/src/main/java/io/appwrite/enums/AuthenticationFactor.kt @@ -3,12 +3,14 @@ package io.appwrite.enums import com.google.gson.annotations.SerializedName enum class AuthenticationFactor(val value: String) { - @SerializedName("totp") - TOTP("totp"), + @SerializedName("email") + EMAIL("email"), @SerializedName("phone") PHONE("phone"), - @SerializedName("email") - EMAIL("email"); + @SerializedName("totp") + TOTP("totp"), + @SerializedName("recoverycode") + RECOVERYCODE("recoverycode"); override fun toString() = value } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/Browser.kt b/library/src/main/java/io/appwrite/enums/Browser.kt index f71024a..9800111 100644 --- a/library/src/main/java/io/appwrite/enums/Browser.kt +++ b/library/src/main/java/io/appwrite/enums/Browser.kt @@ -6,11 +6,11 @@ enum class Browser(val value: String) { @SerializedName("aa") AVANT_BROWSER("aa"), @SerializedName("an") - ANDROID_WEB_VIEW_BETA("an"), + ANDROID_WEBVIEW_BETA("an"), @SerializedName("ch") GOOGLE_CHROME("ch"), @SerializedName("ci") - GOOGLE_CHROMEI_OS("ci"), + GOOGLE_CHROME_IOS("ci"), @SerializedName("cm") GOOGLE_CHROME_MOBILE("cm"), @SerializedName("cr") @@ -24,7 +24,7 @@ enum class Browser(val value: String) { @SerializedName("ps") MICROSOFT_EDGE("ps"), @SerializedName("oi") - MICROSOFT_EDGEI_OS("oi"), + MICROSOFT_EDGE_IOS("oi"), @SerializedName("om") OPERA_MINI("om"), @SerializedName("op") diff --git a/library/src/main/java/io/appwrite/enums/Flag.kt b/library/src/main/java/io/appwrite/enums/Flag.kt index af5889a..d389103 100644 --- a/library/src/main/java/io/appwrite/enums/Flag.kt +++ b/library/src/main/java/io/appwrite/enums/Flag.kt @@ -18,7 +18,7 @@ enum class Flag(val value: String) { @SerializedName("am") ARMENIA("am"), @SerializedName("ag") - ANTIGUAAND_BARBUDA("ag"), + ANTIGUA_AND_BARBUDA("ag"), @SerializedName("au") AUSTRALIA("au"), @SerializedName("at") @@ -42,7 +42,7 @@ enum class Flag(val value: String) { @SerializedName("bs") BAHAMAS("bs"), @SerializedName("ba") - BOSNIAAND_HERZEGOVINA("ba"), + BOSNIA_AND_HERZEGOVINA("ba"), @SerializedName("by") BELARUS("by"), @SerializedName("bz") @@ -70,13 +70,13 @@ enum class Flag(val value: String) { @SerializedName("cn") CHINA("cn"), @SerializedName("ci") - CTED_IVOIRE("ci"), + COTE_DIVOIRE("ci"), @SerializedName("cm") CAMEROON("cm"), @SerializedName("cd") - DEMOCRATIC_REPUBLICOFTHE_CONGO("cd"), + DEMOCRATIC_REPUBLIC_OF_THE_CONGO("cd"), @SerializedName("cg") - REPUBLICOFTHE_CONGO("cg"), + REPUBLIC_OF_THE_CONGO("cg"), @SerializedName("co") COLOMBIA("co"), @SerializedName("km") @@ -122,7 +122,7 @@ enum class Flag(val value: String) { @SerializedName("fr") FRANCE("fr"), @SerializedName("fm") - MICRONESIA_FEDERATED_STATESOF("fm"), + MICRONESIA_FEDERATED_STATES_OF("fm"), @SerializedName("ga") GABON("ga"), @SerializedName("gb") @@ -162,7 +162,7 @@ enum class Flag(val value: String) { @SerializedName("ie") IRELAND("ie"), @SerializedName("ir") - IRAN_ISLAMIC_REPUBLICOF("ir"), + IRAN_ISLAMIC_REPUBLIC_OF("ir"), @SerializedName("iq") IRAQ("iq"), @SerializedName("is") @@ -188,7 +188,7 @@ enum class Flag(val value: String) { @SerializedName("ki") KIRIBATI("ki"), @SerializedName("kn") - SAINT_KITTSAND_NEVIS("kn"), + SAINT_KITTS_AND_NEVIS("kn"), @SerializedName("kr") SOUTH_KOREA("kr"), @SerializedName("kw") @@ -322,7 +322,7 @@ enum class Flag(val value: String) { @SerializedName("ss") SOUTH_SUDAN("ss"), @SerializedName("st") - SAO_TOMEAND_PRINCIPE("st"), + SAO_TOME_AND_PRINCIPE("st"), @SerializedName("sr") SURINAME("sr"), @SerializedName("sk") @@ -352,7 +352,7 @@ enum class Flag(val value: String) { @SerializedName("to") TONGA("to"), @SerializedName("tt") - TRINIDADAND_TOBAGO("tt"), + TRINIDAD_AND_TOBAGO("tt"), @SerializedName("tn") TUNISIA("tn"), @SerializedName("tr") @@ -374,7 +374,7 @@ enum class Flag(val value: String) { @SerializedName("va") VATICAN_CITY("va"), @SerializedName("vc") - SAINT_VINCENTANDTHE_GRENADINES("vc"), + SAINT_VINCENT_AND_THE_GRENADINES("vc"), @SerializedName("ve") VENEZUELA("ve"), @SerializedName("vn") diff --git a/library/src/main/java/io/appwrite/enums/ImageGravity.kt b/library/src/main/java/io/appwrite/enums/ImageGravity.kt index 0e8325d..45f8d88 100644 --- a/library/src/main/java/io/appwrite/enums/ImageGravity.kt +++ b/library/src/main/java/io/appwrite/enums/ImageGravity.kt @@ -6,21 +6,21 @@ enum class ImageGravity(val value: String) { @SerializedName("center") CENTER("center"), @SerializedName("top-left") - TOPLEFT("top-left"), + TOP_LEFT("top-left"), @SerializedName("top") TOP("top"), @SerializedName("top-right") - TOPRIGHT("top-right"), + TOP_RIGHT("top-right"), @SerializedName("left") LEFT("left"), @SerializedName("right") RIGHT("right"), @SerializedName("bottom-left") - BOTTOMLEFT("bottom-left"), + BOTTOM_LEFT("bottom-left"), @SerializedName("bottom") BOTTOM("bottom"), @SerializedName("bottom-right") - BOTTOMRIGHT("bottom-right"); + BOTTOM_RIGHT("bottom-right"); override fun toString() = value } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/OAuthProvider.kt b/library/src/main/java/io/appwrite/enums/OAuthProvider.kt index 2b96d63..dc1b9b3 100644 --- a/library/src/main/java/io/appwrite/enums/OAuthProvider.kt +++ b/library/src/main/java/io/appwrite/enums/OAuthProvider.kt @@ -50,7 +50,7 @@ enum class OAuthProvider(val value: String) { @SerializedName("paypal") PAYPAL("paypal"), @SerializedName("paypalSandbox") - PAYPAL_SANDBOX("paypalSandbox"), + PAYPALSANDBOX("paypalSandbox"), @SerializedName("podio") PODIO("podio"), @SerializedName("salesforce") @@ -64,7 +64,7 @@ enum class OAuthProvider(val value: String) { @SerializedName("tradeshift") TRADESHIFT("tradeshift"), @SerializedName("tradeshiftBox") - TRADESHIFT_BOX("tradeshiftBox"), + TRADESHIFTBOX("tradeshiftBox"), @SerializedName("twitch") TWITCH("twitch"), @SerializedName("wordpress") diff --git a/library/src/main/java/io/appwrite/models/MfaRecoveryCodes.kt b/library/src/main/java/io/appwrite/models/MfaRecoveryCodes.kt new file mode 100644 index 0000000..ad8bc45 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/MfaRecoveryCodes.kt @@ -0,0 +1,30 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * MFA Recovery Codes + */ +data class MfaRecoveryCodes( + /** + * Recovery codes. + */ + @SerializedName("recoveryCodes") + val recoveryCodes: List, + +) { + fun toMap(): Map = mapOf( + "recoveryCodes" to recoveryCodes as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = MfaRecoveryCodes( + recoveryCodes = map["recoveryCodes"] as List, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/MfaType.kt b/library/src/main/java/io/appwrite/models/MfaType.kt index c3d8d53..9c784a9 100644 --- a/library/src/main/java/io/appwrite/models/MfaType.kt +++ b/library/src/main/java/io/appwrite/models/MfaType.kt @@ -7,12 +7,6 @@ import io.appwrite.extensions.jsonCast * MFAType */ data class MfaType( - /** - * Backup codes. - */ - @SerializedName("backups") - val backups: List, - /** * Secret token used for TOTP factor. */ @@ -27,7 +21,6 @@ data class MfaType( ) { fun toMap(): Map = mapOf( - "backups" to backups as Any, "secret" to secret as Any, "uri" to uri as Any, ) @@ -38,7 +31,6 @@ data class MfaType( fun from( map: Map, ) = MfaType( - backups = map["backups"] as List, secret = map["secret"] as String, uri = map["uri"] as String, ) diff --git a/library/src/main/java/io/appwrite/models/Session.kt b/library/src/main/java/io/appwrite/models/Session.kt index da71926..1eaed4d 100644 --- a/library/src/main/java/io/appwrite/models/Session.kt +++ b/library/src/main/java/io/appwrite/models/Session.kt @@ -169,6 +169,12 @@ data class Session( @SerializedName("secret") val secret: String, + /** + * Most recent date in ISO 8601 format when the session successfully passed MFA challenge. + */ + @SerializedName("mfaUpdatedAt") + val mfaUpdatedAt: String, + ) { fun toMap(): Map = mapOf( "\$id" to id as Any, @@ -198,6 +204,7 @@ data class Session( "current" to current as Any, "factors" to factors as Any, "secret" to secret as Any, + "mfaUpdatedAt" to mfaUpdatedAt as Any, ) companion object { @@ -233,6 +240,7 @@ data class Session( current = map["current"] as Boolean, factors = map["factors"] as List, secret = map["secret"] as String, + mfaUpdatedAt = map["mfaUpdatedAt"] as String, ) } } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/User.kt b/library/src/main/java/io/appwrite/models/User.kt index 4c776b9..095467a 100644 --- a/library/src/main/java/io/appwrite/models/User.kt +++ b/library/src/main/java/io/appwrite/models/User.kt @@ -103,12 +103,6 @@ data class User( @SerializedName("mfa") val mfa: Boolean, - /** - * TOTP status. - */ - @SerializedName("totp") - val totp: Boolean, - /** * User preferences as a key-value object */ @@ -145,7 +139,6 @@ data class User( "emailVerification" to emailVerification as Any, "phoneVerification" to phoneVerification as Any, "mfa" to mfa as Any, - "totp" to totp as Any, "prefs" to prefs.toMap() as Any, "targets" to targets.map { it.toMap() } as Any, "accessedAt" to accessedAt as Any, @@ -169,7 +162,6 @@ data class User( emailVerification: Boolean, phoneVerification: Boolean, mfa: Boolean, - totp: Boolean, prefs: Preferences>, targets: List, accessedAt: String, @@ -190,7 +182,6 @@ data class User( emailVerification, phoneVerification, mfa, - totp, prefs, targets, accessedAt, @@ -217,7 +208,6 @@ data class User( emailVerification = map["emailVerification"] as Boolean, phoneVerification = map["phoneVerification"] as Boolean, mfa = map["mfa"] as Boolean, - totp = map["totp"] as Boolean, prefs = Preferences.from(map = map["prefs"] as Map, nestedType), targets = (map["targets"] as List>).map { Target.from(map = it) }, accessedAt = map["accessedAt"] as String, diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 0abdfd2..c4204c0 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -369,15 +369,161 @@ class Account(client: Client) : Service(client) { nestedType = classOf(), ) + /** + * Add Authenticator + * + * Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#verifyAuthenticator) method. + * + * @param type Type of authenticator. Must be `totp` + * @return [io.appwrite.models.MfaType] + */ + suspend fun createMfaAuthenticator( + type: AuthenticatorType, + ): io.appwrite.models.MfaType { + val apiPath = "/account/mfa/authenticators/{type}" + .replace("{type}", type.value) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.MfaType = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.MfaType.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.MfaType::class.java, + converter, + ) + } + + + /** + * Verify Authenticator + * + * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#addAuthenticator) method. + * + * @param type Type of authenticator. + * @param otp Valid verification token. + * @return [io.appwrite.models.User] + */ + suspend fun updateMfaAuthenticator( + type: AuthenticatorType, + otp: String, + nestedType: Class, + ): io.appwrite.models.User { + val apiPath = "/account/mfa/authenticators/{type}" + .replace("{type}", type.value) + + val apiParams = mutableMapOf( + "otp" to otp, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.User.from(map = it as Map, nestedType) + } + return client.call( + "PUT", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Verify Authenticator + * + * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#addAuthenticator) method. + * + * @param type Type of authenticator. + * @param otp Valid verification token. + * @return [io.appwrite.models.User] + */ + @Throws(AppwriteException::class) + suspend fun updateMfaAuthenticator( + type: AuthenticatorType, + otp: String, + ): io.appwrite.models.User> = updateMfaAuthenticator( + type, + otp, + nestedType = classOf(), + ) + + /** + * Delete Authenticator + * + * Delete an authenticator for a user by ID. + * + * @param type Type of authenticator. + * @param otp Valid verification token. + * @return [io.appwrite.models.User] + */ + suspend fun deleteMfaAuthenticator( + type: AuthenticatorType, + otp: String, + nestedType: Class, + ): io.appwrite.models.User { + val apiPath = "/account/mfa/authenticators/{type}" + .replace("{type}", type.value) + + val apiParams = mutableMapOf( + "otp" to otp, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.User.from(map = it as Map, nestedType) + } + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Delete Authenticator + * + * Delete an authenticator for a user by ID. + * + * @param type Type of authenticator. + * @param otp Valid verification token. + * @return [io.appwrite.models.User] + */ + @Throws(AppwriteException::class) + suspend fun deleteMfaAuthenticator( + type: AuthenticatorType, + otp: String, + ): io.appwrite.models.User> = deleteMfaAuthenticator( + type, + otp, + nestedType = classOf(), + ) + /** * Create 2FA Challenge * - * + * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. * - * @param factor Factor used for verification. + * @param factor Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`. * @return [io.appwrite.models.MfaChallenge] */ - suspend fun createChallenge( + suspend fun createMfaChallenge( factor: AuthenticationFactor, ): io.appwrite.models.MfaChallenge { val apiPath = "/account/mfa/challenge" @@ -406,13 +552,13 @@ class Account(client: Client) : Service(client) { /** * Create MFA Challenge (confirmation) * - * Complete the MFA challenge by providing the one-time password. + * Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. * * @param challengeId ID of the challenge. * @param otp Valid verification token. * @return [Any] */ - suspend fun updateChallenge( + suspend fun updateMfaChallenge( challengeId: String, otp: String, ): Any { @@ -442,7 +588,7 @@ class Account(client: Client) : Service(client) { * * @return [io.appwrite.models.MfaFactors] */ - suspend fun listFactors( + suspend fun listMfaFactors( ): io.appwrite.models.MfaFactors { val apiPath = "/account/mfa/factors" @@ -467,150 +613,97 @@ class Account(client: Client) : Service(client) { /** - * Add Authenticator + * Get MFA Recovery Codes * - * Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#verifyAuthenticator) method. + * Get recovery codes that can be used as backup for MFA flow. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to read recovery codes. * - * @param type Type of authenticator. - * @return [io.appwrite.models.MfaType] + * @return [io.appwrite.models.MfaRecoveryCodes] */ - suspend fun addAuthenticator( - type: AuthenticatorType, - ): io.appwrite.models.MfaType { - val apiPath = "/account/mfa/{type}" - .replace("{type}", type.value) + suspend fun getMfaRecoveryCodes( + ): io.appwrite.models.MfaRecoveryCodes { + val apiPath = "/account/mfa/recovery-codes" val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.MfaType = { + val converter: (Any) -> io.appwrite.models.MfaRecoveryCodes = { @Suppress("UNCHECKED_CAST") - io.appwrite.models.MfaType.from(map = it as Map) + io.appwrite.models.MfaRecoveryCodes.from(map = it as Map) } return client.call( - "POST", + "GET", apiPath, apiHeaders, apiParams, - responseType = io.appwrite.models.MfaType::class.java, + responseType = io.appwrite.models.MfaRecoveryCodes::class.java, converter, ) } /** - * Verify Authenticator + * Create MFA Recovery Codes * - * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#addAuthenticator) method. + * Generate recovery codes as backup for MFA flow. It's recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. * - * @param type Type of authenticator. - * @param otp Valid verification token. - * @return [io.appwrite.models.User] + * @return [io.appwrite.models.MfaRecoveryCodes] */ - suspend fun verifyAuthenticator( - type: AuthenticatorType, - otp: String, - nestedType: Class, - ): io.appwrite.models.User { - val apiPath = "/account/mfa/{type}" - .replace("{type}", type.value) + suspend fun createMfaRecoveryCodes( + ): io.appwrite.models.MfaRecoveryCodes { + val apiPath = "/account/mfa/recovery-codes" val apiParams = mutableMapOf( - "otp" to otp, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.User = { + val converter: (Any) -> io.appwrite.models.MfaRecoveryCodes = { @Suppress("UNCHECKED_CAST") - io.appwrite.models.User.from(map = it as Map, nestedType) + io.appwrite.models.MfaRecoveryCodes.from(map = it as Map) } return client.call( - "PUT", + "POST", apiPath, apiHeaders, apiParams, - responseType = classOf(), + responseType = io.appwrite.models.MfaRecoveryCodes::class.java, converter, ) } - /** - * Verify Authenticator - * - * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#addAuthenticator) method. - * - * @param type Type of authenticator. - * @param otp Valid verification token. - * @return [io.appwrite.models.User] - */ - @Throws(AppwriteException::class) - suspend fun verifyAuthenticator( - type: AuthenticatorType, - otp: String, - ): io.appwrite.models.User> = verifyAuthenticator( - type, - otp, - nestedType = classOf(), - ) /** - * Delete Authenticator + * Regenerate MFA Recovery Codes * - * Delete an authenticator for a user by ID. + * Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes. * - * @param type Type of authenticator. - * @param otp Valid verification token. - * @return [io.appwrite.models.User] + * @return [io.appwrite.models.MfaRecoveryCodes] */ - suspend fun deleteAuthenticator( - type: AuthenticatorType, - otp: String, - nestedType: Class, - ): io.appwrite.models.User { - val apiPath = "/account/mfa/{type}" - .replace("{type}", type.value) + suspend fun updateMfaRecoveryCodes( + ): io.appwrite.models.MfaRecoveryCodes { + val apiPath = "/account/mfa/recovery-codes" val apiParams = mutableMapOf( - "otp" to otp, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.User = { + val converter: (Any) -> io.appwrite.models.MfaRecoveryCodes = { @Suppress("UNCHECKED_CAST") - io.appwrite.models.User.from(map = it as Map, nestedType) + io.appwrite.models.MfaRecoveryCodes.from(map = it as Map) } return client.call( - "DELETE", + "PATCH", apiPath, apiHeaders, apiParams, - responseType = classOf(), + responseType = io.appwrite.models.MfaRecoveryCodes::class.java, converter, ) } - /** - * Delete Authenticator - * - * Delete an authenticator for a user by ID. - * - * @param type Type of authenticator. - * @param otp Valid verification token. - * @return [io.appwrite.models.User] - */ - @Throws(AppwriteException::class) - suspend fun deleteAuthenticator( - type: AuthenticatorType, - otp: String, - ): io.appwrite.models.User> = deleteAuthenticator( - type, - otp, - nestedType = classOf(), - ) /** * Update name @@ -1290,9 +1383,9 @@ class Account(client: Client) : Service(client) { /** - * Update (or renew) session + * Update session * - * Extend session's expiry to increase it's lifespan. Extending a session is useful when session length is short such as 5 minutes. + * Use this endpoint to extend a session's length. Extending a session is useful when session expiry is short. If the session was created using an OAuth provider, this endpoint refreshes the access token from the provider. * * @param sessionId Session ID. Use the string 'current' to update the current device session. * @return [io.appwrite.models.Session] From 354ebb7989aeeed4aa4bda00b7a66e7a5b506556 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 8 Mar 2024 14:51:27 +0100 Subject: [PATCH 069/118] Appwrite 1.5 support --- .../main/java/io/appwrite/services/Account.kt | 16 ++++++++-------- .../main/java/io/appwrite/services/Avatars.kt | 6 +++--- .../main/java/io/appwrite/services/Functions.kt | 2 +- .../main/java/io/appwrite/services/Storage.kt | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index c4204c0..46d5c42 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -378,7 +378,7 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.MfaType] */ suspend fun createMfaAuthenticator( - type: AuthenticatorType, + type: io.appwrite.enums.AuthenticatorType, ): io.appwrite.models.MfaType { val apiPath = "/account/mfa/authenticators/{type}" .replace("{type}", type.value) @@ -413,7 +413,7 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.User] */ suspend fun updateMfaAuthenticator( - type: AuthenticatorType, + type: io.appwrite.enums.AuthenticatorType, otp: String, nestedType: Class, ): io.appwrite.models.User { @@ -451,7 +451,7 @@ class Account(client: Client) : Service(client) { */ @Throws(AppwriteException::class) suspend fun updateMfaAuthenticator( - type: AuthenticatorType, + type: io.appwrite.enums.AuthenticatorType, otp: String, ): io.appwrite.models.User> = updateMfaAuthenticator( type, @@ -469,7 +469,7 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.User] */ suspend fun deleteMfaAuthenticator( - type: AuthenticatorType, + type: io.appwrite.enums.AuthenticatorType, otp: String, nestedType: Class, ): io.appwrite.models.User { @@ -507,7 +507,7 @@ class Account(client: Client) : Service(client) { */ @Throws(AppwriteException::class) suspend fun deleteMfaAuthenticator( - type: AuthenticatorType, + type: io.appwrite.enums.AuthenticatorType, otp: String, ): io.appwrite.models.User> = deleteMfaAuthenticator( type, @@ -524,7 +524,7 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.MfaChallenge] */ suspend fun createMfaChallenge( - factor: AuthenticationFactor, + factor: io.appwrite.enums.AuthenticationFactor, ): io.appwrite.models.MfaChallenge { val apiPath = "/account/mfa/challenge" @@ -1215,7 +1215,7 @@ class Account(client: Client) : Service(client) { @JvmOverloads suspend fun createOAuth2Session( activity: ComponentActivity, - provider: OAuthProvider, + provider: io.appwrite.enums.OAuthProvider, success: String? = null, failure: String? = null, scopes: List? = null, @@ -1694,7 +1694,7 @@ class Account(client: Client) : Service(client) { @JvmOverloads suspend fun createOAuth2Token( activity: ComponentActivity, - provider: OAuthProvider, + provider: io.appwrite.enums.OAuthProvider, success: String? = null, failure: String? = null, scopes: List? = null, diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt index e70fcda..09acfb9 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -30,7 +30,7 @@ class Avatars(client: Client) : Service(client) { */ @JvmOverloads suspend fun getBrowser( - code: Browser, + code: io.appwrite.enums.Browser, width: Long? = null, height: Long? = null, quality: Long? = null, @@ -66,7 +66,7 @@ class Avatars(client: Client) : Service(client) { */ @JvmOverloads suspend fun getCreditCard( - code: CreditCard, + code: io.appwrite.enums.CreditCard, width: Long? = null, height: Long? = null, quality: Long? = null, @@ -128,7 +128,7 @@ class Avatars(client: Client) : Service(client) { */ @JvmOverloads suspend fun getFlag( - code: Flag, + code: io.appwrite.enums.Flag, width: Long? = null, height: Long? = null, quality: Long? = null, diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index d6cd35f..c7a81ad 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -75,7 +75,7 @@ class Functions(client: Client) : Service(client) { body: String? = null, async: Boolean? = null, path: String? = null, - method: ExecutionMethod? = null, + method: io.appwrite.enums.ExecutionMethod? = null, headers: Any? = null, ): io.appwrite.models.Execution { val apiPath = "/functions/{functionId}/executions" diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index 8407f3d..80dd45b 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -275,7 +275,7 @@ class Storage(client: Client) : Service(client) { fileId: String, width: Long? = null, height: Long? = null, - gravity: ImageGravity? = null, + gravity: io.appwrite.enums.ImageGravity? = null, quality: Long? = null, borderWidth: Long? = null, borderColor: String? = null, @@ -283,7 +283,7 @@ class Storage(client: Client) : Service(client) { opacity: Double? = null, rotation: Long? = null, background: String? = null, - output: ImageFormat? = null, + output: io.appwrite.enums.ImageFormat? = null, ): ByteArray { val apiPath = "/storage/buckets/{bucketId}/files/{fileId}/preview" .replace("{bucketId}", bucketId) From 8869bc9e174bfa64ad5abefd2d392deb725dd46a Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Sat, 9 Mar 2024 18:09:30 +0100 Subject: [PATCH 070/118] Fix publish --- README.md | 2 +- scripts/publish-module.gradle | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d2e0903..67a7e52 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![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.5.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.5.1-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) diff --git a/scripts/publish-module.gradle b/scripts/publish-module.gradle index 96b31b2..ca97b16 100644 --- a/scripts/publish-module.gradle +++ b/scripts/publish-module.gradle @@ -8,7 +8,6 @@ tasks.register("sourcesJar", Jar) { tasks.register("javadoc", Javadoc) { source = android.sourceSets.getByName("main").java.srcDirs - classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) setDestinationDir(file("../javadoc/")) failOnError false } @@ -19,6 +18,10 @@ tasks.register("javadocJar", Jar) { from(javadoc) } +afterEvaluate { + tasks.javadoc.classpath += files(project.android.getBootClasspath()) +} + publishing { publications { release(MavenPublication) { From 3017598d1ca9a876989099a934b7f373186701ca Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 24 Apr 2024 19:28:09 +1200 Subject: [PATCH 071/118] Fix okttp with AGP 8.2+ --- README.md | 6 ++-- library/build.gradle | 5 +-- library/src/main/java/io/appwrite/Client.kt | 2 +- library/src/main/java/io/appwrite/ID.kt | 30 +++++++++++++++-- .../java/io/appwrite/models/MfaFactors.kt | 14 ++++++-- .../main/java/io/appwrite/models/Session.kt | 8 +++++ .../main/java/io/appwrite/services/Account.kt | 32 +++---------------- 7 files changed, 55 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 67a7e52..57a4335 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![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.5.1-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.5.4-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) @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:5.0.0") +implementation("io.appwrite:sdk-for-android:5.0.1") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 5.0.0 + 5.0.1 ``` diff --git a/library/build.gradle b/library/build.gradle index b741c76..998da2b 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -59,10 +59,7 @@ dependencies { api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1") api("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1") - api(platform("com.squareup.okhttp3:okhttp-bom:4.12.0")) - api("com.squareup.okhttp3:okhttp") - implementation("com.squareup.okhttp3:okhttp-urlconnection") - implementation("com.squareup.okhttp3:logging-interceptor") + implementation("com.squareup.okhttp3:okhttp:4.12.0") implementation("com.google.code.gson:gson:2.10.1") implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0") diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 4eb2557..f2db946 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -83,7 +83,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "5.0.0", + "x-sdk-version" to "5.0.1", "x-appwrite-response-format" to "1.5.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/ID.kt b/library/src/main/java/io/appwrite/ID.kt index fe8e656..e661192 100644 --- a/library/src/main/java/io/appwrite/ID.kt +++ b/library/src/main/java/io/appwrite/ID.kt @@ -1,10 +1,34 @@ package io.appwrite +import java.time.Instant +import kotlin.math.floor +import kotlin.random.Random + class ID { companion object { + // Generate an hex ID based on timestamp + // Recreated from https://www.php.net/manual/en/function.uniqid.php + private fun hexTimestamp(): String { + val now = Instant.now() + val sec = now.epochSecond + val usec = (System.nanoTime() / 1000) % 1000 + + val hexTimestamp = "%08x%05x".format(sec, usec) + + return hexTimestamp + } + fun custom(id: String): String = id - fun unique(): String - = "unique()" + + // Generate a unique ID with padding to have a longer ID + fun unique(padding: Int = 7): String { + val baseId = hexTimestamp() + val randomPadding = (1..padding) + .map { Random.nextInt(0, 16).toString(16) } + .joinToString("") + + return baseId + randomPadding + } } -} \ No newline at end of file +} diff --git a/library/src/main/java/io/appwrite/models/MfaFactors.kt b/library/src/main/java/io/appwrite/models/MfaFactors.kt index 904a10b..ddde40c 100644 --- a/library/src/main/java/io/appwrite/models/MfaFactors.kt +++ b/library/src/main/java/io/appwrite/models/MfaFactors.kt @@ -8,28 +8,35 @@ import io.appwrite.extensions.jsonCast */ data class MfaFactors( /** - * TOTP + * Can TOTP be used for MFA challenge for this account. */ @SerializedName("totp") val totp: Boolean, /** - * Phone + * Can phone (SMS) be used for MFA challenge for this account. */ @SerializedName("phone") val phone: Boolean, /** - * Email + * Can email be used for MFA challenge for this account. */ @SerializedName("email") val email: Boolean, + /** + * Can recovery code be used for MFA challenge for this account. + */ + @SerializedName("recoveryCode") + val recoveryCode: Boolean, + ) { fun toMap(): Map = mapOf( "totp" to totp as Any, "phone" to phone as Any, "email" to email as Any, + "recoveryCode" to recoveryCode as Any, ) companion object { @@ -41,6 +48,7 @@ data class MfaFactors( totp = map["totp"] as Boolean, phone = map["phone"] as Boolean, email = map["email"] as Boolean, + recoveryCode = map["recoveryCode"] as Boolean, ) } } \ 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 1eaed4d..1c6a7b2 100644 --- a/library/src/main/java/io/appwrite/models/Session.kt +++ b/library/src/main/java/io/appwrite/models/Session.kt @@ -19,6 +19,12 @@ data class Session( @SerializedName("\$createdAt") val createdAt: String, + /** + * Session update date in ISO 8601 format. + */ + @SerializedName("\$updatedAt") + val updatedAt: String, + /** * User ID. */ @@ -179,6 +185,7 @@ data class Session( fun toMap(): Map = mapOf( "\$id" to id as Any, "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, "userId" to userId as Any, "expire" to expire as Any, "provider" to provider as Any, @@ -215,6 +222,7 @@ data class Session( ) = Session( id = map["\$id"] as String, createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, userId = map["userId"] as String, expire = map["expire"] as String, provider = map["provider"] as String, diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 46d5c42..1b8457e 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -466,13 +466,12 @@ class Account(client: Client) : Service(client) { * * @param type Type of authenticator. * @param otp Valid verification token. - * @return [io.appwrite.models.User] + * @return [Any] */ - suspend fun deleteMfaAuthenticator( + suspend fun deleteMfaAuthenticator( type: io.appwrite.enums.AuthenticatorType, otp: String, - nestedType: Class, - ): io.appwrite.models.User { + ): Any { val apiPath = "/account/mfa/authenticators/{type}" .replace("{type}", type.value) @@ -482,38 +481,15 @@ class Account(client: Client) : Service(client) { val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.User = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.User.from(map = it as Map, nestedType) - } return client.call( "DELETE", apiPath, apiHeaders, apiParams, - responseType = classOf(), - converter, + responseType = Any::class.java, ) } - /** - * Delete Authenticator - * - * Delete an authenticator for a user by ID. - * - * @param type Type of authenticator. - * @param otp Valid verification token. - * @return [io.appwrite.models.User] - */ - @Throws(AppwriteException::class) - suspend fun deleteMfaAuthenticator( - type: io.appwrite.enums.AuthenticatorType, - otp: String, - ): io.appwrite.models.User> = deleteMfaAuthenticator( - type, - otp, - nestedType = classOf(), - ) /** * Create 2FA Challenge From 8ef821bd360f088fb01d2a51ee101925b27e9d78 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 24 Apr 2024 19:35:03 +1200 Subject: [PATCH 072/118] Bump minor version for other changes --- README.md | 4 ++-- library/src/main/java/io/appwrite/Client.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 57a4335..5a41187 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:5.0.1") +implementation("io.appwrite:sdk-for-android:5.1.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 5.0.1 + 5.1.0 ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index f2db946..5240d60 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -83,7 +83,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "5.0.1", + "x-sdk-version" to "5.1.0", "x-appwrite-response-format" to "1.5.0" ) config = mutableMapOf() From 0a121fb03ec28f7b771e3950e118d530ab56d344 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Fri, 17 May 2024 04:27:49 +0000 Subject: [PATCH 073/118] fix: minor bugs --- README.md | 6 +++--- library/src/main/java/io/appwrite/Client.kt | 2 +- library/src/main/java/io/appwrite/enums/CreditCard.kt | 4 ++-- library/src/main/java/io/appwrite/enums/Flag.kt | 2 ++ library/src/main/java/io/appwrite/services/Account.kt | 6 +++--- library/src/main/java/io/appwrite/services/Avatars.kt | 2 +- library/src/main/java/io/appwrite/services/Realtime.kt | 2 ++ 7 files changed, 14 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 5a41187..b966b5b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![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.5.4-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.5.6-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) @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:5.1.0") +implementation("io.appwrite:sdk-for-android:5.0.1") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 5.1.0 + 5.0.1 ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 5240d60..f2db946 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -83,7 +83,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "5.1.0", + "x-sdk-version" to "5.0.1", "x-appwrite-response-format" to "1.5.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/enums/CreditCard.kt b/library/src/main/java/io/appwrite/enums/CreditCard.kt index 7224778..063de61 100644 --- a/library/src/main/java/io/appwrite/enums/CreditCard.kt +++ b/library/src/main/java/io/appwrite/enums/CreditCard.kt @@ -9,8 +9,8 @@ enum class CreditCard(val value: String) { ARGENCARD("argencard"), @SerializedName("cabal") CABAL("cabal"), - @SerializedName("censosud") - CONSOSUD("censosud"), + @SerializedName("cencosud") + CENCOSUD("cencosud"), @SerializedName("diners") DINERS_CLUB("diners"), @SerializedName("discover") diff --git a/library/src/main/java/io/appwrite/enums/Flag.kt b/library/src/main/java/io/appwrite/enums/Flag.kt index d389103..e4be0b8 100644 --- a/library/src/main/java/io/appwrite/enums/Flag.kt +++ b/library/src/main/java/io/appwrite/enums/Flag.kt @@ -285,6 +285,8 @@ enum class Flag(val value: String) { PAPUA_NEW_GUINEA("pg"), @SerializedName("pl") POLAND("pl"), + @SerializedName("pf") + FRENCH_POLYNESIA("pf"), @SerializedName("kp") NORTH_KOREA("kp"), @SerializedName("pt") diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 1b8457e..95dd107 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -372,7 +372,7 @@ class Account(client: Client) : Service(client) { /** * Add Authenticator * - * Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#verifyAuthenticator) method. + * Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. * * @param type Type of authenticator. Must be `totp` * @return [io.appwrite.models.MfaType] @@ -406,7 +406,7 @@ class Account(client: Client) : Service(client) { /** * Verify Authenticator * - * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#addAuthenticator) method. + * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. add * * @param type Type of authenticator. * @param otp Valid verification token. @@ -443,7 +443,7 @@ class Account(client: Client) : Service(client) { /** * Verify Authenticator * - * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#addAuthenticator) method. + * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. add * * @param type Type of authenticator. * @param otp Valid verification token. diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt index 09acfb9..2cb130d 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -58,7 +58,7 @@ class Avatars(client: Client) : Service(client) { * * 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 code Credit Card Code. Possible values: amex, argencard, cabal, cencosud, 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. diff --git a/library/src/main/java/io/appwrite/services/Realtime.kt b/library/src/main/java/io/appwrite/services/Realtime.kt index c2c7d9e..1bffd3a 100644 --- a/library/src/main/java/io/appwrite/services/Realtime.kt +++ b/library/src/main/java/io/appwrite/services/Realtime.kt @@ -44,6 +44,8 @@ class Realtime(client: Client) : Service(client), CoroutineScope { private fun createSocket() { if (activeChannels.isEmpty()) { + reconnect = false + closeSocket() return } From a1e71b4977a0a665ce2a60cf8722621dd9b8c097 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Fri, 17 May 2024 04:41:36 +0000 Subject: [PATCH 074/118] chore: bump version --- README.md | 4 ++-- library/src/main/java/io/appwrite/Client.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b966b5b..7a8e368 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:5.0.1") +implementation("io.appwrite:sdk-for-android:5.1.1") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 5.0.1 + 5.1.1 ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index f2db946..a27cf48 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -83,7 +83,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "5.0.1", + "x-sdk-version" to "5.1.1", "x-appwrite-response-format" to "1.5.0" ) config = mutableMapOf() From 421eca0fd44a03dfe83f82eaf3daca1b1df6f2e2 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 3 Jul 2024 17:59:42 +0200 Subject: [PATCH 075/118] feat: 1.6.x --- README.md | 4 ++-- docs/examples/java/account/create-anonymous-session.md | 2 +- .../java/account/create-email-password-session.md | 2 +- docs/examples/java/account/create-email-token.md | 2 +- docs/examples/java/account/create-j-w-t.md | 2 +- docs/examples/java/account/create-magic-u-r-l-token.md | 2 +- docs/examples/java/account/create-mfa-authenticator.md | 2 +- docs/examples/java/account/create-mfa-challenge.md | 2 +- docs/examples/java/account/create-mfa-recovery-codes.md | 2 +- docs/examples/java/account/create-o-auth2session.md | 2 +- docs/examples/java/account/create-o-auth2token.md | 2 +- docs/examples/java/account/create-phone-token.md | 2 +- docs/examples/java/account/create-phone-verification.md | 2 +- docs/examples/java/account/create-push-target.md | 2 +- docs/examples/java/account/create-recovery.md | 2 +- docs/examples/java/account/create-session.md | 2 +- docs/examples/java/account/create-verification.md | 2 +- docs/examples/java/account/create.md | 2 +- docs/examples/java/account/delete-identity.md | 2 +- docs/examples/java/account/delete-mfa-authenticator.md | 2 +- docs/examples/java/account/delete-push-target.md | 2 +- docs/examples/java/account/delete-session.md | 2 +- docs/examples/java/account/delete-sessions.md | 2 +- docs/examples/java/account/get-mfa-recovery-codes.md | 2 +- docs/examples/java/account/get-prefs.md | 2 +- docs/examples/java/account/get-session.md | 2 +- docs/examples/java/account/get.md | 2 +- docs/examples/java/account/list-identities.md | 2 +- docs/examples/java/account/list-logs.md | 2 +- docs/examples/java/account/list-mfa-factors.md | 2 +- docs/examples/java/account/list-sessions.md | 2 +- docs/examples/java/account/update-email.md | 2 +- docs/examples/java/account/update-m-f-a.md | 2 +- docs/examples/java/account/update-magic-u-r-l-session.md | 2 +- docs/examples/java/account/update-mfa-authenticator.md | 2 +- docs/examples/java/account/update-mfa-challenge.md | 2 +- docs/examples/java/account/update-mfa-recovery-codes.md | 2 +- docs/examples/java/account/update-name.md | 2 +- docs/examples/java/account/update-password.md | 2 +- docs/examples/java/account/update-phone-session.md | 2 +- docs/examples/java/account/update-phone-verification.md | 2 +- docs/examples/java/account/update-phone.md | 2 +- docs/examples/java/account/update-prefs.md | 2 +- docs/examples/java/account/update-push-target.md | 2 +- docs/examples/java/account/update-recovery.md | 2 +- docs/examples/java/account/update-session.md | 2 +- docs/examples/java/account/update-status.md | 2 +- docs/examples/java/account/update-verification.md | 2 +- docs/examples/java/avatars/get-browser.md | 2 +- docs/examples/java/avatars/get-credit-card.md | 2 +- docs/examples/java/avatars/get-favicon.md | 2 +- docs/examples/java/avatars/get-flag.md | 2 +- docs/examples/java/avatars/get-image.md | 2 +- docs/examples/java/avatars/get-initials.md | 2 +- docs/examples/java/avatars/get-q-r.md | 2 +- docs/examples/java/databases/create-document.md | 2 +- docs/examples/java/databases/delete-document.md | 2 +- docs/examples/java/databases/get-document.md | 2 +- docs/examples/java/databases/list-documents.md | 2 +- docs/examples/java/databases/update-document.md | 2 +- docs/examples/java/functions/create-execution.md | 3 ++- docs/examples/java/functions/get-execution.md | 2 +- docs/examples/java/functions/list-executions.md | 2 +- docs/examples/java/graphql/mutation.md | 2 +- docs/examples/java/graphql/query.md | 2 +- docs/examples/java/locale/get.md | 2 +- docs/examples/java/locale/list-codes.md | 2 +- docs/examples/java/locale/list-continents.md | 2 +- docs/examples/java/locale/list-countries-e-u.md | 2 +- docs/examples/java/locale/list-countries-phones.md | 2 +- docs/examples/java/locale/list-countries.md | 2 +- docs/examples/java/locale/list-currencies.md | 2 +- docs/examples/java/locale/list-languages.md | 2 +- docs/examples/java/messaging/create-subscriber.md | 2 +- docs/examples/java/messaging/delete-subscriber.md | 2 +- docs/examples/java/storage/create-file.md | 2 +- docs/examples/java/storage/delete-file.md | 2 +- docs/examples/java/storage/get-file-download.md | 2 +- docs/examples/java/storage/get-file-preview.md | 2 +- docs/examples/java/storage/get-file-view.md | 2 +- docs/examples/java/storage/get-file.md | 2 +- docs/examples/java/storage/list-files.md | 2 +- docs/examples/java/storage/update-file.md | 2 +- docs/examples/java/teams/create-membership.md | 2 +- docs/examples/java/teams/create.md | 2 +- docs/examples/java/teams/delete-membership.md | 2 +- docs/examples/java/teams/delete.md | 2 +- docs/examples/java/teams/get-membership.md | 2 +- docs/examples/java/teams/get-prefs.md | 2 +- docs/examples/java/teams/get.md | 2 +- docs/examples/java/teams/list-memberships.md | 2 +- docs/examples/java/teams/list.md | 2 +- docs/examples/java/teams/update-membership-status.md | 2 +- docs/examples/java/teams/update-membership.md | 2 +- docs/examples/java/teams/update-name.md | 2 +- docs/examples/java/teams/update-prefs.md | 2 +- docs/examples/kotlin/account/create-anonymous-session.md | 2 +- .../kotlin/account/create-email-password-session.md | 2 +- docs/examples/kotlin/account/create-email-token.md | 2 +- docs/examples/kotlin/account/create-j-w-t.md | 2 +- docs/examples/kotlin/account/create-magic-u-r-l-token.md | 2 +- docs/examples/kotlin/account/create-mfa-authenticator.md | 2 +- docs/examples/kotlin/account/create-mfa-challenge.md | 2 +- docs/examples/kotlin/account/create-mfa-recovery-codes.md | 2 +- docs/examples/kotlin/account/create-o-auth2session.md | 2 +- docs/examples/kotlin/account/create-o-auth2token.md | 2 +- docs/examples/kotlin/account/create-phone-token.md | 2 +- docs/examples/kotlin/account/create-phone-verification.md | 2 +- docs/examples/kotlin/account/create-push-target.md | 2 +- docs/examples/kotlin/account/create-recovery.md | 2 +- docs/examples/kotlin/account/create-session.md | 2 +- docs/examples/kotlin/account/create-verification.md | 2 +- docs/examples/kotlin/account/create.md | 2 +- docs/examples/kotlin/account/delete-identity.md | 2 +- docs/examples/kotlin/account/delete-mfa-authenticator.md | 2 +- docs/examples/kotlin/account/delete-push-target.md | 2 +- docs/examples/kotlin/account/delete-session.md | 2 +- docs/examples/kotlin/account/delete-sessions.md | 2 +- docs/examples/kotlin/account/get-mfa-recovery-codes.md | 2 +- docs/examples/kotlin/account/get-prefs.md | 2 +- docs/examples/kotlin/account/get-session.md | 2 +- docs/examples/kotlin/account/get.md | 2 +- docs/examples/kotlin/account/list-identities.md | 2 +- docs/examples/kotlin/account/list-logs.md | 2 +- docs/examples/kotlin/account/list-mfa-factors.md | 2 +- docs/examples/kotlin/account/list-sessions.md | 2 +- docs/examples/kotlin/account/update-email.md | 2 +- docs/examples/kotlin/account/update-m-f-a.md | 2 +- .../examples/kotlin/account/update-magic-u-r-l-session.md | 2 +- docs/examples/kotlin/account/update-mfa-authenticator.md | 2 +- docs/examples/kotlin/account/update-mfa-challenge.md | 2 +- docs/examples/kotlin/account/update-mfa-recovery-codes.md | 2 +- docs/examples/kotlin/account/update-name.md | 2 +- docs/examples/kotlin/account/update-password.md | 2 +- docs/examples/kotlin/account/update-phone-session.md | 2 +- docs/examples/kotlin/account/update-phone-verification.md | 2 +- docs/examples/kotlin/account/update-phone.md | 2 +- docs/examples/kotlin/account/update-prefs.md | 2 +- docs/examples/kotlin/account/update-push-target.md | 2 +- docs/examples/kotlin/account/update-recovery.md | 2 +- docs/examples/kotlin/account/update-session.md | 2 +- docs/examples/kotlin/account/update-status.md | 2 +- docs/examples/kotlin/account/update-verification.md | 2 +- docs/examples/kotlin/avatars/get-browser.md | 2 +- docs/examples/kotlin/avatars/get-credit-card.md | 2 +- docs/examples/kotlin/avatars/get-favicon.md | 2 +- docs/examples/kotlin/avatars/get-flag.md | 2 +- docs/examples/kotlin/avatars/get-image.md | 2 +- docs/examples/kotlin/avatars/get-initials.md | 2 +- docs/examples/kotlin/avatars/get-q-r.md | 2 +- docs/examples/kotlin/databases/create-document.md | 2 +- docs/examples/kotlin/databases/delete-document.md | 2 +- docs/examples/kotlin/databases/get-document.md | 2 +- docs/examples/kotlin/databases/list-documents.md | 2 +- docs/examples/kotlin/databases/update-document.md | 2 +- docs/examples/kotlin/functions/create-execution.md | 3 ++- docs/examples/kotlin/functions/get-execution.md | 2 +- docs/examples/kotlin/functions/list-executions.md | 2 +- docs/examples/kotlin/graphql/mutation.md | 2 +- docs/examples/kotlin/graphql/query.md | 2 +- docs/examples/kotlin/locale/get.md | 2 +- docs/examples/kotlin/locale/list-codes.md | 2 +- docs/examples/kotlin/locale/list-continents.md | 2 +- docs/examples/kotlin/locale/list-countries-e-u.md | 2 +- docs/examples/kotlin/locale/list-countries-phones.md | 2 +- docs/examples/kotlin/locale/list-countries.md | 2 +- docs/examples/kotlin/locale/list-currencies.md | 2 +- docs/examples/kotlin/locale/list-languages.md | 2 +- docs/examples/kotlin/messaging/create-subscriber.md | 2 +- docs/examples/kotlin/messaging/delete-subscriber.md | 2 +- docs/examples/kotlin/storage/create-file.md | 2 +- docs/examples/kotlin/storage/delete-file.md | 2 +- docs/examples/kotlin/storage/get-file-download.md | 2 +- docs/examples/kotlin/storage/get-file-preview.md | 2 +- docs/examples/kotlin/storage/get-file-view.md | 2 +- docs/examples/kotlin/storage/get-file.md | 2 +- docs/examples/kotlin/storage/list-files.md | 2 +- docs/examples/kotlin/storage/update-file.md | 2 +- docs/examples/kotlin/teams/create-membership.md | 2 +- docs/examples/kotlin/teams/create.md | 2 +- docs/examples/kotlin/teams/delete-membership.md | 2 +- docs/examples/kotlin/teams/delete.md | 2 +- docs/examples/kotlin/teams/get-membership.md | 2 +- docs/examples/kotlin/teams/get-prefs.md | 2 +- docs/examples/kotlin/teams/get.md | 2 +- docs/examples/kotlin/teams/list-memberships.md | 2 +- docs/examples/kotlin/teams/list.md | 2 +- docs/examples/kotlin/teams/update-membership-status.md | 2 +- docs/examples/kotlin/teams/update-membership.md | 2 +- docs/examples/kotlin/teams/update-name.md | 2 +- docs/examples/kotlin/teams/update-prefs.md | 2 +- library/src/main/java/io/appwrite/Client.kt | 8 ++++++++ library/src/main/java/io/appwrite/services/Account.kt | 6 +++--- library/src/main/java/io/appwrite/services/Functions.kt | 5 ++++- library/src/main/java/io/appwrite/services/Storage.kt | 2 +- library/src/main/java/io/appwrite/services/Teams.kt | 2 +- 196 files changed, 211 insertions(+), 198 deletions(-) diff --git a/README.md b/README.md index 7a8e368..6b559ef 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.5.6-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.5.7-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.5.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.6.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) diff --git a/docs/examples/java/account/create-anonymous-session.md b/docs/examples/java/account/create-anonymous-session.md index 46ae275..5475d1b 100644 --- a/docs/examples/java/account/create-anonymous-session.md +++ b/docs/examples/java/account/create-anonymous-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-email-password-session.md b/docs/examples/java/account/create-email-password-session.md index 85d460e..f4c59eb 100644 --- a/docs/examples/java/account/create-email-password-session.md +++ b/docs/examples/java/account/create-email-password-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-email-token.md b/docs/examples/java/account/create-email-token.md index adf8b3d..d1b91c9 100644 --- a/docs/examples/java/account/create-email-token.md +++ b/docs/examples/java/account/create-email-token.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-j-w-t.md b/docs/examples/java/account/create-j-w-t.md index 13e6e49..481259e 100644 --- a/docs/examples/java/account/create-j-w-t.md +++ b/docs/examples/java/account/create-j-w-t.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-magic-u-r-l-token.md b/docs/examples/java/account/create-magic-u-r-l-token.md index 21108cc..3c91e9b 100644 --- a/docs/examples/java/account/create-magic-u-r-l-token.md +++ b/docs/examples/java/account/create-magic-u-r-l-token.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-mfa-authenticator.md b/docs/examples/java/account/create-mfa-authenticator.md index cc64341..35ec26c 100644 --- a/docs/examples/java/account/create-mfa-authenticator.md +++ b/docs/examples/java/account/create-mfa-authenticator.md @@ -5,7 +5,7 @@ import io.appwrite.enums.AuthenticatorType; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-mfa-challenge.md b/docs/examples/java/account/create-mfa-challenge.md index a2c2aa4..f930b56 100644 --- a/docs/examples/java/account/create-mfa-challenge.md +++ b/docs/examples/java/account/create-mfa-challenge.md @@ -5,7 +5,7 @@ import io.appwrite.enums.AuthenticationFactor; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-mfa-recovery-codes.md b/docs/examples/java/account/create-mfa-recovery-codes.md index 8ed8573..48f8582 100644 --- a/docs/examples/java/account/create-mfa-recovery-codes.md +++ b/docs/examples/java/account/create-mfa-recovery-codes.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-o-auth2session.md b/docs/examples/java/account/create-o-auth2session.md index ba284a1..fafd8e1 100644 --- a/docs/examples/java/account/create-o-auth2session.md +++ b/docs/examples/java/account/create-o-auth2session.md @@ -5,7 +5,7 @@ import io.appwrite.enums.OAuthProvider; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-o-auth2token.md b/docs/examples/java/account/create-o-auth2token.md index eb64da1..72fe76e 100644 --- a/docs/examples/java/account/create-o-auth2token.md +++ b/docs/examples/java/account/create-o-auth2token.md @@ -5,7 +5,7 @@ import io.appwrite.enums.OAuthProvider; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-phone-token.md b/docs/examples/java/account/create-phone-token.md index 29ef311..92eeee8 100644 --- a/docs/examples/java/account/create-phone-token.md +++ b/docs/examples/java/account/create-phone-token.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-phone-verification.md b/docs/examples/java/account/create-phone-verification.md index ef14ce8..c560065 100644 --- a/docs/examples/java/account/create-phone-verification.md +++ b/docs/examples/java/account/create-phone-verification.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-push-target.md b/docs/examples/java/account/create-push-target.md index 7eff453..127aec0 100644 --- a/docs/examples/java/account/create-push-target.md +++ b/docs/examples/java/account/create-push-target.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-recovery.md b/docs/examples/java/account/create-recovery.md index 19006f6..09f8fb9 100644 --- a/docs/examples/java/account/create-recovery.md +++ b/docs/examples/java/account/create-recovery.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-session.md b/docs/examples/java/account/create-session.md index 013d372..f54f57c 100644 --- a/docs/examples/java/account/create-session.md +++ b/docs/examples/java/account/create-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-verification.md b/docs/examples/java/account/create-verification.md index 254a31b..c52ee2b 100644 --- a/docs/examples/java/account/create-verification.md +++ b/docs/examples/java/account/create-verification.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create.md b/docs/examples/java/account/create.md index 8ee1de3..15d9b73 100644 --- a/docs/examples/java/account/create.md +++ b/docs/examples/java/account/create.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/delete-identity.md b/docs/examples/java/account/delete-identity.md index 1d6922a..a84f57b 100644 --- a/docs/examples/java/account/delete-identity.md +++ b/docs/examples/java/account/delete-identity.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/delete-mfa-authenticator.md b/docs/examples/java/account/delete-mfa-authenticator.md index e821930..148f4e4 100644 --- a/docs/examples/java/account/delete-mfa-authenticator.md +++ b/docs/examples/java/account/delete-mfa-authenticator.md @@ -5,7 +5,7 @@ import io.appwrite.enums.AuthenticatorType; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/delete-push-target.md b/docs/examples/java/account/delete-push-target.md index 484fc2c..0b51801 100644 --- a/docs/examples/java/account/delete-push-target.md +++ b/docs/examples/java/account/delete-push-target.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/delete-session.md b/docs/examples/java/account/delete-session.md index 4344061..602752e 100644 --- a/docs/examples/java/account/delete-session.md +++ b/docs/examples/java/account/delete-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/delete-sessions.md b/docs/examples/java/account/delete-sessions.md index 147523e..8c48aaf 100644 --- a/docs/examples/java/account/delete-sessions.md +++ b/docs/examples/java/account/delete-sessions.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/get-mfa-recovery-codes.md b/docs/examples/java/account/get-mfa-recovery-codes.md index 14e5023..f42101c 100644 --- a/docs/examples/java/account/get-mfa-recovery-codes.md +++ b/docs/examples/java/account/get-mfa-recovery-codes.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/get-prefs.md b/docs/examples/java/account/get-prefs.md index bfa3c1a..6a40dc7 100644 --- a/docs/examples/java/account/get-prefs.md +++ b/docs/examples/java/account/get-prefs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/get-session.md b/docs/examples/java/account/get-session.md index 470f643..912a52d 100644 --- a/docs/examples/java/account/get-session.md +++ b/docs/examples/java/account/get-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/get.md b/docs/examples/java/account/get.md index 9006cb8..9a99a75 100644 --- a/docs/examples/java/account/get.md +++ b/docs/examples/java/account/get.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/list-identities.md b/docs/examples/java/account/list-identities.md index cb5f74e..38ccc92 100644 --- a/docs/examples/java/account/list-identities.md +++ b/docs/examples/java/account/list-identities.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/list-logs.md b/docs/examples/java/account/list-logs.md index 998d8a8..7f39d84 100644 --- a/docs/examples/java/account/list-logs.md +++ b/docs/examples/java/account/list-logs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/list-mfa-factors.md b/docs/examples/java/account/list-mfa-factors.md index e1a6fa6..f531988 100644 --- a/docs/examples/java/account/list-mfa-factors.md +++ b/docs/examples/java/account/list-mfa-factors.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/list-sessions.md b/docs/examples/java/account/list-sessions.md index 9e70f0d..6571458 100644 --- a/docs/examples/java/account/list-sessions.md +++ b/docs/examples/java/account/list-sessions.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-email.md b/docs/examples/java/account/update-email.md index 13c5b65..5e99b73 100644 --- a/docs/examples/java/account/update-email.md +++ b/docs/examples/java/account/update-email.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-m-f-a.md b/docs/examples/java/account/update-m-f-a.md index 7c774c7..f8420b0 100644 --- a/docs/examples/java/account/update-m-f-a.md +++ b/docs/examples/java/account/update-m-f-a.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); 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 339b1f7..1d40827 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 @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-mfa-authenticator.md b/docs/examples/java/account/update-mfa-authenticator.md index 44bb7f0..09506e5 100644 --- a/docs/examples/java/account/update-mfa-authenticator.md +++ b/docs/examples/java/account/update-mfa-authenticator.md @@ -5,7 +5,7 @@ import io.appwrite.enums.AuthenticatorType; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-mfa-challenge.md b/docs/examples/java/account/update-mfa-challenge.md index e30c733..9fc3e39 100644 --- a/docs/examples/java/account/update-mfa-challenge.md +++ b/docs/examples/java/account/update-mfa-challenge.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-mfa-recovery-codes.md b/docs/examples/java/account/update-mfa-recovery-codes.md index 880d478..36795a0 100644 --- a/docs/examples/java/account/update-mfa-recovery-codes.md +++ b/docs/examples/java/account/update-mfa-recovery-codes.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-name.md b/docs/examples/java/account/update-name.md index ff23ace..f9a0185 100644 --- a/docs/examples/java/account/update-name.md +++ b/docs/examples/java/account/update-name.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-password.md b/docs/examples/java/account/update-password.md index 764debf..676caad 100644 --- a/docs/examples/java/account/update-password.md +++ b/docs/examples/java/account/update-password.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-phone-session.md b/docs/examples/java/account/update-phone-session.md index 69d2dd7..5f9e433 100644 --- a/docs/examples/java/account/update-phone-session.md +++ b/docs/examples/java/account/update-phone-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-phone-verification.md b/docs/examples/java/account/update-phone-verification.md index 304e73e..739b6d8 100644 --- a/docs/examples/java/account/update-phone-verification.md +++ b/docs/examples/java/account/update-phone-verification.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-phone.md b/docs/examples/java/account/update-phone.md index 795700a..adbb098 100644 --- a/docs/examples/java/account/update-phone.md +++ b/docs/examples/java/account/update-phone.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-prefs.md b/docs/examples/java/account/update-prefs.md index 71eae4c..ad42651 100644 --- a/docs/examples/java/account/update-prefs.md +++ b/docs/examples/java/account/update-prefs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-push-target.md b/docs/examples/java/account/update-push-target.md index 90dc29e..7357572 100644 --- a/docs/examples/java/account/update-push-target.md +++ b/docs/examples/java/account/update-push-target.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-recovery.md b/docs/examples/java/account/update-recovery.md index 527351c..f8067d0 100644 --- a/docs/examples/java/account/update-recovery.md +++ b/docs/examples/java/account/update-recovery.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-session.md b/docs/examples/java/account/update-session.md index e2ef0c3..2b6df41 100644 --- a/docs/examples/java/account/update-session.md +++ b/docs/examples/java/account/update-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-status.md b/docs/examples/java/account/update-status.md index 61cb944..38cf5cf 100644 --- a/docs/examples/java/account/update-status.md +++ b/docs/examples/java/account/update-status.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-verification.md b/docs/examples/java/account/update-verification.md index 3f14196..8cfbbb6 100644 --- a/docs/examples/java/account/update-verification.md +++ b/docs/examples/java/account/update-verification.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/avatars/get-browser.md b/docs/examples/java/avatars/get-browser.md index a7b9e7f..a11df7e 100644 --- a/docs/examples/java/avatars/get-browser.md +++ b/docs/examples/java/avatars/get-browser.md @@ -5,7 +5,7 @@ import io.appwrite.enums.Browser; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-credit-card.md b/docs/examples/java/avatars/get-credit-card.md index 61a8a51..f1e2b39 100644 --- a/docs/examples/java/avatars/get-credit-card.md +++ b/docs/examples/java/avatars/get-credit-card.md @@ -5,7 +5,7 @@ import io.appwrite.enums.CreditCard; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-favicon.md b/docs/examples/java/avatars/get-favicon.md index d2f86c0..5cfd60b 100644 --- a/docs/examples/java/avatars/get-favicon.md +++ b/docs/examples/java/avatars/get-favicon.md @@ -4,7 +4,7 @@ import io.appwrite.services.Avatars; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-flag.md b/docs/examples/java/avatars/get-flag.md index dc8cc29..492ecc0 100644 --- a/docs/examples/java/avatars/get-flag.md +++ b/docs/examples/java/avatars/get-flag.md @@ -5,7 +5,7 @@ import io.appwrite.enums.Flag; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-image.md b/docs/examples/java/avatars/get-image.md index 81e8029..4fc1e35 100644 --- a/docs/examples/java/avatars/get-image.md +++ b/docs/examples/java/avatars/get-image.md @@ -4,7 +4,7 @@ import io.appwrite.services.Avatars; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-initials.md b/docs/examples/java/avatars/get-initials.md index f6c3ee6..9b28608 100644 --- a/docs/examples/java/avatars/get-initials.md +++ b/docs/examples/java/avatars/get-initials.md @@ -4,7 +4,7 @@ import io.appwrite.services.Avatars; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-q-r.md b/docs/examples/java/avatars/get-q-r.md index d75b3b3..29446d5 100644 --- a/docs/examples/java/avatars/get-q-r.md +++ b/docs/examples/java/avatars/get-q-r.md @@ -4,7 +4,7 @@ import io.appwrite.services.Avatars; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index 361d5fe..87d33bd 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -4,7 +4,7 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Databases databases = new Databases(client); diff --git a/docs/examples/java/databases/delete-document.md b/docs/examples/java/databases/delete-document.md index 26b67a2..2fb3acc 100644 --- a/docs/examples/java/databases/delete-document.md +++ b/docs/examples/java/databases/delete-document.md @@ -4,7 +4,7 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Databases databases = new Databases(client); diff --git a/docs/examples/java/databases/get-document.md b/docs/examples/java/databases/get-document.md index ac89489..0edce73 100644 --- a/docs/examples/java/databases/get-document.md +++ b/docs/examples/java/databases/get-document.md @@ -4,7 +4,7 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Databases databases = new Databases(client); diff --git a/docs/examples/java/databases/list-documents.md b/docs/examples/java/databases/list-documents.md index 9f70425..f256e14 100644 --- a/docs/examples/java/databases/list-documents.md +++ b/docs/examples/java/databases/list-documents.md @@ -4,7 +4,7 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Databases databases = new Databases(client); diff --git a/docs/examples/java/databases/update-document.md b/docs/examples/java/databases/update-document.md index 430a617..16f89df 100644 --- a/docs/examples/java/databases/update-document.md +++ b/docs/examples/java/databases/update-document.md @@ -4,7 +4,7 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Databases databases = new Databases(client); diff --git a/docs/examples/java/functions/create-execution.md b/docs/examples/java/functions/create-execution.md index 0db569b..5d4cc4d 100644 --- a/docs/examples/java/functions/create-execution.md +++ b/docs/examples/java/functions/create-execution.md @@ -4,7 +4,7 @@ import io.appwrite.services.Functions; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Functions functions = new Functions(client); @@ -15,6 +15,7 @@ functions.createExecution( "", // path (optional) ExecutionMethod.GET, // method (optional) mapOf( "a" to "b" ), // headers (optional) + "", // scheduledAt (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/functions/get-execution.md b/docs/examples/java/functions/get-execution.md index 66bf263..8231445 100644 --- a/docs/examples/java/functions/get-execution.md +++ b/docs/examples/java/functions/get-execution.md @@ -4,7 +4,7 @@ import io.appwrite.services.Functions; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Functions functions = new Functions(client); diff --git a/docs/examples/java/functions/list-executions.md b/docs/examples/java/functions/list-executions.md index 1bb510a..ac793fa 100644 --- a/docs/examples/java/functions/list-executions.md +++ b/docs/examples/java/functions/list-executions.md @@ -4,7 +4,7 @@ import io.appwrite.services.Functions; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Functions functions = new Functions(client); diff --git a/docs/examples/java/graphql/mutation.md b/docs/examples/java/graphql/mutation.md index a7e5f6e..5e49fcb 100644 --- a/docs/examples/java/graphql/mutation.md +++ b/docs/examples/java/graphql/mutation.md @@ -4,7 +4,7 @@ import io.appwrite.services.Graphql; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Graphql graphql = new Graphql(client); diff --git a/docs/examples/java/graphql/query.md b/docs/examples/java/graphql/query.md index a6420b4..2d39c16 100644 --- a/docs/examples/java/graphql/query.md +++ b/docs/examples/java/graphql/query.md @@ -4,7 +4,7 @@ import io.appwrite.services.Graphql; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Graphql graphql = new Graphql(client); diff --git a/docs/examples/java/locale/get.md b/docs/examples/java/locale/get.md index cc37896..4883b21 100644 --- a/docs/examples/java/locale/get.md +++ b/docs/examples/java/locale/get.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-codes.md b/docs/examples/java/locale/list-codes.md index 3fbdf85..caddf6c 100644 --- a/docs/examples/java/locale/list-codes.md +++ b/docs/examples/java/locale/list-codes.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-continents.md b/docs/examples/java/locale/list-continents.md index 296eade..634f471 100644 --- a/docs/examples/java/locale/list-continents.md +++ b/docs/examples/java/locale/list-continents.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-countries-e-u.md b/docs/examples/java/locale/list-countries-e-u.md index f674ac5..798ea34 100644 --- a/docs/examples/java/locale/list-countries-e-u.md +++ b/docs/examples/java/locale/list-countries-e-u.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-countries-phones.md b/docs/examples/java/locale/list-countries-phones.md index 6280cbb..0828547 100644 --- a/docs/examples/java/locale/list-countries-phones.md +++ b/docs/examples/java/locale/list-countries-phones.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-countries.md b/docs/examples/java/locale/list-countries.md index eab9ae2..b56ab5c 100644 --- a/docs/examples/java/locale/list-countries.md +++ b/docs/examples/java/locale/list-countries.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-currencies.md b/docs/examples/java/locale/list-currencies.md index 662e025..ab014b5 100644 --- a/docs/examples/java/locale/list-currencies.md +++ b/docs/examples/java/locale/list-currencies.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-languages.md b/docs/examples/java/locale/list-languages.md index dd68bf2..8ef5723 100644 --- a/docs/examples/java/locale/list-languages.md +++ b/docs/examples/java/locale/list-languages.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/messaging/create-subscriber.md b/docs/examples/java/messaging/create-subscriber.md index e83b43c..d1ea18b 100644 --- a/docs/examples/java/messaging/create-subscriber.md +++ b/docs/examples/java/messaging/create-subscriber.md @@ -4,7 +4,7 @@ import io.appwrite.services.Messaging; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Messaging messaging = new Messaging(client); diff --git a/docs/examples/java/messaging/delete-subscriber.md b/docs/examples/java/messaging/delete-subscriber.md index 5e8302b..5fa1b57 100644 --- a/docs/examples/java/messaging/delete-subscriber.md +++ b/docs/examples/java/messaging/delete-subscriber.md @@ -4,7 +4,7 @@ import io.appwrite.services.Messaging; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Messaging messaging = new Messaging(client); diff --git a/docs/examples/java/storage/create-file.md b/docs/examples/java/storage/create-file.md index a060552..716ef6c 100644 --- a/docs/examples/java/storage/create-file.md +++ b/docs/examples/java/storage/create-file.md @@ -5,7 +5,7 @@ import io.appwrite.services.Storage; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/delete-file.md b/docs/examples/java/storage/delete-file.md index 113dfce..e4b4a2b 100644 --- a/docs/examples/java/storage/delete-file.md +++ b/docs/examples/java/storage/delete-file.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/get-file-download.md b/docs/examples/java/storage/get-file-download.md index 22207ca..304bbfe 100644 --- a/docs/examples/java/storage/get-file-download.md +++ b/docs/examples/java/storage/get-file-download.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/get-file-preview.md b/docs/examples/java/storage/get-file-preview.md index df81fb4..267b16f 100644 --- a/docs/examples/java/storage/get-file-preview.md +++ b/docs/examples/java/storage/get-file-preview.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/get-file-view.md b/docs/examples/java/storage/get-file-view.md index d64c3e6..ae40098 100644 --- a/docs/examples/java/storage/get-file-view.md +++ b/docs/examples/java/storage/get-file-view.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/get-file.md b/docs/examples/java/storage/get-file.md index b68bf78..86118c0 100644 --- a/docs/examples/java/storage/get-file.md +++ b/docs/examples/java/storage/get-file.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/list-files.md b/docs/examples/java/storage/list-files.md index 8b84ecb..3ef0ace 100644 --- a/docs/examples/java/storage/list-files.md +++ b/docs/examples/java/storage/list-files.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/update-file.md b/docs/examples/java/storage/update-file.md index 12b6443..6a90a61 100644 --- a/docs/examples/java/storage/update-file.md +++ b/docs/examples/java/storage/update-file.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/teams/create-membership.md b/docs/examples/java/teams/create-membership.md index 468571e..bca117a 100644 --- a/docs/examples/java/teams/create-membership.md +++ b/docs/examples/java/teams/create-membership.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/create.md b/docs/examples/java/teams/create.md index 3c757ac..6644e24 100644 --- a/docs/examples/java/teams/create.md +++ b/docs/examples/java/teams/create.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/delete-membership.md b/docs/examples/java/teams/delete-membership.md index e23409f..953f461 100644 --- a/docs/examples/java/teams/delete-membership.md +++ b/docs/examples/java/teams/delete-membership.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/delete.md b/docs/examples/java/teams/delete.md index 567ea3d..d4b6076 100644 --- a/docs/examples/java/teams/delete.md +++ b/docs/examples/java/teams/delete.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/get-membership.md b/docs/examples/java/teams/get-membership.md index c09a267..425e6f3 100644 --- a/docs/examples/java/teams/get-membership.md +++ b/docs/examples/java/teams/get-membership.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/get-prefs.md b/docs/examples/java/teams/get-prefs.md index 48a9815..a36be58 100644 --- a/docs/examples/java/teams/get-prefs.md +++ b/docs/examples/java/teams/get-prefs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/get.md b/docs/examples/java/teams/get.md index 20a6f6a..7ecfbab 100644 --- a/docs/examples/java/teams/get.md +++ b/docs/examples/java/teams/get.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/list-memberships.md b/docs/examples/java/teams/list-memberships.md index 2de609c..6a7e056 100644 --- a/docs/examples/java/teams/list-memberships.md +++ b/docs/examples/java/teams/list-memberships.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/list.md b/docs/examples/java/teams/list.md index 7f7910c..94b65d6 100644 --- a/docs/examples/java/teams/list.md +++ b/docs/examples/java/teams/list.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/update-membership-status.md b/docs/examples/java/teams/update-membership-status.md index 97e8242..ffb722a 100644 --- a/docs/examples/java/teams/update-membership-status.md +++ b/docs/examples/java/teams/update-membership-status.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/update-membership.md b/docs/examples/java/teams/update-membership.md index 86f0ddd..478a94d 100644 --- a/docs/examples/java/teams/update-membership.md +++ b/docs/examples/java/teams/update-membership.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/update-name.md b/docs/examples/java/teams/update-name.md index 1aa96f8..219bece 100644 --- a/docs/examples/java/teams/update-name.md +++ b/docs/examples/java/teams/update-name.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/update-prefs.md b/docs/examples/java/teams/update-prefs.md index e188a99..e4fb344 100644 --- a/docs/examples/java/teams/update-prefs.md +++ b/docs/examples/java/teams/update-prefs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject("<YOUR_PROJECT_ID>"); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/kotlin/account/create-anonymous-session.md b/docs/examples/kotlin/account/create-anonymous-session.md index 7961cc0..6731b6c 100644 --- a/docs/examples/kotlin/account/create-anonymous-session.md +++ b/docs/examples/kotlin/account/create-anonymous-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-email-password-session.md b/docs/examples/kotlin/account/create-email-password-session.md index 57bc99b..88123a5 100644 --- a/docs/examples/kotlin/account/create-email-password-session.md +++ b/docs/examples/kotlin/account/create-email-password-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-email-token.md b/docs/examples/kotlin/account/create-email-token.md index dd0bdf3..adaa5eb 100644 --- a/docs/examples/kotlin/account/create-email-token.md +++ b/docs/examples/kotlin/account/create-email-token.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-j-w-t.md b/docs/examples/kotlin/account/create-j-w-t.md index 3aefe4a..34e6b1a 100644 --- a/docs/examples/kotlin/account/create-j-w-t.md +++ b/docs/examples/kotlin/account/create-j-w-t.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-magic-u-r-l-token.md b/docs/examples/kotlin/account/create-magic-u-r-l-token.md index dad908e..10c9427 100644 --- a/docs/examples/kotlin/account/create-magic-u-r-l-token.md +++ b/docs/examples/kotlin/account/create-magic-u-r-l-token.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-mfa-authenticator.md b/docs/examples/kotlin/account/create-mfa-authenticator.md index f2ff748..2b60be3 100644 --- a/docs/examples/kotlin/account/create-mfa-authenticator.md +++ b/docs/examples/kotlin/account/create-mfa-authenticator.md @@ -5,7 +5,7 @@ import io.appwrite.enums.AuthenticatorType val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-mfa-challenge.md b/docs/examples/kotlin/account/create-mfa-challenge.md index d43aa39..f7554de 100644 --- a/docs/examples/kotlin/account/create-mfa-challenge.md +++ b/docs/examples/kotlin/account/create-mfa-challenge.md @@ -5,7 +5,7 @@ import io.appwrite.enums.AuthenticationFactor val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-mfa-recovery-codes.md b/docs/examples/kotlin/account/create-mfa-recovery-codes.md index be25e74..5618b3b 100644 --- a/docs/examples/kotlin/account/create-mfa-recovery-codes.md +++ b/docs/examples/kotlin/account/create-mfa-recovery-codes.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-o-auth2session.md b/docs/examples/kotlin/account/create-o-auth2session.md index d642de8..e2aebc9 100644 --- a/docs/examples/kotlin/account/create-o-auth2session.md +++ b/docs/examples/kotlin/account/create-o-auth2session.md @@ -5,7 +5,7 @@ import io.appwrite.enums.OAuthProvider val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-o-auth2token.md b/docs/examples/kotlin/account/create-o-auth2token.md index 7d651b1..71e58db 100644 --- a/docs/examples/kotlin/account/create-o-auth2token.md +++ b/docs/examples/kotlin/account/create-o-auth2token.md @@ -5,7 +5,7 @@ import io.appwrite.enums.OAuthProvider val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-phone-token.md b/docs/examples/kotlin/account/create-phone-token.md index 9e72059..16e744c 100644 --- a/docs/examples/kotlin/account/create-phone-token.md +++ b/docs/examples/kotlin/account/create-phone-token.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-phone-verification.md b/docs/examples/kotlin/account/create-phone-verification.md index 3c94fb8..74a05a0 100644 --- a/docs/examples/kotlin/account/create-phone-verification.md +++ b/docs/examples/kotlin/account/create-phone-verification.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-push-target.md b/docs/examples/kotlin/account/create-push-target.md index 66729cc..80b8221 100644 --- a/docs/examples/kotlin/account/create-push-target.md +++ b/docs/examples/kotlin/account/create-push-target.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-recovery.md b/docs/examples/kotlin/account/create-recovery.md index 8afb76c..9b4f0db 100644 --- a/docs/examples/kotlin/account/create-recovery.md +++ b/docs/examples/kotlin/account/create-recovery.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-session.md b/docs/examples/kotlin/account/create-session.md index 49daa6b..8eab36b 100644 --- a/docs/examples/kotlin/account/create-session.md +++ b/docs/examples/kotlin/account/create-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-verification.md b/docs/examples/kotlin/account/create-verification.md index 0638a36..5c2d869 100644 --- a/docs/examples/kotlin/account/create-verification.md +++ b/docs/examples/kotlin/account/create-verification.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create.md b/docs/examples/kotlin/account/create.md index 48b8b66..2707908 100644 --- a/docs/examples/kotlin/account/create.md +++ b/docs/examples/kotlin/account/create.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/delete-identity.md b/docs/examples/kotlin/account/delete-identity.md index 099b5ac..decb1b0 100644 --- a/docs/examples/kotlin/account/delete-identity.md +++ b/docs/examples/kotlin/account/delete-identity.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/delete-mfa-authenticator.md b/docs/examples/kotlin/account/delete-mfa-authenticator.md index c07afd0..3038337 100644 --- a/docs/examples/kotlin/account/delete-mfa-authenticator.md +++ b/docs/examples/kotlin/account/delete-mfa-authenticator.md @@ -5,7 +5,7 @@ import io.appwrite.enums.AuthenticatorType val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/delete-push-target.md b/docs/examples/kotlin/account/delete-push-target.md index c20d04a..a1e5519 100644 --- a/docs/examples/kotlin/account/delete-push-target.md +++ b/docs/examples/kotlin/account/delete-push-target.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/delete-session.md b/docs/examples/kotlin/account/delete-session.md index ae2ed67..4d49833 100644 --- a/docs/examples/kotlin/account/delete-session.md +++ b/docs/examples/kotlin/account/delete-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/delete-sessions.md b/docs/examples/kotlin/account/delete-sessions.md index 7caaea4..d8bf871 100644 --- a/docs/examples/kotlin/account/delete-sessions.md +++ b/docs/examples/kotlin/account/delete-sessions.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/get-mfa-recovery-codes.md b/docs/examples/kotlin/account/get-mfa-recovery-codes.md index 4a1652c..bdd2908 100644 --- a/docs/examples/kotlin/account/get-mfa-recovery-codes.md +++ b/docs/examples/kotlin/account/get-mfa-recovery-codes.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/get-prefs.md b/docs/examples/kotlin/account/get-prefs.md index 08fdd13..a4fefc5 100644 --- a/docs/examples/kotlin/account/get-prefs.md +++ b/docs/examples/kotlin/account/get-prefs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/get-session.md b/docs/examples/kotlin/account/get-session.md index d0520ce..b18c532 100644 --- a/docs/examples/kotlin/account/get-session.md +++ b/docs/examples/kotlin/account/get-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/get.md b/docs/examples/kotlin/account/get.md index ed4874b..1718bdd 100644 --- a/docs/examples/kotlin/account/get.md +++ b/docs/examples/kotlin/account/get.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/list-identities.md b/docs/examples/kotlin/account/list-identities.md index bde6023..e553a88 100644 --- a/docs/examples/kotlin/account/list-identities.md +++ b/docs/examples/kotlin/account/list-identities.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/list-logs.md b/docs/examples/kotlin/account/list-logs.md index 56238f9..2ee8214 100644 --- a/docs/examples/kotlin/account/list-logs.md +++ b/docs/examples/kotlin/account/list-logs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/list-mfa-factors.md b/docs/examples/kotlin/account/list-mfa-factors.md index 9f8572c..eddefdc 100644 --- a/docs/examples/kotlin/account/list-mfa-factors.md +++ b/docs/examples/kotlin/account/list-mfa-factors.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/list-sessions.md b/docs/examples/kotlin/account/list-sessions.md index 9d64c74..b484144 100644 --- a/docs/examples/kotlin/account/list-sessions.md +++ b/docs/examples/kotlin/account/list-sessions.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-email.md b/docs/examples/kotlin/account/update-email.md index 5068962..b8f759f 100644 --- a/docs/examples/kotlin/account/update-email.md +++ b/docs/examples/kotlin/account/update-email.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-m-f-a.md b/docs/examples/kotlin/account/update-m-f-a.md index 7949490..8940cf4 100644 --- a/docs/examples/kotlin/account/update-m-f-a.md +++ b/docs/examples/kotlin/account/update-m-f-a.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) 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 0abb033..09029e4 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 @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-mfa-authenticator.md b/docs/examples/kotlin/account/update-mfa-authenticator.md index 8b19680..5889931 100644 --- a/docs/examples/kotlin/account/update-mfa-authenticator.md +++ b/docs/examples/kotlin/account/update-mfa-authenticator.md @@ -5,7 +5,7 @@ import io.appwrite.enums.AuthenticatorType val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-mfa-challenge.md b/docs/examples/kotlin/account/update-mfa-challenge.md index fe4cb1e..d63401b 100644 --- a/docs/examples/kotlin/account/update-mfa-challenge.md +++ b/docs/examples/kotlin/account/update-mfa-challenge.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-mfa-recovery-codes.md b/docs/examples/kotlin/account/update-mfa-recovery-codes.md index f39b7c6..69b41c9 100644 --- a/docs/examples/kotlin/account/update-mfa-recovery-codes.md +++ b/docs/examples/kotlin/account/update-mfa-recovery-codes.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-name.md b/docs/examples/kotlin/account/update-name.md index 20aab9d..6658a1b 100644 --- a/docs/examples/kotlin/account/update-name.md +++ b/docs/examples/kotlin/account/update-name.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-password.md b/docs/examples/kotlin/account/update-password.md index 86c862c..fe3b8ce 100644 --- a/docs/examples/kotlin/account/update-password.md +++ b/docs/examples/kotlin/account/update-password.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-phone-session.md b/docs/examples/kotlin/account/update-phone-session.md index 6c8fa65..7414b2e 100644 --- a/docs/examples/kotlin/account/update-phone-session.md +++ b/docs/examples/kotlin/account/update-phone-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-phone-verification.md b/docs/examples/kotlin/account/update-phone-verification.md index 445a47e..e1b264b 100644 --- a/docs/examples/kotlin/account/update-phone-verification.md +++ b/docs/examples/kotlin/account/update-phone-verification.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-phone.md b/docs/examples/kotlin/account/update-phone.md index c8f50c3..c4ae4f5 100644 --- a/docs/examples/kotlin/account/update-phone.md +++ b/docs/examples/kotlin/account/update-phone.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-prefs.md b/docs/examples/kotlin/account/update-prefs.md index f449ccb..62129a2 100644 --- a/docs/examples/kotlin/account/update-prefs.md +++ b/docs/examples/kotlin/account/update-prefs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-push-target.md b/docs/examples/kotlin/account/update-push-target.md index 5fff554..8dfa97c 100644 --- a/docs/examples/kotlin/account/update-push-target.md +++ b/docs/examples/kotlin/account/update-push-target.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-recovery.md b/docs/examples/kotlin/account/update-recovery.md index da1f27e..6c83496 100644 --- a/docs/examples/kotlin/account/update-recovery.md +++ b/docs/examples/kotlin/account/update-recovery.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-session.md b/docs/examples/kotlin/account/update-session.md index 3252039..85dec29 100644 --- a/docs/examples/kotlin/account/update-session.md +++ b/docs/examples/kotlin/account/update-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-status.md b/docs/examples/kotlin/account/update-status.md index 2b54214..4bf9faf 100644 --- a/docs/examples/kotlin/account/update-status.md +++ b/docs/examples/kotlin/account/update-status.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-verification.md b/docs/examples/kotlin/account/update-verification.md index 5f7f902..4bd5459 100644 --- a/docs/examples/kotlin/account/update-verification.md +++ b/docs/examples/kotlin/account/update-verification.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/avatars/get-browser.md b/docs/examples/kotlin/avatars/get-browser.md index 1e63217..6f2a45c 100644 --- a/docs/examples/kotlin/avatars/get-browser.md +++ b/docs/examples/kotlin/avatars/get-browser.md @@ -5,7 +5,7 @@ import io.appwrite.enums.Browser val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-credit-card.md b/docs/examples/kotlin/avatars/get-credit-card.md index 23fbbfd..a85c8c8 100644 --- a/docs/examples/kotlin/avatars/get-credit-card.md +++ b/docs/examples/kotlin/avatars/get-credit-card.md @@ -5,7 +5,7 @@ import io.appwrite.enums.CreditCard val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-favicon.md b/docs/examples/kotlin/avatars/get-favicon.md index a2d5e18..eee47e1 100644 --- a/docs/examples/kotlin/avatars/get-favicon.md +++ b/docs/examples/kotlin/avatars/get-favicon.md @@ -4,7 +4,7 @@ import io.appwrite.services.Avatars val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-flag.md b/docs/examples/kotlin/avatars/get-flag.md index b1ac632..0689ba1 100644 --- a/docs/examples/kotlin/avatars/get-flag.md +++ b/docs/examples/kotlin/avatars/get-flag.md @@ -5,7 +5,7 @@ import io.appwrite.enums.Flag val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-image.md b/docs/examples/kotlin/avatars/get-image.md index bb76b4c..7042757 100644 --- a/docs/examples/kotlin/avatars/get-image.md +++ b/docs/examples/kotlin/avatars/get-image.md @@ -4,7 +4,7 @@ import io.appwrite.services.Avatars val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-initials.md b/docs/examples/kotlin/avatars/get-initials.md index b2a1c25..fd52a3b 100644 --- a/docs/examples/kotlin/avatars/get-initials.md +++ b/docs/examples/kotlin/avatars/get-initials.md @@ -4,7 +4,7 @@ import io.appwrite.services.Avatars val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-q-r.md b/docs/examples/kotlin/avatars/get-q-r.md index 853d94e..3be18c1 100644 --- a/docs/examples/kotlin/avatars/get-q-r.md +++ b/docs/examples/kotlin/avatars/get-q-r.md @@ -4,7 +4,7 @@ import io.appwrite.services.Avatars val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index 10b6fdf..69c17ef 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -4,7 +4,7 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val databases = Databases(client) diff --git a/docs/examples/kotlin/databases/delete-document.md b/docs/examples/kotlin/databases/delete-document.md index 3eb1147..3733e2f 100644 --- a/docs/examples/kotlin/databases/delete-document.md +++ b/docs/examples/kotlin/databases/delete-document.md @@ -4,7 +4,7 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val databases = Databases(client) diff --git a/docs/examples/kotlin/databases/get-document.md b/docs/examples/kotlin/databases/get-document.md index 6c5f92a..a11de0e 100644 --- a/docs/examples/kotlin/databases/get-document.md +++ b/docs/examples/kotlin/databases/get-document.md @@ -4,7 +4,7 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val databases = Databases(client) diff --git a/docs/examples/kotlin/databases/list-documents.md b/docs/examples/kotlin/databases/list-documents.md index 7b1e851..6615d44 100644 --- a/docs/examples/kotlin/databases/list-documents.md +++ b/docs/examples/kotlin/databases/list-documents.md @@ -4,7 +4,7 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val databases = Databases(client) diff --git a/docs/examples/kotlin/databases/update-document.md b/docs/examples/kotlin/databases/update-document.md index de6b192..5f9aab2 100644 --- a/docs/examples/kotlin/databases/update-document.md +++ b/docs/examples/kotlin/databases/update-document.md @@ -4,7 +4,7 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val databases = Databases(client) diff --git a/docs/examples/kotlin/functions/create-execution.md b/docs/examples/kotlin/functions/create-execution.md index de84186..e4ddc6a 100644 --- a/docs/examples/kotlin/functions/create-execution.md +++ b/docs/examples/kotlin/functions/create-execution.md @@ -4,7 +4,7 @@ import io.appwrite.services.Functions val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val functions = Functions(client) @@ -15,4 +15,5 @@ val result = functions.createExecution( path = "", // (optional) method = ExecutionMethod.GET, // (optional) headers = mapOf( "a" to "b" ), // (optional) + scheduledAt = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/get-execution.md b/docs/examples/kotlin/functions/get-execution.md index 0c4de1e..6ca4bed 100644 --- a/docs/examples/kotlin/functions/get-execution.md +++ b/docs/examples/kotlin/functions/get-execution.md @@ -4,7 +4,7 @@ import io.appwrite.services.Functions val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val functions = Functions(client) diff --git a/docs/examples/kotlin/functions/list-executions.md b/docs/examples/kotlin/functions/list-executions.md index d28b32c..4adc722 100644 --- a/docs/examples/kotlin/functions/list-executions.md +++ b/docs/examples/kotlin/functions/list-executions.md @@ -4,7 +4,7 @@ import io.appwrite.services.Functions val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val functions = Functions(client) diff --git a/docs/examples/kotlin/graphql/mutation.md b/docs/examples/kotlin/graphql/mutation.md index a429a66..2036e8e 100644 --- a/docs/examples/kotlin/graphql/mutation.md +++ b/docs/examples/kotlin/graphql/mutation.md @@ -4,7 +4,7 @@ import io.appwrite.services.Graphql val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val graphql = Graphql(client) diff --git a/docs/examples/kotlin/graphql/query.md b/docs/examples/kotlin/graphql/query.md index 0c39edd..4a37ff3 100644 --- a/docs/examples/kotlin/graphql/query.md +++ b/docs/examples/kotlin/graphql/query.md @@ -4,7 +4,7 @@ import io.appwrite.services.Graphql val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val graphql = Graphql(client) diff --git a/docs/examples/kotlin/locale/get.md b/docs/examples/kotlin/locale/get.md index d38572a..aeee656 100644 --- a/docs/examples/kotlin/locale/get.md +++ b/docs/examples/kotlin/locale/get.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-codes.md b/docs/examples/kotlin/locale/list-codes.md index 9f506f0..312ee65 100644 --- a/docs/examples/kotlin/locale/list-codes.md +++ b/docs/examples/kotlin/locale/list-codes.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-continents.md b/docs/examples/kotlin/locale/list-continents.md index 96cfda5..fa72e8e 100644 --- a/docs/examples/kotlin/locale/list-continents.md +++ b/docs/examples/kotlin/locale/list-continents.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-countries-e-u.md b/docs/examples/kotlin/locale/list-countries-e-u.md index 54faf5e..fc78895 100644 --- a/docs/examples/kotlin/locale/list-countries-e-u.md +++ b/docs/examples/kotlin/locale/list-countries-e-u.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-countries-phones.md b/docs/examples/kotlin/locale/list-countries-phones.md index 9e4bec1..c91603d 100644 --- a/docs/examples/kotlin/locale/list-countries-phones.md +++ b/docs/examples/kotlin/locale/list-countries-phones.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-countries.md b/docs/examples/kotlin/locale/list-countries.md index 4299efb..8447eae 100644 --- a/docs/examples/kotlin/locale/list-countries.md +++ b/docs/examples/kotlin/locale/list-countries.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-currencies.md b/docs/examples/kotlin/locale/list-currencies.md index 2bb7ca7..631cd0d 100644 --- a/docs/examples/kotlin/locale/list-currencies.md +++ b/docs/examples/kotlin/locale/list-currencies.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-languages.md b/docs/examples/kotlin/locale/list-languages.md index a9035e9..c6c1560 100644 --- a/docs/examples/kotlin/locale/list-languages.md +++ b/docs/examples/kotlin/locale/list-languages.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/messaging/create-subscriber.md b/docs/examples/kotlin/messaging/create-subscriber.md index 3f1d476..e0798af 100644 --- a/docs/examples/kotlin/messaging/create-subscriber.md +++ b/docs/examples/kotlin/messaging/create-subscriber.md @@ -4,7 +4,7 @@ import io.appwrite.services.Messaging val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val messaging = Messaging(client) diff --git a/docs/examples/kotlin/messaging/delete-subscriber.md b/docs/examples/kotlin/messaging/delete-subscriber.md index febf622..cf84d81 100644 --- a/docs/examples/kotlin/messaging/delete-subscriber.md +++ b/docs/examples/kotlin/messaging/delete-subscriber.md @@ -4,7 +4,7 @@ import io.appwrite.services.Messaging val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val messaging = Messaging(client) diff --git a/docs/examples/kotlin/storage/create-file.md b/docs/examples/kotlin/storage/create-file.md index ccd342e..d9b50e5 100644 --- a/docs/examples/kotlin/storage/create-file.md +++ b/docs/examples/kotlin/storage/create-file.md @@ -5,7 +5,7 @@ import io.appwrite.services.Storage val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/delete-file.md b/docs/examples/kotlin/storage/delete-file.md index 8def7d9..6309658 100644 --- a/docs/examples/kotlin/storage/delete-file.md +++ b/docs/examples/kotlin/storage/delete-file.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/get-file-download.md b/docs/examples/kotlin/storage/get-file-download.md index c6e8fa4..305fdb9 100644 --- a/docs/examples/kotlin/storage/get-file-download.md +++ b/docs/examples/kotlin/storage/get-file-download.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/get-file-preview.md b/docs/examples/kotlin/storage/get-file-preview.md index 9c9993c..9cd86ff 100644 --- a/docs/examples/kotlin/storage/get-file-preview.md +++ b/docs/examples/kotlin/storage/get-file-preview.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/get-file-view.md b/docs/examples/kotlin/storage/get-file-view.md index 83f8b31..b8769cd 100644 --- a/docs/examples/kotlin/storage/get-file-view.md +++ b/docs/examples/kotlin/storage/get-file-view.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/get-file.md b/docs/examples/kotlin/storage/get-file.md index df662ea..4fab8a6 100644 --- a/docs/examples/kotlin/storage/get-file.md +++ b/docs/examples/kotlin/storage/get-file.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/list-files.md b/docs/examples/kotlin/storage/list-files.md index 4e28fc5..78d875e 100644 --- a/docs/examples/kotlin/storage/list-files.md +++ b/docs/examples/kotlin/storage/list-files.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/update-file.md b/docs/examples/kotlin/storage/update-file.md index c84dadb..7f34dee 100644 --- a/docs/examples/kotlin/storage/update-file.md +++ b/docs/examples/kotlin/storage/update-file.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/teams/create-membership.md b/docs/examples/kotlin/teams/create-membership.md index a892663..5858c23 100644 --- a/docs/examples/kotlin/teams/create-membership.md +++ b/docs/examples/kotlin/teams/create-membership.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/create.md b/docs/examples/kotlin/teams/create.md index 22d6e7f..a45c22c 100644 --- a/docs/examples/kotlin/teams/create.md +++ b/docs/examples/kotlin/teams/create.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/delete-membership.md b/docs/examples/kotlin/teams/delete-membership.md index 66e5716..0d191e6 100644 --- a/docs/examples/kotlin/teams/delete-membership.md +++ b/docs/examples/kotlin/teams/delete-membership.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/delete.md b/docs/examples/kotlin/teams/delete.md index a73fa75..87a3026 100644 --- a/docs/examples/kotlin/teams/delete.md +++ b/docs/examples/kotlin/teams/delete.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/get-membership.md b/docs/examples/kotlin/teams/get-membership.md index 80640c7..25e8b3a 100644 --- a/docs/examples/kotlin/teams/get-membership.md +++ b/docs/examples/kotlin/teams/get-membership.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/get-prefs.md b/docs/examples/kotlin/teams/get-prefs.md index 31001bd..447c4f2 100644 --- a/docs/examples/kotlin/teams/get-prefs.md +++ b/docs/examples/kotlin/teams/get-prefs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/get.md b/docs/examples/kotlin/teams/get.md index 4387118..aa18a31 100644 --- a/docs/examples/kotlin/teams/get.md +++ b/docs/examples/kotlin/teams/get.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/list-memberships.md b/docs/examples/kotlin/teams/list-memberships.md index 7c8c686..2f83d8c 100644 --- a/docs/examples/kotlin/teams/list-memberships.md +++ b/docs/examples/kotlin/teams/list-memberships.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/list.md b/docs/examples/kotlin/teams/list.md index e73d9e4..569e607 100644 --- a/docs/examples/kotlin/teams/list.md +++ b/docs/examples/kotlin/teams/list.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/update-membership-status.md b/docs/examples/kotlin/teams/update-membership-status.md index 0866892..8d091aa 100644 --- a/docs/examples/kotlin/teams/update-membership-status.md +++ b/docs/examples/kotlin/teams/update-membership-status.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/update-membership.md b/docs/examples/kotlin/teams/update-membership.md index 799c594..1f6c2d3 100644 --- a/docs/examples/kotlin/teams/update-membership.md +++ b/docs/examples/kotlin/teams/update-membership.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/update-name.md b/docs/examples/kotlin/teams/update-name.md index 5e2399a..470ab17 100644 --- a/docs/examples/kotlin/teams/update-name.md +++ b/docs/examples/kotlin/teams/update-name.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/update-prefs.md b/docs/examples/kotlin/teams/update-prefs.md index 62febab..6ef809e 100644 --- a/docs/examples/kotlin/teams/update-prefs.md +++ b/docs/examples/kotlin/teams/update-prefs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("<YOUR_PROJECT_ID>") // Your project ID val teams = Teams(client) diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index a27cf48..6a7de91 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -508,6 +508,14 @@ class Client @JvmOverloads constructor( it.cancel(error) return } + + val warnings = response.headers["x-appwrite-warning"] + if (warnings != null) { + warnings.split(";").forEach { warning -> + println("Warning: $warning") + } + } + when { responseType == Boolean::class.java -> { it.resume(true as T) diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 95dd107..0ffb9a7 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -262,7 +262,7 @@ class Account(client: Client) : Service(client) { */ suspend fun createJWT( ): io.appwrite.models.Jwt { - val apiPath = "/account/jwt" + val apiPath = "/account/jwts" val apiParams = mutableMapOf( ) @@ -406,7 +406,7 @@ class Account(client: Client) : Service(client) { /** * Verify Authenticator * - * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. add + * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. * * @param type Type of authenticator. * @param otp Valid verification token. @@ -443,7 +443,7 @@ class Account(client: Client) : Service(client) { /** * Verify Authenticator * - * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. add + * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. * * @param type Type of authenticator. * @param otp Valid verification token. diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index c7a81ad..9ff22d6 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -21,7 +21,7 @@ class Functions(client: Client) : Service(client) { * 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/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, responseStatusCode, duration + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.ExecutionList] */ @@ -67,6 +67,7 @@ class Functions(client: Client) : Service(client) { * @param path HTTP path of execution. Path can include query params. Default value is / * @param method HTTP method of execution. Default value is GET. * @param headers HTTP headers of execution. Defaults to empty. + * @param scheduledAt Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. * @return [io.appwrite.models.Execution] */ @JvmOverloads @@ -77,6 +78,7 @@ class Functions(client: Client) : Service(client) { path: String? = null, method: io.appwrite.enums.ExecutionMethod? = null, headers: Any? = null, + scheduledAt: String? = null, ): io.appwrite.models.Execution { val apiPath = "/functions/{functionId}/executions" .replace("{functionId}", functionId) @@ -87,6 +89,7 @@ class Functions(client: Client) : Service(client) { "path" to path, "method" to method, "headers" to headers, + "scheduledAt" to scheduledAt, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index 80dd45b..8f21473 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -65,7 +65,7 @@ class Storage(client: Client) : Service(client) { * * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). * @param fileId File ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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. Appwrite SDKs provide helpers to handle file input. [Learn about file input](https://appwrite.io/docs/storage#file-input). + * @param file Binary file. Appwrite SDKs provide helpers to handle file input. [Learn about file input](https://appwrite.io/docs/products/storage/upload-download#input-file). * @param permissions An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.File] */ diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 304e60d..fd0ae92 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -323,7 +323,7 @@ class Teams(client: Client) : Service(client) { * @param email Email of the new team member. * @param userId ID of the user to be added to a team. * @param phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. - * @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 url URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. 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] */ From 84918075df71f3fb956ef0eede6f0fc06146e930 Mon Sep 17 00:00:00 2001 From: Evan Date: Mon, 29 Jul 2024 09:16:55 -0700 Subject: [PATCH 076/118] Create autoclose.yml --- .github/workflows/autoclose.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/workflows/autoclose.yml diff --git a/.github/workflows/autoclose.yml b/.github/workflows/autoclose.yml new file mode 100644 index 0000000..3e2b3cb --- /dev/null +++ b/.github/workflows/autoclose.yml @@ -0,0 +1,11 @@ +name: Auto-close External Pull Requests + +on: + pull_request_target: + types: [opened, reopened] + +jobs: + auto_close: + uses: appwrite/.github/.github/workflows/autoclose.yml@main + secrets: + GH_AUTO_CLOSE_PR_TOKEN: ${{ secrets.GH_AUTO_CLOSE_PR_TOKEN }} From 4af79e2966962fdc102884c8f5a9106254bc7921 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 17 Aug 2024 08:48:44 +0000 Subject: [PATCH 077/118] chore: release rc --- README.md | 6 +- .../java/account/delete-mfa-authenticator.md | 1 - .../java/functions/get-deployment-download.md | 23 +++ docs/examples/java/functions/get-template.md | 22 +++ .../examples/java/functions/list-templates.md | 25 +++ .../account/delete-mfa-authenticator.md | 1 - .../functions/get-deployment-download.md | 14 ++ .../examples/kotlin/functions/get-template.md | 13 ++ .../kotlin/functions/list-templates.md | 16 ++ library/build.gradle | 2 +- library/src/main/java/io/appwrite/Client.kt | 7 +- library/src/main/java/io/appwrite/ID.kt | 10 +- .../src/main/java/io/appwrite/Permission.kt | 47 ++++- library/src/main/java/io/appwrite/Query.kt | 161 +++++++++++++++++- library/src/main/java/io/appwrite/Service.kt | 5 + .../main/java/io/appwrite/models/Execution.kt | 8 + .../io/appwrite/models/TemplateFunction.kt | 158 +++++++++++++++++ .../appwrite/models/TemplateFunctionList.kt | 38 +++++ .../io/appwrite/models/TemplateRuntime.kt | 54 ++++++ .../io/appwrite/models/TemplateVariable.kt | 70 ++++++++ .../main/java/io/appwrite/services/Account.kt | 9 +- .../main/java/io/appwrite/services/Avatars.kt | 4 +- .../java/io/appwrite/services/Functions.kt | 121 ++++++++++++- 23 files changed, 790 insertions(+), 25 deletions(-) create mode 100644 docs/examples/java/functions/get-deployment-download.md create mode 100644 docs/examples/java/functions/get-template.md create mode 100644 docs/examples/java/functions/list-templates.md create mode 100644 docs/examples/kotlin/functions/get-deployment-download.md create mode 100644 docs/examples/kotlin/functions/get-template.md create mode 100644 docs/examples/kotlin/functions/list-templates.md create mode 100644 library/src/main/java/io/appwrite/models/TemplateFunction.kt create mode 100644 library/src/main/java/io/appwrite/models/TemplateFunctionList.kt create mode 100644 library/src/main/java/io/appwrite/models/TemplateRuntime.kt create mode 100644 library/src/main/java/io/appwrite/models/TemplateVariable.kt diff --git a/README.md b/README.md index 6b559ef..b06e453 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![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.5.7-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.6.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) @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:5.1.1") +implementation("io.appwrite:sdk-for-android:6.0.0-rc.1") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 5.1.1 + 6.0.0-rc.1 ``` diff --git a/docs/examples/java/account/delete-mfa-authenticator.md b/docs/examples/java/account/delete-mfa-authenticator.md index 148f4e4..b7c7442 100644 --- a/docs/examples/java/account/delete-mfa-authenticator.md +++ b/docs/examples/java/account/delete-mfa-authenticator.md @@ -11,7 +11,6 @@ Account account = new Account(client); account.deleteMfaAuthenticator( AuthenticatorType.TOTP, // type - "", // otp new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/functions/get-deployment-download.md b/docs/examples/java/functions/get-deployment-download.md new file mode 100644 index 0000000..4a93187 --- /dev/null +++ b/docs/examples/java/functions/get-deployment-download.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Functions; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("<YOUR_PROJECT_ID>"); // Your project ID + +Functions functions = new Functions(client); + +functions.getDeploymentDownload( + "", // functionId + "", // deploymentId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/functions/get-template.md b/docs/examples/java/functions/get-template.md new file mode 100644 index 0000000..f1043f3 --- /dev/null +++ b/docs/examples/java/functions/get-template.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Functions; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("<YOUR_PROJECT_ID>"); // Your project ID + +Functions functions = new Functions(client); + +functions.getTemplate( + "", // templateId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/functions/list-templates.md b/docs/examples/java/functions/list-templates.md new file mode 100644 index 0000000..bd99c31 --- /dev/null +++ b/docs/examples/java/functions/list-templates.md @@ -0,0 +1,25 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Functions; + +Client client = new Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("<YOUR_PROJECT_ID>"); // Your project ID + +Functions functions = new Functions(client); + +functions.listTemplates( + listOf(), // runtimes (optional) + listOf(), // useCases (optional) + 1, // limit (optional) + 0, // offset (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/kotlin/account/delete-mfa-authenticator.md b/docs/examples/kotlin/account/delete-mfa-authenticator.md index 3038337..a9a9fd8 100644 --- a/docs/examples/kotlin/account/delete-mfa-authenticator.md +++ b/docs/examples/kotlin/account/delete-mfa-authenticator.md @@ -11,5 +11,4 @@ val account = Account(client) val result = account.deleteMfaAuthenticator( type = AuthenticatorType.TOTP, - otp = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/get-deployment-download.md b/docs/examples/kotlin/functions/get-deployment-download.md new file mode 100644 index 0000000..ade55aa --- /dev/null +++ b/docs/examples/kotlin/functions/get-deployment-download.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Functions + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("<YOUR_PROJECT_ID>") // Your project ID + +val functions = Functions(client) + +val result = functions.getDeploymentDownload( + functionId = "", + deploymentId = "", +) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/get-template.md b/docs/examples/kotlin/functions/get-template.md new file mode 100644 index 0000000..f8d6697 --- /dev/null +++ b/docs/examples/kotlin/functions/get-template.md @@ -0,0 +1,13 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Functions + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("<YOUR_PROJECT_ID>") // Your project ID + +val functions = Functions(client) + +val result = functions.getTemplate( + templateId = "", +) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/list-templates.md b/docs/examples/kotlin/functions/list-templates.md new file mode 100644 index 0000000..5ea5f16 --- /dev/null +++ b/docs/examples/kotlin/functions/list-templates.md @@ -0,0 +1,16 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Functions + +val client = Client(context) + .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setProject("<YOUR_PROJECT_ID>") // Your project ID + +val functions = Functions(client) + +val result = functions.listTemplates( + runtimes = listOf(), // (optional) + useCases = listOf(), // (optional) + limit = 1, // (optional) + offset = 0, // (optional) +) \ No newline at end of file diff --git a/library/build.gradle b/library/build.gradle index 998da2b..b67e51e 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -15,7 +15,7 @@ ext { POM_LICENSE_NAME = "GPL-3.0" POM_DEVELOPER_ID = 'appwrite' POM_DEVELOPER_NAME = 'Appwrite Team' - POM_DEVELOPER_EMAIL = 'team@appwrite.io' + POM_DEVELOPER_EMAIL = 'team@localhost.test' GITHUB_SCM_CONNECTION = 'scm:git:git://github.com/appwrite/sdk-for-android.git' } diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 6a7de91..1e2f464 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -44,6 +44,9 @@ class Client @JvmOverloads constructor( ) : CoroutineScope { companion object { + /** + * The size for chunked uploads in bytes. + */ internal const val CHUNK_SIZE = 5*1024*1024; // 5MB internal const val GLOBAL_PREFS = "io.appwrite" internal const val COOKIE_PREFS = "myCookie" @@ -83,8 +86,8 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "5.1.1", - "x-appwrite-response-format" to "1.5.0" + "x-sdk-version" to "6.0.0-rc.1", + "x-appwrite-response-format" to "1.6.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/ID.kt b/library/src/main/java/io/appwrite/ID.kt index e661192..b89957b 100644 --- a/library/src/main/java/io/appwrite/ID.kt +++ b/library/src/main/java/io/appwrite/ID.kt @@ -4,6 +4,9 @@ import java.time.Instant import kotlin.math.floor import kotlin.random.Random +/** + * Helper class to generate ID strings for resources. + */ class ID { companion object { // Generate an hex ID based on timestamp @@ -21,7 +24,12 @@ class ID { fun custom(id: String): String = id - // Generate a unique ID with padding to have a longer ID + /** + * Generate a unique ID with padding to have a longer ID + * + * @param padding The number of characters to add to the ID + * @returns The unique ID + */ fun unique(padding: Int = 7): String { val baseId = hexTimestamp() val randomPadding = (1..padding) diff --git a/library/src/main/java/io/appwrite/Permission.kt b/library/src/main/java/io/appwrite/Permission.kt index a540dcf..462b8e4 100644 --- a/library/src/main/java/io/appwrite/Permission.kt +++ b/library/src/main/java/io/appwrite/Permission.kt @@ -1,19 +1,60 @@ package io.appwrite +/** + * Helper class to generate permission strings for resources. + */ class Permission { companion object { + + /** + * Generate read permission string for the provided role. + * + * @param role The role for which to generate the permission. + * @returns The read permission string. + */ fun read(role: String): String { return "read(\"${role}\")" - } + } + + /** + * Generate write permission string for the provided role. + * + * This is an alias of update, delete, and possibly create. + * Don't use write in combination with update, delete, or create. + * + * @param role The role for which to generate the permission. + * @returns The write permission string. + */ fun write(role: String): String { return "write(\"${role}\")" } + + /** + * Generate create permission string for the provided role. + * + * @param role The role for which to generate the permission. + * @returns The create permission string. + */ fun create(role: String): String { return "create(\"${role}\")" - } + } + + /** + * Generate update permission string for the provided role. + * + * @param role The role for which to generate the permission. + * @returns The update permission string. + */ fun update(role: String): String { return "update(\"${role}\")" - } + } + + /** + * Generate delete permission string for the provided role. + * + * @param role The role for which to generate the permission. + * @returns The delete permission string. + */ fun delete(role: String): String { return "delete(\"${role}\")" } diff --git a/library/src/main/java/io/appwrite/Query.kt b/library/src/main/java/io/appwrite/Query.kt index 6efbb11..e326335 100644 --- a/library/src/main/java/io/appwrite/Query.kt +++ b/library/src/main/java/io/appwrite/Query.kt @@ -3,58 +3,217 @@ package io.appwrite import io.appwrite.extensions.toJson import io.appwrite.extensions.fromJson +/** + * Helper class to generate query strings. + */ class Query( val method: String, val attribute: String? = null, val values: List? = null, ) { + /** + * Convert the query object to a JSON string. + * + * @returns The JSON string representation of the query object. + */ override fun toString() = this.toJson() companion object { + + /** + * Filter resources where attribute is equal to value. + * + * @param attribute The attribute to filter on. + * @param value The value to compare against. + * @returns The query string. + */ fun equal(attribute: String, value: Any) = Query("equal", attribute, parseValue(value)).toJson() + /** + * Filter resources where attribute is not equal to value. + * + * @param attribute The attribute to filter on. + * @param value The value to compare against. + * @returns The query string. + */ fun notEqual(attribute: String, value: Any) = Query("notEqual", attribute, parseValue(value)).toJson() + /** + * Filter resources where attribute is less than value. + * + * @param attribute The attribute to filter on. + * @param value The value to compare against. + * @returns The query string. + */ fun lessThan(attribute: String, value: Any) = Query("lessThan", attribute, parseValue(value)).toJson() + /** + * Filter resources where attribute is less than or equal to value. + * + * @param attribute The attribute to filter on. + * @param value The value to compare against. + * @returns The query string. + */ fun lessThanEqual(attribute: String, value: Any) = Query("lessThanEqual", attribute, parseValue(value)).toJson() + /** + * Filter resources where attribute is greater than value. + * + * @param attribute The attribute to filter on. + * @param value The value to compare against. + * @returns The query string. + */ fun greaterThan(attribute: String, value: Any) = Query("greaterThan", attribute, parseValue(value)).toJson() + /** + * Filter resources where attribute is greater than or equal to value. + * + * @param attribute The attribute to filter on. + * @param value The value to compare against. + * @returns The query string. + */ fun greaterThanEqual(attribute: String, value: Any) = Query("greaterThanEqual", attribute, parseValue(value)).toJson() + /** + * Filter resources where attribute matches the search value. + * + * @param attribute The attribute to filter on. + * @param value The search value to match against. + * @returns The query string. + */ fun search(attribute: String, value: String) = Query("search", attribute, listOf(value)).toJson() + /** + * Filter resources where attribute is null. + * + * @param attribute The attribute to filter on. + * @returns The query string. + */ fun isNull(attribute: String) = Query("isNull", attribute).toJson() + /** + * Filter resources where attribute is not null. + * + * @param attribute The attribute to filter on. + * @returns The query string. + */ fun isNotNull(attribute: String) = Query("isNotNull", attribute).toJson() + /** + * Filter resources where attribute is between start and end (inclusive). + * + * @param attribute The attribute to filter on. + * @param start The start value of the range. + * @param end The end value of the range. + * @returns The query string. + */ fun between(attribute: String, start: Any, end: Any) = Query("between", attribute, listOf(start, end)).toJson() + /** + * Filter resources where attribute starts with value. + * + * @param attribute The attribute to filter on. + * @param value The value to compare against. + * @returns The query string. + */ fun startsWith(attribute: String, value: String) = Query("startsWith", attribute, listOf(value)).toJson() + /** + * Filter resources where attribute ends with value. + * + * @param attribute The attribute to filter on. + * @param value The value to compare against. + * @returns The query string. + */ fun endsWith(attribute: String, value: String) = Query("endsWith", attribute, listOf(value)).toJson() + /** + * Specify which attributes should be returned by the API call. + * + * @param attributes The list of attributes to select. + * @returns The query string. + */ fun select(attributes: List) = Query("select", null, attributes).toJson() + /** + * Sort results by attribute ascending. + * + * @param attribute The attribute to sort by. + * @returns The query string. + */ fun orderAsc(attribute: String) = Query("orderAsc", attribute).toJson() + /** + * Sort results by attribute descending. + * + * @param attribute The attribute to sort by. + * @returns The query string. + */ fun orderDesc(attribute: String) = Query("orderDesc", attribute).toJson() + /** + * Return results before documentId. + * + * @param documentId The document ID to use as cursor. + * @returns The query string. + */ fun cursorBefore(documentId: String) = Query("cursorBefore", null, listOf(documentId)).toJson() + /** + * Return results after documentId. + * + * @param documentId The document ID to use as cursor. + * @returns The query string. + */ fun cursorAfter(documentId: String) = Query("cursorAfter", null, listOf(documentId)).toJson() - + + /** + * Return only limit results. + * + * @param limit The number of results to return. + * @returns The query string. + */ fun limit(limit: Int) = Query("limit", null, listOf(limit)).toJson() + /** + * Filter resources by skipping the first offset results. + * + * @param offset The number of results to skip. + * @returns The query string. + */ fun offset(offset: Int) = Query("offset", null, listOf(offset)).toJson() + /** + * Filter resources where attribute contains the specified value. + * + * @param attribute The attribute to filter on. + * @param value The value to compare against. + * @returns The query string. + */ fun contains(attribute: String, value: Any) = Query("contains", attribute, parseValue(value)).toJson() + /** + * Combine multiple queries using logical OR operator. + * + * @param queries The list of query strings to combine. + * @returns The query string. + */ fun or(queries: List) = Query("or", null, queries.map { it.fromJson() }).toJson() + /** + * Combine multiple queries using logical AND operator. + * + * @param queries The list of query strings to combine. + * @returns The query string. + */ fun and(queries: List) = Query("and", null, queries.map { it.fromJson() }).toJson() + /** + * Parse the value to a list of values. + * + * @param value The value to parse. + * @returns The list of parsed values. + */ private fun parseValue(value: Any): List { return when (value) { is List<*> -> value as List diff --git a/library/src/main/java/io/appwrite/Service.kt b/library/src/main/java/io/appwrite/Service.kt index 8efdb9b..7a01b4b 100644 --- a/library/src/main/java/io/appwrite/Service.kt +++ b/library/src/main/java/io/appwrite/Service.kt @@ -2,4 +2,9 @@ package io.appwrite import io.appwrite.Client +/** + * Abstract class for services. + * + * @param client The Appwrite client. + */ abstract class Service(val client: Client) diff --git a/library/src/main/java/io/appwrite/models/Execution.kt b/library/src/main/java/io/appwrite/models/Execution.kt index 8252aa1..44724fa 100644 --- a/library/src/main/java/io/appwrite/models/Execution.kt +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -103,6 +103,12 @@ data class Execution( @SerializedName("duration") val duration: Double, + /** + * The scheduled time for execution. If left empty, execution will be queued immediately. + */ + @SerializedName("scheduledAt") + var scheduledAt: String?, + ) { fun toMap(): Map = mapOf( "\$id" to id as Any, @@ -121,6 +127,7 @@ data class Execution( "logs" to logs as Any, "errors" to errors as Any, "duration" to duration as Any, + "scheduledAt" to scheduledAt as Any, ) companion object { @@ -145,6 +152,7 @@ data class Execution( logs = map["logs"] as String, errors = map["errors"] as String, duration = (map["duration"] as Number).toDouble(), + scheduledAt = map["scheduledAt"] as? String?, ) } } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/TemplateFunction.kt b/library/src/main/java/io/appwrite/models/TemplateFunction.kt new file mode 100644 index 0000000..3da1135 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/TemplateFunction.kt @@ -0,0 +1,158 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Template Function + */ +data class TemplateFunction( + /** + * Function Template Icon. + */ + @SerializedName("icon") + val icon: String, + + /** + * Function Template ID. + */ + @SerializedName("id") + val id: String, + + /** + * Function Template Name. + */ + @SerializedName("name") + val name: String, + + /** + * Function Template Tagline. + */ + @SerializedName("tagline") + val tagline: String, + + /** + * Execution permissions. + */ + @SerializedName("permissions") + val permissions: List, + + /** + * Function trigger events. + */ + @SerializedName("events") + val events: List, + + /** + * Function execution schedult in CRON format. + */ + @SerializedName("cron") + val cron: String, + + /** + * Function execution timeout in seconds. + */ + @SerializedName("timeout") + val timeout: Long, + + /** + * Function use cases. + */ + @SerializedName("useCases") + val useCases: List, + + /** + * List of runtimes that can be used with this template. + */ + @SerializedName("runtimes") + val runtimes: List, + + /** + * Function Template Instructions. + */ + @SerializedName("instructions") + val instructions: String, + + /** + * VCS (Version Control System) Provider. + */ + @SerializedName("vcsProvider") + val vcsProvider: String, + + /** + * VCS (Version Control System) Repository ID + */ + @SerializedName("providerRepositoryId") + val providerRepositoryId: String, + + /** + * VCS (Version Control System) Owner. + */ + @SerializedName("providerOwner") + val providerOwner: String, + + /** + * VCS (Version Control System) branch version (tag). + */ + @SerializedName("providerVersion") + val providerVersion: String, + + /** + * Function variables. + */ + @SerializedName("variables") + val variables: List, + + /** + * Function scopes. + */ + @SerializedName("scopes") + val scopes: List, + +) { + fun toMap(): Map = mapOf( + "icon" to icon as Any, + "id" to id as Any, + "name" to name as Any, + "tagline" to tagline as Any, + "permissions" to permissions as Any, + "events" to events as Any, + "cron" to cron as Any, + "timeout" to timeout as Any, + "useCases" to useCases as Any, + "runtimes" to runtimes.map { it.toMap() } as Any, + "instructions" to instructions as Any, + "vcsProvider" to vcsProvider as Any, + "providerRepositoryId" to providerRepositoryId as Any, + "providerOwner" to providerOwner as Any, + "providerVersion" to providerVersion as Any, + "variables" to variables.map { it.toMap() } as Any, + "scopes" to scopes as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = TemplateFunction( + icon = map["icon"] as String, + id = map["id"] as String, + name = map["name"] as String, + tagline = map["tagline"] as String, + permissions = map["permissions"] as List, + events = map["events"] as List, + cron = map["cron"] as String, + timeout = (map["timeout"] as Number).toLong(), + useCases = map["useCases"] as List, + runtimes = (map["runtimes"] as List>).map { TemplateRuntime.from(map = it) }, + instructions = map["instructions"] as String, + vcsProvider = map["vcsProvider"] as String, + providerRepositoryId = map["providerRepositoryId"] as String, + providerOwner = map["providerOwner"] as String, + providerVersion = map["providerVersion"] as String, + variables = (map["variables"] as List>).map { TemplateVariable.from(map = it) }, + scopes = map["scopes"] as List, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/TemplateFunctionList.kt b/library/src/main/java/io/appwrite/models/TemplateFunctionList.kt new file mode 100644 index 0000000..4cfce5d --- /dev/null +++ b/library/src/main/java/io/appwrite/models/TemplateFunctionList.kt @@ -0,0 +1,38 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Function Templates List + */ +data class TemplateFunctionList( + /** + * Total number of templates documents that matched your query. + */ + @SerializedName("total") + val total: Long, + + /** + * List of templates. + */ + @SerializedName("templates") + val templates: List, + +) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "templates" to templates.map { it.toMap() } as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = TemplateFunctionList( + total = (map["total"] as Number).toLong(), + templates = (map["templates"] as List>).map { TemplateFunction.from(map = it) }, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/TemplateRuntime.kt b/library/src/main/java/io/appwrite/models/TemplateRuntime.kt new file mode 100644 index 0000000..d354239 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/TemplateRuntime.kt @@ -0,0 +1,54 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Template Runtime + */ +data class TemplateRuntime( + /** + * Runtime Name. + */ + @SerializedName("name") + val name: String, + + /** + * The build command used to build the deployment. + */ + @SerializedName("commands") + val commands: String, + + /** + * The entrypoint file used to execute the deployment. + */ + @SerializedName("entrypoint") + val entrypoint: String, + + /** + * Path to function in VCS (Version Control System) repository + */ + @SerializedName("providerRootDirectory") + val providerRootDirectory: String, + +) { + fun toMap(): Map = mapOf( + "name" to name as Any, + "commands" to commands as Any, + "entrypoint" to entrypoint as Any, + "providerRootDirectory" to providerRootDirectory as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = TemplateRuntime( + name = map["name"] as String, + commands = map["commands"] as String, + entrypoint = map["entrypoint"] as String, + providerRootDirectory = map["providerRootDirectory"] as String, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/TemplateVariable.kt b/library/src/main/java/io/appwrite/models/TemplateVariable.kt new file mode 100644 index 0000000..96d6607 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/TemplateVariable.kt @@ -0,0 +1,70 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Template Variable + */ +data class TemplateVariable( + /** + * Variable Name. + */ + @SerializedName("name") + val name: String, + + /** + * Variable Description. + */ + @SerializedName("description") + val description: String, + + /** + * Variable Value. + */ + @SerializedName("value") + val value: String, + + /** + * Variable Placeholder. + */ + @SerializedName("placeholder") + val placeholder: String, + + /** + * Is the variable required? + */ + @SerializedName("required") + val required: Boolean, + + /** + * Variable Type. + */ + @SerializedName("type") + val type: String, + +) { + fun toMap(): Map = mapOf( + "name" to name as Any, + "description" to description as Any, + "value" to value as Any, + "placeholder" to placeholder as Any, + "required" to required as Any, + "type" to type as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = TemplateVariable( + name = map["name"] as String, + description = map["description"] as String, + value = map["value"] as String, + placeholder = map["placeholder"] as String, + required = map["required"] as Boolean, + type = map["type"] as String, + ) + } +} \ 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 0ffb9a7..c3655ea 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -370,7 +370,7 @@ class Account(client: Client) : Service(client) { ) /** - * Add Authenticator + * Create Authenticator * * Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. * @@ -465,18 +465,15 @@ class Account(client: Client) : Service(client) { * Delete an authenticator for a user by ID. * * @param type Type of authenticator. - * @param otp Valid verification token. * @return [Any] */ suspend fun deleteMfaAuthenticator( type: io.appwrite.enums.AuthenticatorType, - otp: String, ): Any { val apiPath = "/account/mfa/authenticators/{type}" .replace("{type}", type.value) val apiParams = mutableMapOf( - "otp" to otp, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -492,7 +489,7 @@ class Account(client: Client) : Service(client) { /** - * Create 2FA Challenge + * Create MFA Challenge * * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. * @@ -1869,7 +1866,7 @@ class Account(client: Client) : Service(client) { /** - * Create phone verification (confirmation) + * Update 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. * diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt index 2cb130d..9913edc 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -92,7 +92,7 @@ class Avatars(client: Client) : Service(client) { /** * 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.This endpoint does not follow HTTP redirects. * * @param url Website URL which you want to fetch the favicon from. * @return [ByteArray] @@ -154,7 +154,7 @@ class Avatars(client: Client) : Service(client) { /** * 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.This endpoint does not follow HTTP redirects. * * @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. diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index 9ff22d6..a8fa0d3 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -8,6 +8,8 @@ import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import okhttp3.Cookie +import okhttp3.HttpUrl +import okhttp3.HttpUrl.Companion.toHttpUrl import java.io.File /** @@ -15,6 +17,113 @@ import java.io.File **/ class Functions(client: Client) : Service(client) { + /** + * List function templates + * + * List available function templates. You can use template details in [createFunction](/docs/references/cloud/server-nodejs/functions#create) method. + * + * @param runtimes List of runtimes allowed for filtering function templates. Maximum of 100 runtimes are allowed. + * @param useCases List of use cases allowed for filtering function templates. Maximum of 100 use cases are allowed. + * @param limit Limit the number of templates returned in the response. Default limit is 25, and maximum limit is 5000. + * @param offset Offset the list of returned templates. Maximum offset is 5000. + * @return [io.appwrite.models.TemplateFunctionList] + */ + @JvmOverloads + suspend fun listTemplates( + runtimes: List? = null, + useCases: List? = null, + limit: Long? = null, + offset: Long? = null, + ): io.appwrite.models.TemplateFunctionList { + val apiPath = "/functions/templates" + + val apiParams = mutableMapOf( + "runtimes" to runtimes, + "useCases" to useCases, + "limit" to limit, + "offset" to offset, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.TemplateFunctionList = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.TemplateFunctionList.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.TemplateFunctionList::class.java, + converter, + ) + } + + + /** + * Get function template + * + * Get a function template using ID. You can use template details in [createFunction](/docs/references/cloud/server-nodejs/functions#create) method. + * + * @param templateId Template ID. + * @return [io.appwrite.models.TemplateFunction] + */ + suspend fun getTemplate( + templateId: String, + ): io.appwrite.models.TemplateFunction { + val apiPath = "/functions/templates/{templateId}" + .replace("{templateId}", templateId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.TemplateFunction = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.TemplateFunction.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.TemplateFunction::class.java, + converter, + ) + } + + + /** + * Download deployment + * + * Get a Deployment's contents by its unique ID. This endpoint supports range requests for partial or streaming file download. + * + * @param functionId Function ID. + * @param deploymentId Deployment ID. + * @return [ByteArray] + */ + suspend fun getDeploymentDownload( + functionId: String, + deploymentId: String, + ): ByteArray { + val apiPath = "/functions/{functionId}/deployments/{deploymentId}/download" + .replace("{functionId}", functionId) + .replace("{deploymentId}", deploymentId) + + val apiParams = mutableMapOf( + "project" to client.config["project"], + ) + return client.call( + "GET", + apiPath, + params = apiParams, + responseType = ByteArray::class.java + ) + } + + /** * List executions * @@ -67,7 +176,7 @@ class Functions(client: Client) : Service(client) { * @param path HTTP path of execution. Path can include query params. Default value is / * @param method HTTP method of execution. Default value is GET. * @param headers HTTP headers of execution. Defaults to empty. - * @param scheduledAt Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param scheduledAt Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. * @return [io.appwrite.models.Execution] */ @JvmOverloads @@ -79,6 +188,7 @@ class Functions(client: Client) : Service(client) { method: io.appwrite.enums.ExecutionMethod? = null, headers: Any? = null, scheduledAt: String? = null, + onProgress: ((UploadProgress) -> Unit)? = null ): io.appwrite.models.Execution { val apiPath = "/functions/{functionId}/executions" .replace("{functionId}", functionId) @@ -92,19 +202,22 @@ class Functions(client: Client) : Service(client) { "scheduledAt" to scheduledAt, ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", + "content-type" to "multipart/form-data", ) val converter: (Any) -> io.appwrite.models.Execution = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Execution.from(map = it as Map) } - return client.call( - "POST", + val idParamName: String? = null + return client.chunkedUpload( apiPath, apiHeaders, apiParams, responseType = io.appwrite.models.Execution::class.java, converter, + paramName, + idParamName, + onProgress, ) } From ec8cd71039b84b118d9ace86a8bedfc4ea19b45a Mon Sep 17 00:00:00 2001 From: root Date: Tue, 20 Aug 2024 11:02:09 +0000 Subject: [PATCH 078/118] chore: update SDKs to new RC version --- README.md | 4 ++-- library/src/main/java/io/appwrite/Client.kt | 2 +- .../src/main/java/io/appwrite/services/Functions.kt | 10 +++------- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index b06e453..548f312 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:6.0.0-rc.1") +implementation("io.appwrite:sdk-for-android:6.0.0-rc.2") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 6.0.0-rc.1 + 6.0.0-rc.2 ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 1e2f464..2c2593b 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -86,7 +86,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "6.0.0-rc.1", + "x-sdk-version" to "6.0.0-rc.2", "x-appwrite-response-format" to "1.6.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index a8fa0d3..c0c0bc0 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -188,7 +188,6 @@ class Functions(client: Client) : Service(client) { method: io.appwrite.enums.ExecutionMethod? = null, headers: Any? = null, scheduledAt: String? = null, - onProgress: ((UploadProgress) -> Unit)? = null ): io.appwrite.models.Execution { val apiPath = "/functions/{functionId}/executions" .replace("{functionId}", functionId) @@ -202,22 +201,19 @@ class Functions(client: Client) : Service(client) { "scheduledAt" to scheduledAt, ) val apiHeaders = mutableMapOf( - "content-type" to "multipart/form-data", + "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Execution = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Execution.from(map = it as Map) } - val idParamName: String? = null - return client.chunkedUpload( + return client.call( + "POST", apiPath, apiHeaders, apiParams, responseType = io.appwrite.models.Execution::class.java, converter, - paramName, - idParamName, - onProgress, ) } From 1717fedc0584c1ab5c0ab46aa5b17301c43d6d17 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 23 Aug 2024 10:48:52 +0000 Subject: [PATCH 079/118] chore: updates for next rc release --- README.md | 4 ++-- docs/examples/java/account/create-anonymous-session.md | 2 +- docs/examples/java/account/create-email-password-session.md | 2 +- docs/examples/java/account/create-email-token.md | 2 +- docs/examples/java/account/create-j-w-t.md | 2 +- docs/examples/java/account/create-magic-u-r-l-token.md | 2 +- docs/examples/java/account/create-mfa-authenticator.md | 2 +- docs/examples/java/account/create-mfa-challenge.md | 2 +- docs/examples/java/account/create-mfa-recovery-codes.md | 2 +- docs/examples/java/account/create-o-auth2session.md | 2 +- docs/examples/java/account/create-o-auth2token.md | 2 +- docs/examples/java/account/create-phone-token.md | 2 +- docs/examples/java/account/create-phone-verification.md | 2 +- docs/examples/java/account/create-push-target.md | 2 +- docs/examples/java/account/create-recovery.md | 2 +- docs/examples/java/account/create-session.md | 2 +- docs/examples/java/account/create-verification.md | 2 +- docs/examples/java/account/create.md | 2 +- docs/examples/java/account/delete-identity.md | 2 +- docs/examples/java/account/delete-mfa-authenticator.md | 2 +- docs/examples/java/account/delete-push-target.md | 2 +- docs/examples/java/account/delete-session.md | 2 +- docs/examples/java/account/delete-sessions.md | 2 +- docs/examples/java/account/get-mfa-recovery-codes.md | 2 +- docs/examples/java/account/get-prefs.md | 2 +- docs/examples/java/account/get-session.md | 2 +- docs/examples/java/account/get.md | 2 +- docs/examples/java/account/list-identities.md | 2 +- docs/examples/java/account/list-logs.md | 2 +- docs/examples/java/account/list-mfa-factors.md | 2 +- docs/examples/java/account/list-sessions.md | 2 +- docs/examples/java/account/update-email.md | 2 +- docs/examples/java/account/update-m-f-a.md | 2 +- docs/examples/java/account/update-magic-u-r-l-session.md | 2 +- docs/examples/java/account/update-mfa-authenticator.md | 2 +- docs/examples/java/account/update-mfa-challenge.md | 2 +- docs/examples/java/account/update-mfa-recovery-codes.md | 2 +- docs/examples/java/account/update-name.md | 2 +- docs/examples/java/account/update-password.md | 2 +- docs/examples/java/account/update-phone-session.md | 2 +- docs/examples/java/account/update-phone-verification.md | 2 +- docs/examples/java/account/update-phone.md | 2 +- docs/examples/java/account/update-prefs.md | 2 +- docs/examples/java/account/update-push-target.md | 2 +- docs/examples/java/account/update-recovery.md | 2 +- docs/examples/java/account/update-session.md | 2 +- docs/examples/java/account/update-status.md | 2 +- docs/examples/java/account/update-verification.md | 2 +- docs/examples/java/avatars/get-browser.md | 2 +- docs/examples/java/avatars/get-credit-card.md | 2 +- docs/examples/java/avatars/get-favicon.md | 2 +- docs/examples/java/avatars/get-flag.md | 2 +- docs/examples/java/avatars/get-image.md | 2 +- docs/examples/java/avatars/get-initials.md | 2 +- docs/examples/java/avatars/get-q-r.md | 2 +- docs/examples/java/databases/create-document.md | 2 +- docs/examples/java/databases/delete-document.md | 2 +- docs/examples/java/databases/get-document.md | 2 +- docs/examples/java/databases/list-documents.md | 2 +- docs/examples/java/databases/update-document.md | 2 +- docs/examples/java/functions/create-execution.md | 2 +- docs/examples/java/functions/get-deployment-download.md | 2 +- docs/examples/java/functions/get-execution.md | 2 +- docs/examples/java/functions/get-template.md | 2 +- docs/examples/java/functions/list-executions.md | 2 +- docs/examples/java/functions/list-templates.md | 2 +- docs/examples/java/graphql/mutation.md | 2 +- docs/examples/java/graphql/query.md | 2 +- docs/examples/java/locale/get.md | 2 +- docs/examples/java/locale/list-codes.md | 2 +- docs/examples/java/locale/list-continents.md | 2 +- docs/examples/java/locale/list-countries-e-u.md | 2 +- docs/examples/java/locale/list-countries-phones.md | 2 +- docs/examples/java/locale/list-countries.md | 2 +- docs/examples/java/locale/list-currencies.md | 2 +- docs/examples/java/locale/list-languages.md | 2 +- docs/examples/java/messaging/create-subscriber.md | 2 +- docs/examples/java/messaging/delete-subscriber.md | 2 +- docs/examples/java/storage/create-file.md | 2 +- docs/examples/java/storage/delete-file.md | 2 +- docs/examples/java/storage/get-file-download.md | 2 +- docs/examples/java/storage/get-file-preview.md | 2 +- docs/examples/java/storage/get-file-view.md | 2 +- docs/examples/java/storage/get-file.md | 2 +- docs/examples/java/storage/list-files.md | 2 +- docs/examples/java/storage/update-file.md | 2 +- docs/examples/java/teams/create-membership.md | 2 +- docs/examples/java/teams/create.md | 2 +- docs/examples/java/teams/delete-membership.md | 2 +- docs/examples/java/teams/delete.md | 2 +- docs/examples/java/teams/get-membership.md | 2 +- docs/examples/java/teams/get-prefs.md | 2 +- docs/examples/java/teams/get.md | 2 +- docs/examples/java/teams/list-memberships.md | 2 +- docs/examples/java/teams/list.md | 2 +- docs/examples/java/teams/update-membership-status.md | 2 +- docs/examples/java/teams/update-membership.md | 2 +- docs/examples/java/teams/update-name.md | 2 +- docs/examples/java/teams/update-prefs.md | 2 +- docs/examples/kotlin/account/create-anonymous-session.md | 2 +- docs/examples/kotlin/account/create-email-password-session.md | 2 +- docs/examples/kotlin/account/create-email-token.md | 2 +- docs/examples/kotlin/account/create-j-w-t.md | 2 +- docs/examples/kotlin/account/create-magic-u-r-l-token.md | 2 +- docs/examples/kotlin/account/create-mfa-authenticator.md | 2 +- docs/examples/kotlin/account/create-mfa-challenge.md | 2 +- docs/examples/kotlin/account/create-mfa-recovery-codes.md | 2 +- docs/examples/kotlin/account/create-o-auth2session.md | 2 +- docs/examples/kotlin/account/create-o-auth2token.md | 2 +- docs/examples/kotlin/account/create-phone-token.md | 2 +- docs/examples/kotlin/account/create-phone-verification.md | 2 +- docs/examples/kotlin/account/create-push-target.md | 2 +- docs/examples/kotlin/account/create-recovery.md | 2 +- docs/examples/kotlin/account/create-session.md | 2 +- docs/examples/kotlin/account/create-verification.md | 2 +- docs/examples/kotlin/account/create.md | 2 +- docs/examples/kotlin/account/delete-identity.md | 2 +- docs/examples/kotlin/account/delete-mfa-authenticator.md | 2 +- docs/examples/kotlin/account/delete-push-target.md | 2 +- docs/examples/kotlin/account/delete-session.md | 2 +- docs/examples/kotlin/account/delete-sessions.md | 2 +- docs/examples/kotlin/account/get-mfa-recovery-codes.md | 2 +- docs/examples/kotlin/account/get-prefs.md | 2 +- docs/examples/kotlin/account/get-session.md | 2 +- docs/examples/kotlin/account/get.md | 2 +- docs/examples/kotlin/account/list-identities.md | 2 +- docs/examples/kotlin/account/list-logs.md | 2 +- docs/examples/kotlin/account/list-mfa-factors.md | 2 +- docs/examples/kotlin/account/list-sessions.md | 2 +- docs/examples/kotlin/account/update-email.md | 2 +- docs/examples/kotlin/account/update-m-f-a.md | 2 +- docs/examples/kotlin/account/update-magic-u-r-l-session.md | 2 +- docs/examples/kotlin/account/update-mfa-authenticator.md | 2 +- docs/examples/kotlin/account/update-mfa-challenge.md | 2 +- docs/examples/kotlin/account/update-mfa-recovery-codes.md | 2 +- docs/examples/kotlin/account/update-name.md | 2 +- docs/examples/kotlin/account/update-password.md | 2 +- docs/examples/kotlin/account/update-phone-session.md | 2 +- docs/examples/kotlin/account/update-phone-verification.md | 2 +- docs/examples/kotlin/account/update-phone.md | 2 +- docs/examples/kotlin/account/update-prefs.md | 2 +- docs/examples/kotlin/account/update-push-target.md | 2 +- docs/examples/kotlin/account/update-recovery.md | 2 +- docs/examples/kotlin/account/update-session.md | 2 +- docs/examples/kotlin/account/update-status.md | 2 +- docs/examples/kotlin/account/update-verification.md | 2 +- docs/examples/kotlin/avatars/get-browser.md | 2 +- docs/examples/kotlin/avatars/get-credit-card.md | 2 +- docs/examples/kotlin/avatars/get-favicon.md | 2 +- docs/examples/kotlin/avatars/get-flag.md | 2 +- docs/examples/kotlin/avatars/get-image.md | 2 +- docs/examples/kotlin/avatars/get-initials.md | 2 +- docs/examples/kotlin/avatars/get-q-r.md | 2 +- docs/examples/kotlin/databases/create-document.md | 2 +- docs/examples/kotlin/databases/delete-document.md | 2 +- docs/examples/kotlin/databases/get-document.md | 2 +- docs/examples/kotlin/databases/list-documents.md | 2 +- docs/examples/kotlin/databases/update-document.md | 2 +- docs/examples/kotlin/functions/create-execution.md | 2 +- docs/examples/kotlin/functions/get-deployment-download.md | 2 +- docs/examples/kotlin/functions/get-execution.md | 2 +- docs/examples/kotlin/functions/get-template.md | 2 +- docs/examples/kotlin/functions/list-executions.md | 2 +- docs/examples/kotlin/functions/list-templates.md | 2 +- docs/examples/kotlin/graphql/mutation.md | 2 +- docs/examples/kotlin/graphql/query.md | 2 +- docs/examples/kotlin/locale/get.md | 2 +- docs/examples/kotlin/locale/list-codes.md | 2 +- docs/examples/kotlin/locale/list-continents.md | 2 +- docs/examples/kotlin/locale/list-countries-e-u.md | 2 +- docs/examples/kotlin/locale/list-countries-phones.md | 2 +- docs/examples/kotlin/locale/list-countries.md | 2 +- docs/examples/kotlin/locale/list-currencies.md | 2 +- docs/examples/kotlin/locale/list-languages.md | 2 +- docs/examples/kotlin/messaging/create-subscriber.md | 2 +- docs/examples/kotlin/messaging/delete-subscriber.md | 2 +- docs/examples/kotlin/storage/create-file.md | 2 +- docs/examples/kotlin/storage/delete-file.md | 2 +- docs/examples/kotlin/storage/get-file-download.md | 2 +- docs/examples/kotlin/storage/get-file-preview.md | 2 +- docs/examples/kotlin/storage/get-file-view.md | 2 +- docs/examples/kotlin/storage/get-file.md | 2 +- docs/examples/kotlin/storage/list-files.md | 2 +- docs/examples/kotlin/storage/update-file.md | 2 +- docs/examples/kotlin/teams/create-membership.md | 2 +- docs/examples/kotlin/teams/create.md | 2 +- docs/examples/kotlin/teams/delete-membership.md | 2 +- docs/examples/kotlin/teams/delete.md | 2 +- docs/examples/kotlin/teams/get-membership.md | 2 +- docs/examples/kotlin/teams/get-prefs.md | 2 +- docs/examples/kotlin/teams/get.md | 2 +- docs/examples/kotlin/teams/list-memberships.md | 2 +- docs/examples/kotlin/teams/list.md | 2 +- docs/examples/kotlin/teams/update-membership-status.md | 2 +- docs/examples/kotlin/teams/update-membership.md | 2 +- docs/examples/kotlin/teams/update-name.md | 2 +- docs/examples/kotlin/teams/update-prefs.md | 2 +- library/src/main/java/io/appwrite/Client.kt | 2 +- 198 files changed, 199 insertions(+), 199 deletions(-) diff --git a/README.md b/README.md index 548f312..d5a6b72 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:6.0.0-rc.2") +implementation("io.appwrite:sdk-for-android:6.0.0-rc.3") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 6.0.0-rc.2 + 6.0.0-rc.3 ``` diff --git a/docs/examples/java/account/create-anonymous-session.md b/docs/examples/java/account/create-anonymous-session.md index 5475d1b..1639cdc 100644 --- a/docs/examples/java/account/create-anonymous-session.md +++ b/docs/examples/java/account/create-anonymous-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-email-password-session.md b/docs/examples/java/account/create-email-password-session.md index f4c59eb..817bda0 100644 --- a/docs/examples/java/account/create-email-password-session.md +++ b/docs/examples/java/account/create-email-password-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-email-token.md b/docs/examples/java/account/create-email-token.md index d1b91c9..a4bc83b 100644 --- a/docs/examples/java/account/create-email-token.md +++ b/docs/examples/java/account/create-email-token.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-j-w-t.md b/docs/examples/java/account/create-j-w-t.md index 481259e..9aeb29c 100644 --- a/docs/examples/java/account/create-j-w-t.md +++ b/docs/examples/java/account/create-j-w-t.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-magic-u-r-l-token.md b/docs/examples/java/account/create-magic-u-r-l-token.md index 3c91e9b..e57758a 100644 --- a/docs/examples/java/account/create-magic-u-r-l-token.md +++ b/docs/examples/java/account/create-magic-u-r-l-token.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-mfa-authenticator.md b/docs/examples/java/account/create-mfa-authenticator.md index 35ec26c..b8b06c3 100644 --- a/docs/examples/java/account/create-mfa-authenticator.md +++ b/docs/examples/java/account/create-mfa-authenticator.md @@ -5,7 +5,7 @@ import io.appwrite.enums.AuthenticatorType; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-mfa-challenge.md b/docs/examples/java/account/create-mfa-challenge.md index f930b56..d9d9bb6 100644 --- a/docs/examples/java/account/create-mfa-challenge.md +++ b/docs/examples/java/account/create-mfa-challenge.md @@ -5,7 +5,7 @@ import io.appwrite.enums.AuthenticationFactor; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-mfa-recovery-codes.md b/docs/examples/java/account/create-mfa-recovery-codes.md index 48f8582..6e23ad2 100644 --- a/docs/examples/java/account/create-mfa-recovery-codes.md +++ b/docs/examples/java/account/create-mfa-recovery-codes.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-o-auth2session.md b/docs/examples/java/account/create-o-auth2session.md index fafd8e1..59f5b41 100644 --- a/docs/examples/java/account/create-o-auth2session.md +++ b/docs/examples/java/account/create-o-auth2session.md @@ -5,7 +5,7 @@ import io.appwrite.enums.OAuthProvider; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-o-auth2token.md b/docs/examples/java/account/create-o-auth2token.md index 72fe76e..6103196 100644 --- a/docs/examples/java/account/create-o-auth2token.md +++ b/docs/examples/java/account/create-o-auth2token.md @@ -5,7 +5,7 @@ import io.appwrite.enums.OAuthProvider; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-phone-token.md b/docs/examples/java/account/create-phone-token.md index 92eeee8..a1ad85b 100644 --- a/docs/examples/java/account/create-phone-token.md +++ b/docs/examples/java/account/create-phone-token.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-phone-verification.md b/docs/examples/java/account/create-phone-verification.md index c560065..cca9283 100644 --- a/docs/examples/java/account/create-phone-verification.md +++ b/docs/examples/java/account/create-phone-verification.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-push-target.md b/docs/examples/java/account/create-push-target.md index 127aec0..34e8fcb 100644 --- a/docs/examples/java/account/create-push-target.md +++ b/docs/examples/java/account/create-push-target.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-recovery.md b/docs/examples/java/account/create-recovery.md index 09f8fb9..4d2af8b 100644 --- a/docs/examples/java/account/create-recovery.md +++ b/docs/examples/java/account/create-recovery.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-session.md b/docs/examples/java/account/create-session.md index f54f57c..71d11a5 100644 --- a/docs/examples/java/account/create-session.md +++ b/docs/examples/java/account/create-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-verification.md b/docs/examples/java/account/create-verification.md index c52ee2b..be4f7c9 100644 --- a/docs/examples/java/account/create-verification.md +++ b/docs/examples/java/account/create-verification.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create.md b/docs/examples/java/account/create.md index 15d9b73..e721248 100644 --- a/docs/examples/java/account/create.md +++ b/docs/examples/java/account/create.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/delete-identity.md b/docs/examples/java/account/delete-identity.md index a84f57b..6a62ea2 100644 --- a/docs/examples/java/account/delete-identity.md +++ b/docs/examples/java/account/delete-identity.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/delete-mfa-authenticator.md b/docs/examples/java/account/delete-mfa-authenticator.md index b7c7442..bb6cb09 100644 --- a/docs/examples/java/account/delete-mfa-authenticator.md +++ b/docs/examples/java/account/delete-mfa-authenticator.md @@ -5,7 +5,7 @@ import io.appwrite.enums.AuthenticatorType; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/delete-push-target.md b/docs/examples/java/account/delete-push-target.md index 0b51801..c320800 100644 --- a/docs/examples/java/account/delete-push-target.md +++ b/docs/examples/java/account/delete-push-target.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/delete-session.md b/docs/examples/java/account/delete-session.md index 602752e..2efc0f6 100644 --- a/docs/examples/java/account/delete-session.md +++ b/docs/examples/java/account/delete-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/delete-sessions.md b/docs/examples/java/account/delete-sessions.md index 8c48aaf..d4c4380 100644 --- a/docs/examples/java/account/delete-sessions.md +++ b/docs/examples/java/account/delete-sessions.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/get-mfa-recovery-codes.md b/docs/examples/java/account/get-mfa-recovery-codes.md index f42101c..acf5984 100644 --- a/docs/examples/java/account/get-mfa-recovery-codes.md +++ b/docs/examples/java/account/get-mfa-recovery-codes.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/get-prefs.md b/docs/examples/java/account/get-prefs.md index 6a40dc7..0fea3fe 100644 --- a/docs/examples/java/account/get-prefs.md +++ b/docs/examples/java/account/get-prefs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/get-session.md b/docs/examples/java/account/get-session.md index 912a52d..3ce4ab5 100644 --- a/docs/examples/java/account/get-session.md +++ b/docs/examples/java/account/get-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/get.md b/docs/examples/java/account/get.md index 9a99a75..5c25ed0 100644 --- a/docs/examples/java/account/get.md +++ b/docs/examples/java/account/get.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/list-identities.md b/docs/examples/java/account/list-identities.md index 38ccc92..7f9449d 100644 --- a/docs/examples/java/account/list-identities.md +++ b/docs/examples/java/account/list-identities.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/list-logs.md b/docs/examples/java/account/list-logs.md index 7f39d84..3aa66e2 100644 --- a/docs/examples/java/account/list-logs.md +++ b/docs/examples/java/account/list-logs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/list-mfa-factors.md b/docs/examples/java/account/list-mfa-factors.md index f531988..a10cb8d 100644 --- a/docs/examples/java/account/list-mfa-factors.md +++ b/docs/examples/java/account/list-mfa-factors.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/list-sessions.md b/docs/examples/java/account/list-sessions.md index 6571458..aa8d37b 100644 --- a/docs/examples/java/account/list-sessions.md +++ b/docs/examples/java/account/list-sessions.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-email.md b/docs/examples/java/account/update-email.md index 5e99b73..98cf907 100644 --- a/docs/examples/java/account/update-email.md +++ b/docs/examples/java/account/update-email.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-m-f-a.md b/docs/examples/java/account/update-m-f-a.md index f8420b0..620a20c 100644 --- a/docs/examples/java/account/update-m-f-a.md +++ b/docs/examples/java/account/update-m-f-a.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); 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 1d40827..1b79b73 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 @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-mfa-authenticator.md b/docs/examples/java/account/update-mfa-authenticator.md index 09506e5..74321be 100644 --- a/docs/examples/java/account/update-mfa-authenticator.md +++ b/docs/examples/java/account/update-mfa-authenticator.md @@ -5,7 +5,7 @@ import io.appwrite.enums.AuthenticatorType; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-mfa-challenge.md b/docs/examples/java/account/update-mfa-challenge.md index 9fc3e39..a92f007 100644 --- a/docs/examples/java/account/update-mfa-challenge.md +++ b/docs/examples/java/account/update-mfa-challenge.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-mfa-recovery-codes.md b/docs/examples/java/account/update-mfa-recovery-codes.md index 36795a0..2aa82b1 100644 --- a/docs/examples/java/account/update-mfa-recovery-codes.md +++ b/docs/examples/java/account/update-mfa-recovery-codes.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-name.md b/docs/examples/java/account/update-name.md index f9a0185..40a5e2e 100644 --- a/docs/examples/java/account/update-name.md +++ b/docs/examples/java/account/update-name.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-password.md b/docs/examples/java/account/update-password.md index 676caad..355c06d 100644 --- a/docs/examples/java/account/update-password.md +++ b/docs/examples/java/account/update-password.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-phone-session.md b/docs/examples/java/account/update-phone-session.md index 5f9e433..042238e 100644 --- a/docs/examples/java/account/update-phone-session.md +++ b/docs/examples/java/account/update-phone-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-phone-verification.md b/docs/examples/java/account/update-phone-verification.md index 739b6d8..ba7b69c 100644 --- a/docs/examples/java/account/update-phone-verification.md +++ b/docs/examples/java/account/update-phone-verification.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-phone.md b/docs/examples/java/account/update-phone.md index adbb098..b3ce0f6 100644 --- a/docs/examples/java/account/update-phone.md +++ b/docs/examples/java/account/update-phone.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-prefs.md b/docs/examples/java/account/update-prefs.md index ad42651..d746067 100644 --- a/docs/examples/java/account/update-prefs.md +++ b/docs/examples/java/account/update-prefs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-push-target.md b/docs/examples/java/account/update-push-target.md index 7357572..f9491e0 100644 --- a/docs/examples/java/account/update-push-target.md +++ b/docs/examples/java/account/update-push-target.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-recovery.md b/docs/examples/java/account/update-recovery.md index f8067d0..e172f12 100644 --- a/docs/examples/java/account/update-recovery.md +++ b/docs/examples/java/account/update-recovery.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-session.md b/docs/examples/java/account/update-session.md index 2b6df41..b3e8706 100644 --- a/docs/examples/java/account/update-session.md +++ b/docs/examples/java/account/update-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-status.md b/docs/examples/java/account/update-status.md index 38cf5cf..2216649 100644 --- a/docs/examples/java/account/update-status.md +++ b/docs/examples/java/account/update-status.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-verification.md b/docs/examples/java/account/update-verification.md index 8cfbbb6..2594943 100644 --- a/docs/examples/java/account/update-verification.md +++ b/docs/examples/java/account/update-verification.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/avatars/get-browser.md b/docs/examples/java/avatars/get-browser.md index a11df7e..f7e8651 100644 --- a/docs/examples/java/avatars/get-browser.md +++ b/docs/examples/java/avatars/get-browser.md @@ -5,7 +5,7 @@ import io.appwrite.enums.Browser; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-credit-card.md b/docs/examples/java/avatars/get-credit-card.md index f1e2b39..5b1ee06 100644 --- a/docs/examples/java/avatars/get-credit-card.md +++ b/docs/examples/java/avatars/get-credit-card.md @@ -5,7 +5,7 @@ import io.appwrite.enums.CreditCard; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-favicon.md b/docs/examples/java/avatars/get-favicon.md index 5cfd60b..05bf590 100644 --- a/docs/examples/java/avatars/get-favicon.md +++ b/docs/examples/java/avatars/get-favicon.md @@ -4,7 +4,7 @@ import io.appwrite.services.Avatars; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-flag.md b/docs/examples/java/avatars/get-flag.md index 492ecc0..6a2185c 100644 --- a/docs/examples/java/avatars/get-flag.md +++ b/docs/examples/java/avatars/get-flag.md @@ -5,7 +5,7 @@ import io.appwrite.enums.Flag; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-image.md b/docs/examples/java/avatars/get-image.md index 4fc1e35..78fbf98 100644 --- a/docs/examples/java/avatars/get-image.md +++ b/docs/examples/java/avatars/get-image.md @@ -4,7 +4,7 @@ import io.appwrite.services.Avatars; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-initials.md b/docs/examples/java/avatars/get-initials.md index 9b28608..621798b 100644 --- a/docs/examples/java/avatars/get-initials.md +++ b/docs/examples/java/avatars/get-initials.md @@ -4,7 +4,7 @@ import io.appwrite.services.Avatars; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-q-r.md b/docs/examples/java/avatars/get-q-r.md index 29446d5..fc8bc43 100644 --- a/docs/examples/java/avatars/get-q-r.md +++ b/docs/examples/java/avatars/get-q-r.md @@ -4,7 +4,7 @@ import io.appwrite.services.Avatars; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index 87d33bd..6c7e068 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -4,7 +4,7 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Databases databases = new Databases(client); diff --git a/docs/examples/java/databases/delete-document.md b/docs/examples/java/databases/delete-document.md index 2fb3acc..0cbd6b5 100644 --- a/docs/examples/java/databases/delete-document.md +++ b/docs/examples/java/databases/delete-document.md @@ -4,7 +4,7 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Databases databases = new Databases(client); diff --git a/docs/examples/java/databases/get-document.md b/docs/examples/java/databases/get-document.md index 0edce73..0918c88 100644 --- a/docs/examples/java/databases/get-document.md +++ b/docs/examples/java/databases/get-document.md @@ -4,7 +4,7 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Databases databases = new Databases(client); diff --git a/docs/examples/java/databases/list-documents.md b/docs/examples/java/databases/list-documents.md index f256e14..9cc722b 100644 --- a/docs/examples/java/databases/list-documents.md +++ b/docs/examples/java/databases/list-documents.md @@ -4,7 +4,7 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Databases databases = new Databases(client); diff --git a/docs/examples/java/databases/update-document.md b/docs/examples/java/databases/update-document.md index 16f89df..ccfb498 100644 --- a/docs/examples/java/databases/update-document.md +++ b/docs/examples/java/databases/update-document.md @@ -4,7 +4,7 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Databases databases = new Databases(client); diff --git a/docs/examples/java/functions/create-execution.md b/docs/examples/java/functions/create-execution.md index 5d4cc4d..845f02e 100644 --- a/docs/examples/java/functions/create-execution.md +++ b/docs/examples/java/functions/create-execution.md @@ -4,7 +4,7 @@ import io.appwrite.services.Functions; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Functions functions = new Functions(client); diff --git a/docs/examples/java/functions/get-deployment-download.md b/docs/examples/java/functions/get-deployment-download.md index 4a93187..200cdf2 100644 --- a/docs/examples/java/functions/get-deployment-download.md +++ b/docs/examples/java/functions/get-deployment-download.md @@ -4,7 +4,7 @@ import io.appwrite.services.Functions; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Functions functions = new Functions(client); diff --git a/docs/examples/java/functions/get-execution.md b/docs/examples/java/functions/get-execution.md index 8231445..c53ef0e 100644 --- a/docs/examples/java/functions/get-execution.md +++ b/docs/examples/java/functions/get-execution.md @@ -4,7 +4,7 @@ import io.appwrite.services.Functions; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Functions functions = new Functions(client); diff --git a/docs/examples/java/functions/get-template.md b/docs/examples/java/functions/get-template.md index f1043f3..af9efc7 100644 --- a/docs/examples/java/functions/get-template.md +++ b/docs/examples/java/functions/get-template.md @@ -4,7 +4,7 @@ import io.appwrite.services.Functions; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Functions functions = new Functions(client); diff --git a/docs/examples/java/functions/list-executions.md b/docs/examples/java/functions/list-executions.md index ac793fa..b796dc9 100644 --- a/docs/examples/java/functions/list-executions.md +++ b/docs/examples/java/functions/list-executions.md @@ -4,7 +4,7 @@ import io.appwrite.services.Functions; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Functions functions = new Functions(client); diff --git a/docs/examples/java/functions/list-templates.md b/docs/examples/java/functions/list-templates.md index bd99c31..6c051f3 100644 --- a/docs/examples/java/functions/list-templates.md +++ b/docs/examples/java/functions/list-templates.md @@ -4,7 +4,7 @@ import io.appwrite.services.Functions; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Functions functions = new Functions(client); diff --git a/docs/examples/java/graphql/mutation.md b/docs/examples/java/graphql/mutation.md index 5e49fcb..b79903b 100644 --- a/docs/examples/java/graphql/mutation.md +++ b/docs/examples/java/graphql/mutation.md @@ -4,7 +4,7 @@ import io.appwrite.services.Graphql; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Graphql graphql = new Graphql(client); diff --git a/docs/examples/java/graphql/query.md b/docs/examples/java/graphql/query.md index 2d39c16..82bad13 100644 --- a/docs/examples/java/graphql/query.md +++ b/docs/examples/java/graphql/query.md @@ -4,7 +4,7 @@ import io.appwrite.services.Graphql; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Graphql graphql = new Graphql(client); diff --git a/docs/examples/java/locale/get.md b/docs/examples/java/locale/get.md index 4883b21..29b542f 100644 --- a/docs/examples/java/locale/get.md +++ b/docs/examples/java/locale/get.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-codes.md b/docs/examples/java/locale/list-codes.md index caddf6c..d8c9a0b 100644 --- a/docs/examples/java/locale/list-codes.md +++ b/docs/examples/java/locale/list-codes.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-continents.md b/docs/examples/java/locale/list-continents.md index 634f471..cf43045 100644 --- a/docs/examples/java/locale/list-continents.md +++ b/docs/examples/java/locale/list-continents.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-countries-e-u.md b/docs/examples/java/locale/list-countries-e-u.md index 798ea34..b7b56ab 100644 --- a/docs/examples/java/locale/list-countries-e-u.md +++ b/docs/examples/java/locale/list-countries-e-u.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-countries-phones.md b/docs/examples/java/locale/list-countries-phones.md index 0828547..c3598c0 100644 --- a/docs/examples/java/locale/list-countries-phones.md +++ b/docs/examples/java/locale/list-countries-phones.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-countries.md b/docs/examples/java/locale/list-countries.md index b56ab5c..91ac052 100644 --- a/docs/examples/java/locale/list-countries.md +++ b/docs/examples/java/locale/list-countries.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-currencies.md b/docs/examples/java/locale/list-currencies.md index ab014b5..5233004 100644 --- a/docs/examples/java/locale/list-currencies.md +++ b/docs/examples/java/locale/list-currencies.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-languages.md b/docs/examples/java/locale/list-languages.md index 8ef5723..0f10563 100644 --- a/docs/examples/java/locale/list-languages.md +++ b/docs/examples/java/locale/list-languages.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/messaging/create-subscriber.md b/docs/examples/java/messaging/create-subscriber.md index d1ea18b..e8fa79f 100644 --- a/docs/examples/java/messaging/create-subscriber.md +++ b/docs/examples/java/messaging/create-subscriber.md @@ -4,7 +4,7 @@ import io.appwrite.services.Messaging; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Messaging messaging = new Messaging(client); diff --git a/docs/examples/java/messaging/delete-subscriber.md b/docs/examples/java/messaging/delete-subscriber.md index 5fa1b57..7e5b3d2 100644 --- a/docs/examples/java/messaging/delete-subscriber.md +++ b/docs/examples/java/messaging/delete-subscriber.md @@ -4,7 +4,7 @@ import io.appwrite.services.Messaging; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Messaging messaging = new Messaging(client); diff --git a/docs/examples/java/storage/create-file.md b/docs/examples/java/storage/create-file.md index 716ef6c..bc9ebed 100644 --- a/docs/examples/java/storage/create-file.md +++ b/docs/examples/java/storage/create-file.md @@ -5,7 +5,7 @@ import io.appwrite.services.Storage; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/delete-file.md b/docs/examples/java/storage/delete-file.md index e4b4a2b..eaeb47b 100644 --- a/docs/examples/java/storage/delete-file.md +++ b/docs/examples/java/storage/delete-file.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/get-file-download.md b/docs/examples/java/storage/get-file-download.md index 304bbfe..d0fdc41 100644 --- a/docs/examples/java/storage/get-file-download.md +++ b/docs/examples/java/storage/get-file-download.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/get-file-preview.md b/docs/examples/java/storage/get-file-preview.md index 267b16f..c935e6f 100644 --- a/docs/examples/java/storage/get-file-preview.md +++ b/docs/examples/java/storage/get-file-preview.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/get-file-view.md b/docs/examples/java/storage/get-file-view.md index ae40098..bbfd04d 100644 --- a/docs/examples/java/storage/get-file-view.md +++ b/docs/examples/java/storage/get-file-view.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/get-file.md b/docs/examples/java/storage/get-file.md index 86118c0..a63122f 100644 --- a/docs/examples/java/storage/get-file.md +++ b/docs/examples/java/storage/get-file.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/list-files.md b/docs/examples/java/storage/list-files.md index 3ef0ace..dc327fc 100644 --- a/docs/examples/java/storage/list-files.md +++ b/docs/examples/java/storage/list-files.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/update-file.md b/docs/examples/java/storage/update-file.md index 6a90a61..ed81821 100644 --- a/docs/examples/java/storage/update-file.md +++ b/docs/examples/java/storage/update-file.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/teams/create-membership.md b/docs/examples/java/teams/create-membership.md index bca117a..b30f176 100644 --- a/docs/examples/java/teams/create-membership.md +++ b/docs/examples/java/teams/create-membership.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/create.md b/docs/examples/java/teams/create.md index 6644e24..a0d4f07 100644 --- a/docs/examples/java/teams/create.md +++ b/docs/examples/java/teams/create.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/delete-membership.md b/docs/examples/java/teams/delete-membership.md index 953f461..7f9189f 100644 --- a/docs/examples/java/teams/delete-membership.md +++ b/docs/examples/java/teams/delete-membership.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/delete.md b/docs/examples/java/teams/delete.md index d4b6076..2f4e861 100644 --- a/docs/examples/java/teams/delete.md +++ b/docs/examples/java/teams/delete.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/get-membership.md b/docs/examples/java/teams/get-membership.md index 425e6f3..529feb2 100644 --- a/docs/examples/java/teams/get-membership.md +++ b/docs/examples/java/teams/get-membership.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/get-prefs.md b/docs/examples/java/teams/get-prefs.md index a36be58..61da757 100644 --- a/docs/examples/java/teams/get-prefs.md +++ b/docs/examples/java/teams/get-prefs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/get.md b/docs/examples/java/teams/get.md index 7ecfbab..39fe4d4 100644 --- a/docs/examples/java/teams/get.md +++ b/docs/examples/java/teams/get.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/list-memberships.md b/docs/examples/java/teams/list-memberships.md index 6a7e056..58430f0 100644 --- a/docs/examples/java/teams/list-memberships.md +++ b/docs/examples/java/teams/list-memberships.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/list.md b/docs/examples/java/teams/list.md index 94b65d6..914509f 100644 --- a/docs/examples/java/teams/list.md +++ b/docs/examples/java/teams/list.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/update-membership-status.md b/docs/examples/java/teams/update-membership-status.md index ffb722a..5134613 100644 --- a/docs/examples/java/teams/update-membership-status.md +++ b/docs/examples/java/teams/update-membership-status.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/update-membership.md b/docs/examples/java/teams/update-membership.md index 478a94d..a60c2a0 100644 --- a/docs/examples/java/teams/update-membership.md +++ b/docs/examples/java/teams/update-membership.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/update-name.md b/docs/examples/java/teams/update-name.md index 219bece..54f218e 100644 --- a/docs/examples/java/teams/update-name.md +++ b/docs/examples/java/teams/update-name.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/update-prefs.md b/docs/examples/java/teams/update-prefs.md index e4fb344..eaa161e 100644 --- a/docs/examples/java/teams/update-prefs.md +++ b/docs/examples/java/teams/update-prefs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/kotlin/account/create-anonymous-session.md b/docs/examples/kotlin/account/create-anonymous-session.md index 6731b6c..50a011a 100644 --- a/docs/examples/kotlin/account/create-anonymous-session.md +++ b/docs/examples/kotlin/account/create-anonymous-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-email-password-session.md b/docs/examples/kotlin/account/create-email-password-session.md index 88123a5..8c44759 100644 --- a/docs/examples/kotlin/account/create-email-password-session.md +++ b/docs/examples/kotlin/account/create-email-password-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-email-token.md b/docs/examples/kotlin/account/create-email-token.md index adaa5eb..219e793 100644 --- a/docs/examples/kotlin/account/create-email-token.md +++ b/docs/examples/kotlin/account/create-email-token.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-j-w-t.md b/docs/examples/kotlin/account/create-j-w-t.md index 34e6b1a..50014d4 100644 --- a/docs/examples/kotlin/account/create-j-w-t.md +++ b/docs/examples/kotlin/account/create-j-w-t.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-magic-u-r-l-token.md b/docs/examples/kotlin/account/create-magic-u-r-l-token.md index 10c9427..905e942 100644 --- a/docs/examples/kotlin/account/create-magic-u-r-l-token.md +++ b/docs/examples/kotlin/account/create-magic-u-r-l-token.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-mfa-authenticator.md b/docs/examples/kotlin/account/create-mfa-authenticator.md index 2b60be3..dacf56a 100644 --- a/docs/examples/kotlin/account/create-mfa-authenticator.md +++ b/docs/examples/kotlin/account/create-mfa-authenticator.md @@ -5,7 +5,7 @@ import io.appwrite.enums.AuthenticatorType val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-mfa-challenge.md b/docs/examples/kotlin/account/create-mfa-challenge.md index f7554de..22c9658 100644 --- a/docs/examples/kotlin/account/create-mfa-challenge.md +++ b/docs/examples/kotlin/account/create-mfa-challenge.md @@ -5,7 +5,7 @@ import io.appwrite.enums.AuthenticationFactor val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-mfa-recovery-codes.md b/docs/examples/kotlin/account/create-mfa-recovery-codes.md index 5618b3b..364bc0e 100644 --- a/docs/examples/kotlin/account/create-mfa-recovery-codes.md +++ b/docs/examples/kotlin/account/create-mfa-recovery-codes.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-o-auth2session.md b/docs/examples/kotlin/account/create-o-auth2session.md index e2aebc9..fc9d822 100644 --- a/docs/examples/kotlin/account/create-o-auth2session.md +++ b/docs/examples/kotlin/account/create-o-auth2session.md @@ -5,7 +5,7 @@ import io.appwrite.enums.OAuthProvider val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-o-auth2token.md b/docs/examples/kotlin/account/create-o-auth2token.md index 71e58db..11a814b 100644 --- a/docs/examples/kotlin/account/create-o-auth2token.md +++ b/docs/examples/kotlin/account/create-o-auth2token.md @@ -5,7 +5,7 @@ import io.appwrite.enums.OAuthProvider val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-phone-token.md b/docs/examples/kotlin/account/create-phone-token.md index 16e744c..56b53c2 100644 --- a/docs/examples/kotlin/account/create-phone-token.md +++ b/docs/examples/kotlin/account/create-phone-token.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-phone-verification.md b/docs/examples/kotlin/account/create-phone-verification.md index 74a05a0..531aead 100644 --- a/docs/examples/kotlin/account/create-phone-verification.md +++ b/docs/examples/kotlin/account/create-phone-verification.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-push-target.md b/docs/examples/kotlin/account/create-push-target.md index 80b8221..7dd2101 100644 --- a/docs/examples/kotlin/account/create-push-target.md +++ b/docs/examples/kotlin/account/create-push-target.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-recovery.md b/docs/examples/kotlin/account/create-recovery.md index 9b4f0db..d03bd32 100644 --- a/docs/examples/kotlin/account/create-recovery.md +++ b/docs/examples/kotlin/account/create-recovery.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-session.md b/docs/examples/kotlin/account/create-session.md index 8eab36b..2b3da6d 100644 --- a/docs/examples/kotlin/account/create-session.md +++ b/docs/examples/kotlin/account/create-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-verification.md b/docs/examples/kotlin/account/create-verification.md index 5c2d869..54174be 100644 --- a/docs/examples/kotlin/account/create-verification.md +++ b/docs/examples/kotlin/account/create-verification.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create.md b/docs/examples/kotlin/account/create.md index 2707908..2ee3ae4 100644 --- a/docs/examples/kotlin/account/create.md +++ b/docs/examples/kotlin/account/create.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/delete-identity.md b/docs/examples/kotlin/account/delete-identity.md index decb1b0..1e5d206 100644 --- a/docs/examples/kotlin/account/delete-identity.md +++ b/docs/examples/kotlin/account/delete-identity.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/delete-mfa-authenticator.md b/docs/examples/kotlin/account/delete-mfa-authenticator.md index a9a9fd8..48220b2 100644 --- a/docs/examples/kotlin/account/delete-mfa-authenticator.md +++ b/docs/examples/kotlin/account/delete-mfa-authenticator.md @@ -5,7 +5,7 @@ import io.appwrite.enums.AuthenticatorType val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/delete-push-target.md b/docs/examples/kotlin/account/delete-push-target.md index a1e5519..e67b180 100644 --- a/docs/examples/kotlin/account/delete-push-target.md +++ b/docs/examples/kotlin/account/delete-push-target.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/delete-session.md b/docs/examples/kotlin/account/delete-session.md index 4d49833..0990989 100644 --- a/docs/examples/kotlin/account/delete-session.md +++ b/docs/examples/kotlin/account/delete-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/delete-sessions.md b/docs/examples/kotlin/account/delete-sessions.md index d8bf871..8c464e0 100644 --- a/docs/examples/kotlin/account/delete-sessions.md +++ b/docs/examples/kotlin/account/delete-sessions.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/get-mfa-recovery-codes.md b/docs/examples/kotlin/account/get-mfa-recovery-codes.md index bdd2908..bd12e83 100644 --- a/docs/examples/kotlin/account/get-mfa-recovery-codes.md +++ b/docs/examples/kotlin/account/get-mfa-recovery-codes.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/get-prefs.md b/docs/examples/kotlin/account/get-prefs.md index a4fefc5..9227eff 100644 --- a/docs/examples/kotlin/account/get-prefs.md +++ b/docs/examples/kotlin/account/get-prefs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/get-session.md b/docs/examples/kotlin/account/get-session.md index b18c532..42e61fd 100644 --- a/docs/examples/kotlin/account/get-session.md +++ b/docs/examples/kotlin/account/get-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/get.md b/docs/examples/kotlin/account/get.md index 1718bdd..8c90304 100644 --- a/docs/examples/kotlin/account/get.md +++ b/docs/examples/kotlin/account/get.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/list-identities.md b/docs/examples/kotlin/account/list-identities.md index e553a88..53e388d 100644 --- a/docs/examples/kotlin/account/list-identities.md +++ b/docs/examples/kotlin/account/list-identities.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/list-logs.md b/docs/examples/kotlin/account/list-logs.md index 2ee8214..683a94b 100644 --- a/docs/examples/kotlin/account/list-logs.md +++ b/docs/examples/kotlin/account/list-logs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/list-mfa-factors.md b/docs/examples/kotlin/account/list-mfa-factors.md index eddefdc..ecfa6c2 100644 --- a/docs/examples/kotlin/account/list-mfa-factors.md +++ b/docs/examples/kotlin/account/list-mfa-factors.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/list-sessions.md b/docs/examples/kotlin/account/list-sessions.md index b484144..2da413d 100644 --- a/docs/examples/kotlin/account/list-sessions.md +++ b/docs/examples/kotlin/account/list-sessions.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-email.md b/docs/examples/kotlin/account/update-email.md index b8f759f..072d6db 100644 --- a/docs/examples/kotlin/account/update-email.md +++ b/docs/examples/kotlin/account/update-email.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-m-f-a.md b/docs/examples/kotlin/account/update-m-f-a.md index 8940cf4..3cac098 100644 --- a/docs/examples/kotlin/account/update-m-f-a.md +++ b/docs/examples/kotlin/account/update-m-f-a.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) 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 09029e4..52d0ad7 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 @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-mfa-authenticator.md b/docs/examples/kotlin/account/update-mfa-authenticator.md index 5889931..321f25b 100644 --- a/docs/examples/kotlin/account/update-mfa-authenticator.md +++ b/docs/examples/kotlin/account/update-mfa-authenticator.md @@ -5,7 +5,7 @@ import io.appwrite.enums.AuthenticatorType val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-mfa-challenge.md b/docs/examples/kotlin/account/update-mfa-challenge.md index d63401b..021f515 100644 --- a/docs/examples/kotlin/account/update-mfa-challenge.md +++ b/docs/examples/kotlin/account/update-mfa-challenge.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-mfa-recovery-codes.md b/docs/examples/kotlin/account/update-mfa-recovery-codes.md index 69b41c9..d4ea7f5 100644 --- a/docs/examples/kotlin/account/update-mfa-recovery-codes.md +++ b/docs/examples/kotlin/account/update-mfa-recovery-codes.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-name.md b/docs/examples/kotlin/account/update-name.md index 6658a1b..374f84f 100644 --- a/docs/examples/kotlin/account/update-name.md +++ b/docs/examples/kotlin/account/update-name.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-password.md b/docs/examples/kotlin/account/update-password.md index fe3b8ce..edf5117 100644 --- a/docs/examples/kotlin/account/update-password.md +++ b/docs/examples/kotlin/account/update-password.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-phone-session.md b/docs/examples/kotlin/account/update-phone-session.md index 7414b2e..93e080d 100644 --- a/docs/examples/kotlin/account/update-phone-session.md +++ b/docs/examples/kotlin/account/update-phone-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-phone-verification.md b/docs/examples/kotlin/account/update-phone-verification.md index e1b264b..226b21d 100644 --- a/docs/examples/kotlin/account/update-phone-verification.md +++ b/docs/examples/kotlin/account/update-phone-verification.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-phone.md b/docs/examples/kotlin/account/update-phone.md index c4ae4f5..772c099 100644 --- a/docs/examples/kotlin/account/update-phone.md +++ b/docs/examples/kotlin/account/update-phone.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-prefs.md b/docs/examples/kotlin/account/update-prefs.md index 62129a2..c5c7a3d 100644 --- a/docs/examples/kotlin/account/update-prefs.md +++ b/docs/examples/kotlin/account/update-prefs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-push-target.md b/docs/examples/kotlin/account/update-push-target.md index 8dfa97c..c6e6f21 100644 --- a/docs/examples/kotlin/account/update-push-target.md +++ b/docs/examples/kotlin/account/update-push-target.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-recovery.md b/docs/examples/kotlin/account/update-recovery.md index 6c83496..b448114 100644 --- a/docs/examples/kotlin/account/update-recovery.md +++ b/docs/examples/kotlin/account/update-recovery.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-session.md b/docs/examples/kotlin/account/update-session.md index 85dec29..43d84e1 100644 --- a/docs/examples/kotlin/account/update-session.md +++ b/docs/examples/kotlin/account/update-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-status.md b/docs/examples/kotlin/account/update-status.md index 4bf9faf..4f44ce1 100644 --- a/docs/examples/kotlin/account/update-status.md +++ b/docs/examples/kotlin/account/update-status.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-verification.md b/docs/examples/kotlin/account/update-verification.md index 4bd5459..3c9c465 100644 --- a/docs/examples/kotlin/account/update-verification.md +++ b/docs/examples/kotlin/account/update-verification.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/avatars/get-browser.md b/docs/examples/kotlin/avatars/get-browser.md index 6f2a45c..34f6f28 100644 --- a/docs/examples/kotlin/avatars/get-browser.md +++ b/docs/examples/kotlin/avatars/get-browser.md @@ -5,7 +5,7 @@ import io.appwrite.enums.Browser val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-credit-card.md b/docs/examples/kotlin/avatars/get-credit-card.md index a85c8c8..52eea79 100644 --- a/docs/examples/kotlin/avatars/get-credit-card.md +++ b/docs/examples/kotlin/avatars/get-credit-card.md @@ -5,7 +5,7 @@ import io.appwrite.enums.CreditCard val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-favicon.md b/docs/examples/kotlin/avatars/get-favicon.md index eee47e1..5f83bdd 100644 --- a/docs/examples/kotlin/avatars/get-favicon.md +++ b/docs/examples/kotlin/avatars/get-favicon.md @@ -4,7 +4,7 @@ import io.appwrite.services.Avatars val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-flag.md b/docs/examples/kotlin/avatars/get-flag.md index 0689ba1..cfd5d01 100644 --- a/docs/examples/kotlin/avatars/get-flag.md +++ b/docs/examples/kotlin/avatars/get-flag.md @@ -5,7 +5,7 @@ import io.appwrite.enums.Flag val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-image.md b/docs/examples/kotlin/avatars/get-image.md index 7042757..a9a7c2a 100644 --- a/docs/examples/kotlin/avatars/get-image.md +++ b/docs/examples/kotlin/avatars/get-image.md @@ -4,7 +4,7 @@ import io.appwrite.services.Avatars val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-initials.md b/docs/examples/kotlin/avatars/get-initials.md index fd52a3b..bd2ae1b 100644 --- a/docs/examples/kotlin/avatars/get-initials.md +++ b/docs/examples/kotlin/avatars/get-initials.md @@ -4,7 +4,7 @@ import io.appwrite.services.Avatars val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-q-r.md b/docs/examples/kotlin/avatars/get-q-r.md index 3be18c1..9e02a0c 100644 --- a/docs/examples/kotlin/avatars/get-q-r.md +++ b/docs/examples/kotlin/avatars/get-q-r.md @@ -4,7 +4,7 @@ import io.appwrite.services.Avatars val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index 69c17ef..2b77405 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -4,7 +4,7 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val databases = Databases(client) diff --git a/docs/examples/kotlin/databases/delete-document.md b/docs/examples/kotlin/databases/delete-document.md index 3733e2f..e3e6de3 100644 --- a/docs/examples/kotlin/databases/delete-document.md +++ b/docs/examples/kotlin/databases/delete-document.md @@ -4,7 +4,7 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val databases = Databases(client) diff --git a/docs/examples/kotlin/databases/get-document.md b/docs/examples/kotlin/databases/get-document.md index a11de0e..6ed6c8b 100644 --- a/docs/examples/kotlin/databases/get-document.md +++ b/docs/examples/kotlin/databases/get-document.md @@ -4,7 +4,7 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val databases = Databases(client) diff --git a/docs/examples/kotlin/databases/list-documents.md b/docs/examples/kotlin/databases/list-documents.md index 6615d44..ff419c4 100644 --- a/docs/examples/kotlin/databases/list-documents.md +++ b/docs/examples/kotlin/databases/list-documents.md @@ -4,7 +4,7 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val databases = Databases(client) diff --git a/docs/examples/kotlin/databases/update-document.md b/docs/examples/kotlin/databases/update-document.md index 5f9aab2..630e2b6 100644 --- a/docs/examples/kotlin/databases/update-document.md +++ b/docs/examples/kotlin/databases/update-document.md @@ -4,7 +4,7 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val databases = Databases(client) diff --git a/docs/examples/kotlin/functions/create-execution.md b/docs/examples/kotlin/functions/create-execution.md index e4ddc6a..937bb4f 100644 --- a/docs/examples/kotlin/functions/create-execution.md +++ b/docs/examples/kotlin/functions/create-execution.md @@ -4,7 +4,7 @@ import io.appwrite.services.Functions val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val functions = Functions(client) diff --git a/docs/examples/kotlin/functions/get-deployment-download.md b/docs/examples/kotlin/functions/get-deployment-download.md index ade55aa..21e99cb 100644 --- a/docs/examples/kotlin/functions/get-deployment-download.md +++ b/docs/examples/kotlin/functions/get-deployment-download.md @@ -4,7 +4,7 @@ import io.appwrite.services.Functions val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val functions = Functions(client) diff --git a/docs/examples/kotlin/functions/get-execution.md b/docs/examples/kotlin/functions/get-execution.md index 6ca4bed..60b2e0f 100644 --- a/docs/examples/kotlin/functions/get-execution.md +++ b/docs/examples/kotlin/functions/get-execution.md @@ -4,7 +4,7 @@ import io.appwrite.services.Functions val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val functions = Functions(client) diff --git a/docs/examples/kotlin/functions/get-template.md b/docs/examples/kotlin/functions/get-template.md index f8d6697..4af83bd 100644 --- a/docs/examples/kotlin/functions/get-template.md +++ b/docs/examples/kotlin/functions/get-template.md @@ -4,7 +4,7 @@ import io.appwrite.services.Functions val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val functions = Functions(client) diff --git a/docs/examples/kotlin/functions/list-executions.md b/docs/examples/kotlin/functions/list-executions.md index 4adc722..90b2bf6 100644 --- a/docs/examples/kotlin/functions/list-executions.md +++ b/docs/examples/kotlin/functions/list-executions.md @@ -4,7 +4,7 @@ import io.appwrite.services.Functions val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val functions = Functions(client) diff --git a/docs/examples/kotlin/functions/list-templates.md b/docs/examples/kotlin/functions/list-templates.md index 5ea5f16..a1a59d9 100644 --- a/docs/examples/kotlin/functions/list-templates.md +++ b/docs/examples/kotlin/functions/list-templates.md @@ -4,7 +4,7 @@ import io.appwrite.services.Functions val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val functions = Functions(client) diff --git a/docs/examples/kotlin/graphql/mutation.md b/docs/examples/kotlin/graphql/mutation.md index 2036e8e..e90c9ae 100644 --- a/docs/examples/kotlin/graphql/mutation.md +++ b/docs/examples/kotlin/graphql/mutation.md @@ -4,7 +4,7 @@ import io.appwrite.services.Graphql val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val graphql = Graphql(client) diff --git a/docs/examples/kotlin/graphql/query.md b/docs/examples/kotlin/graphql/query.md index 4a37ff3..2ce0cb1 100644 --- a/docs/examples/kotlin/graphql/query.md +++ b/docs/examples/kotlin/graphql/query.md @@ -4,7 +4,7 @@ import io.appwrite.services.Graphql val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val graphql = Graphql(client) diff --git a/docs/examples/kotlin/locale/get.md b/docs/examples/kotlin/locale/get.md index aeee656..f2f235a 100644 --- a/docs/examples/kotlin/locale/get.md +++ b/docs/examples/kotlin/locale/get.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-codes.md b/docs/examples/kotlin/locale/list-codes.md index 312ee65..895c96d 100644 --- a/docs/examples/kotlin/locale/list-codes.md +++ b/docs/examples/kotlin/locale/list-codes.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-continents.md b/docs/examples/kotlin/locale/list-continents.md index fa72e8e..e320344 100644 --- a/docs/examples/kotlin/locale/list-continents.md +++ b/docs/examples/kotlin/locale/list-continents.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-countries-e-u.md b/docs/examples/kotlin/locale/list-countries-e-u.md index fc78895..b9182aa 100644 --- a/docs/examples/kotlin/locale/list-countries-e-u.md +++ b/docs/examples/kotlin/locale/list-countries-e-u.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-countries-phones.md b/docs/examples/kotlin/locale/list-countries-phones.md index c91603d..961ebd3 100644 --- a/docs/examples/kotlin/locale/list-countries-phones.md +++ b/docs/examples/kotlin/locale/list-countries-phones.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-countries.md b/docs/examples/kotlin/locale/list-countries.md index 8447eae..1ebae69 100644 --- a/docs/examples/kotlin/locale/list-countries.md +++ b/docs/examples/kotlin/locale/list-countries.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-currencies.md b/docs/examples/kotlin/locale/list-currencies.md index 631cd0d..7500aa7 100644 --- a/docs/examples/kotlin/locale/list-currencies.md +++ b/docs/examples/kotlin/locale/list-currencies.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-languages.md b/docs/examples/kotlin/locale/list-languages.md index c6c1560..2be0ba5 100644 --- a/docs/examples/kotlin/locale/list-languages.md +++ b/docs/examples/kotlin/locale/list-languages.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/messaging/create-subscriber.md b/docs/examples/kotlin/messaging/create-subscriber.md index e0798af..db23342 100644 --- a/docs/examples/kotlin/messaging/create-subscriber.md +++ b/docs/examples/kotlin/messaging/create-subscriber.md @@ -4,7 +4,7 @@ import io.appwrite.services.Messaging val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val messaging = Messaging(client) diff --git a/docs/examples/kotlin/messaging/delete-subscriber.md b/docs/examples/kotlin/messaging/delete-subscriber.md index cf84d81..ab0d479 100644 --- a/docs/examples/kotlin/messaging/delete-subscriber.md +++ b/docs/examples/kotlin/messaging/delete-subscriber.md @@ -4,7 +4,7 @@ import io.appwrite.services.Messaging val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val messaging = Messaging(client) diff --git a/docs/examples/kotlin/storage/create-file.md b/docs/examples/kotlin/storage/create-file.md index d9b50e5..d327e72 100644 --- a/docs/examples/kotlin/storage/create-file.md +++ b/docs/examples/kotlin/storage/create-file.md @@ -5,7 +5,7 @@ import io.appwrite.services.Storage val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/delete-file.md b/docs/examples/kotlin/storage/delete-file.md index 6309658..60df78e 100644 --- a/docs/examples/kotlin/storage/delete-file.md +++ b/docs/examples/kotlin/storage/delete-file.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/get-file-download.md b/docs/examples/kotlin/storage/get-file-download.md index 305fdb9..bb97541 100644 --- a/docs/examples/kotlin/storage/get-file-download.md +++ b/docs/examples/kotlin/storage/get-file-download.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/get-file-preview.md b/docs/examples/kotlin/storage/get-file-preview.md index 9cd86ff..904f3ec 100644 --- a/docs/examples/kotlin/storage/get-file-preview.md +++ b/docs/examples/kotlin/storage/get-file-preview.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/get-file-view.md b/docs/examples/kotlin/storage/get-file-view.md index b8769cd..898c1ee 100644 --- a/docs/examples/kotlin/storage/get-file-view.md +++ b/docs/examples/kotlin/storage/get-file-view.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/get-file.md b/docs/examples/kotlin/storage/get-file.md index 4fab8a6..a07095d 100644 --- a/docs/examples/kotlin/storage/get-file.md +++ b/docs/examples/kotlin/storage/get-file.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/list-files.md b/docs/examples/kotlin/storage/list-files.md index 78d875e..640b705 100644 --- a/docs/examples/kotlin/storage/list-files.md +++ b/docs/examples/kotlin/storage/list-files.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/update-file.md b/docs/examples/kotlin/storage/update-file.md index 7f34dee..f7a20f0 100644 --- a/docs/examples/kotlin/storage/update-file.md +++ b/docs/examples/kotlin/storage/update-file.md @@ -4,7 +4,7 @@ import io.appwrite.services.Storage val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/teams/create-membership.md b/docs/examples/kotlin/teams/create-membership.md index 5858c23..63f3c67 100644 --- a/docs/examples/kotlin/teams/create-membership.md +++ b/docs/examples/kotlin/teams/create-membership.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/create.md b/docs/examples/kotlin/teams/create.md index a45c22c..f214a37 100644 --- a/docs/examples/kotlin/teams/create.md +++ b/docs/examples/kotlin/teams/create.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/delete-membership.md b/docs/examples/kotlin/teams/delete-membership.md index 0d191e6..f3a54b3 100644 --- a/docs/examples/kotlin/teams/delete-membership.md +++ b/docs/examples/kotlin/teams/delete-membership.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/delete.md b/docs/examples/kotlin/teams/delete.md index 87a3026..bc8e8d0 100644 --- a/docs/examples/kotlin/teams/delete.md +++ b/docs/examples/kotlin/teams/delete.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/get-membership.md b/docs/examples/kotlin/teams/get-membership.md index 25e8b3a..e5a589e 100644 --- a/docs/examples/kotlin/teams/get-membership.md +++ b/docs/examples/kotlin/teams/get-membership.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/get-prefs.md b/docs/examples/kotlin/teams/get-prefs.md index 447c4f2..af7503a 100644 --- a/docs/examples/kotlin/teams/get-prefs.md +++ b/docs/examples/kotlin/teams/get-prefs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/get.md b/docs/examples/kotlin/teams/get.md index aa18a31..70759bc 100644 --- a/docs/examples/kotlin/teams/get.md +++ b/docs/examples/kotlin/teams/get.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/list-memberships.md b/docs/examples/kotlin/teams/list-memberships.md index 2f83d8c..abb140e 100644 --- a/docs/examples/kotlin/teams/list-memberships.md +++ b/docs/examples/kotlin/teams/list-memberships.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/list.md b/docs/examples/kotlin/teams/list.md index 569e607..5d80873 100644 --- a/docs/examples/kotlin/teams/list.md +++ b/docs/examples/kotlin/teams/list.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/update-membership-status.md b/docs/examples/kotlin/teams/update-membership-status.md index 8d091aa..9ecf417 100644 --- a/docs/examples/kotlin/teams/update-membership-status.md +++ b/docs/examples/kotlin/teams/update-membership-status.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/update-membership.md b/docs/examples/kotlin/teams/update-membership.md index 1f6c2d3..15b2ac0 100644 --- a/docs/examples/kotlin/teams/update-membership.md +++ b/docs/examples/kotlin/teams/update-membership.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/update-name.md b/docs/examples/kotlin/teams/update-name.md index 470ab17..0040737 100644 --- a/docs/examples/kotlin/teams/update-name.md +++ b/docs/examples/kotlin/teams/update-name.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/update-prefs.md b/docs/examples/kotlin/teams/update-prefs.md index 6ef809e..f70a5eb 100644 --- a/docs/examples/kotlin/teams/update-prefs.md +++ b/docs/examples/kotlin/teams/update-prefs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 2c2593b..d52102a 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -86,7 +86,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "6.0.0-rc.2", + "x-sdk-version" to "6.0.0-rc.3", "x-appwrite-response-format" to "1.6.0" ) config = mutableMapOf() From 998e3073a159b0327222ab674d47b8fcb9bf4daa Mon Sep 17 00:00:00 2001 From: root Date: Fri, 23 Aug 2024 15:25:39 +0000 Subject: [PATCH 080/118] chore: update SDKs for appwrite 1.6.0 --- README.md | 4 ++-- library/src/main/java/io/appwrite/Client.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d5a6b72..f8dab1a 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:6.0.0-rc.3") +implementation("io.appwrite:sdk-for-android:6.0.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 6.0.0-rc.3 + 6.0.0 ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index d52102a..93a3e06 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -86,7 +86,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "6.0.0-rc.3", + "x-sdk-version" to "6.0.0", "x-appwrite-response-format" to "1.6.0" ) config = mutableMapOf() From a3606b7514aecac9f325e97056f14ba880a8f596 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 26 Aug 2024 16:55:59 +0000 Subject: [PATCH 081/118] chore: update team email --- library/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/build.gradle b/library/build.gradle index b67e51e..998da2b 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -15,7 +15,7 @@ ext { POM_LICENSE_NAME = "GPL-3.0" POM_DEVELOPER_ID = 'appwrite' POM_DEVELOPER_NAME = 'Appwrite Team' - POM_DEVELOPER_EMAIL = 'team@localhost.test' + POM_DEVELOPER_EMAIL = 'team@appwrite.io' GITHUB_SCM_CONNECTION = 'scm:git:git://github.com/appwrite/sdk-for-android.git' } From 5aefbda6b6dd985a27108b7390bfb2e88bdcb5db Mon Sep 17 00:00:00 2001 From: root Date: Tue, 27 Aug 2024 10:53:56 +0000 Subject: [PATCH 082/118] chore: update Appwrite version --- .../examples/java/functions/list-templates.md | 25 ----------- .../kotlin/functions/list-templates.md | 16 ------- .../appwrite/models/TemplateFunctionList.kt | 38 ---------------- .../java/io/appwrite/services/Functions.kt | 44 ------------------- 4 files changed, 123 deletions(-) delete mode 100644 docs/examples/java/functions/list-templates.md delete mode 100644 docs/examples/kotlin/functions/list-templates.md delete mode 100644 library/src/main/java/io/appwrite/models/TemplateFunctionList.kt diff --git a/docs/examples/java/functions/list-templates.md b/docs/examples/java/functions/list-templates.md deleted file mode 100644 index 6c051f3..0000000 --- a/docs/examples/java/functions/list-templates.md +++ /dev/null @@ -1,25 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Functions; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Functions functions = new Functions(client); - -functions.listTemplates( - listOf(), // runtimes (optional) - listOf(), // useCases (optional) - 1, // limit (optional) - 0, // offset (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - diff --git a/docs/examples/kotlin/functions/list-templates.md b/docs/examples/kotlin/functions/list-templates.md deleted file mode 100644 index a1a59d9..0000000 --- a/docs/examples/kotlin/functions/list-templates.md +++ /dev/null @@ -1,16 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Functions - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val functions = Functions(client) - -val result = functions.listTemplates( - runtimes = listOf(), // (optional) - useCases = listOf(), // (optional) - limit = 1, // (optional) - offset = 0, // (optional) -) \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/TemplateFunctionList.kt b/library/src/main/java/io/appwrite/models/TemplateFunctionList.kt deleted file mode 100644 index 4cfce5d..0000000 --- a/library/src/main/java/io/appwrite/models/TemplateFunctionList.kt +++ /dev/null @@ -1,38 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * Function Templates List - */ -data class TemplateFunctionList( - /** - * Total number of templates documents that matched your query. - */ - @SerializedName("total") - val total: Long, - - /** - * List of templates. - */ - @SerializedName("templates") - val templates: List, - -) { - fun toMap(): Map = mapOf( - "total" to total as Any, - "templates" to templates.map { it.toMap() } as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = TemplateFunctionList( - total = (map["total"] as Number).toLong(), - templates = (map["templates"] as List>).map { TemplateFunction.from(map = it) }, - ) - } -} \ 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 c0c0bc0..c3c6120 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -17,50 +17,6 @@ import java.io.File **/ class Functions(client: Client) : Service(client) { - /** - * List function templates - * - * List available function templates. You can use template details in [createFunction](/docs/references/cloud/server-nodejs/functions#create) method. - * - * @param runtimes List of runtimes allowed for filtering function templates. Maximum of 100 runtimes are allowed. - * @param useCases List of use cases allowed for filtering function templates. Maximum of 100 use cases are allowed. - * @param limit Limit the number of templates returned in the response. Default limit is 25, and maximum limit is 5000. - * @param offset Offset the list of returned templates. Maximum offset is 5000. - * @return [io.appwrite.models.TemplateFunctionList] - */ - @JvmOverloads - suspend fun listTemplates( - runtimes: List? = null, - useCases: List? = null, - limit: Long? = null, - offset: Long? = null, - ): io.appwrite.models.TemplateFunctionList { - val apiPath = "/functions/templates" - - val apiParams = mutableMapOf( - "runtimes" to runtimes, - "useCases" to useCases, - "limit" to limit, - "offset" to offset, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.TemplateFunctionList = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.TemplateFunctionList.from(map = it as Map) - } - return client.call( - "GET", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.TemplateFunctionList::class.java, - converter, - ) - } - - /** * Get function template * From 2774e024d54da2be2fff44db562f04a23066f699 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 27 Aug 2024 11:15:44 +0000 Subject: [PATCH 083/118] chore: updates for appwrite 1.6.x --- .../java/functions/get-deployment-download.md | 23 --- docs/examples/java/functions/get-template.md | 22 --- .../functions/get-deployment-download.md | 14 -- .../examples/kotlin/functions/get-template.md | 13 -- .../io/appwrite/models/TemplateFunction.kt | 158 ------------------ .../io/appwrite/models/TemplateRuntime.kt | 54 ------ .../io/appwrite/models/TemplateVariable.kt | 70 -------- .../java/io/appwrite/services/Functions.kt | 65 ------- 8 files changed, 419 deletions(-) delete mode 100644 docs/examples/java/functions/get-deployment-download.md delete mode 100644 docs/examples/java/functions/get-template.md delete mode 100644 docs/examples/kotlin/functions/get-deployment-download.md delete mode 100644 docs/examples/kotlin/functions/get-template.md delete mode 100644 library/src/main/java/io/appwrite/models/TemplateFunction.kt delete mode 100644 library/src/main/java/io/appwrite/models/TemplateRuntime.kt delete mode 100644 library/src/main/java/io/appwrite/models/TemplateVariable.kt diff --git a/docs/examples/java/functions/get-deployment-download.md b/docs/examples/java/functions/get-deployment-download.md deleted file mode 100644 index 200cdf2..0000000 --- a/docs/examples/java/functions/get-deployment-download.md +++ /dev/null @@ -1,23 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Functions; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Functions functions = new Functions(client); - -functions.getDeploymentDownload( - "", // functionId - "", // deploymentId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - diff --git a/docs/examples/java/functions/get-template.md b/docs/examples/java/functions/get-template.md deleted file mode 100644 index af9efc7..0000000 --- a/docs/examples/java/functions/get-template.md +++ /dev/null @@ -1,22 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Functions; - -Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Functions functions = new Functions(client); - -functions.getTemplate( - "", // templateId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - diff --git a/docs/examples/kotlin/functions/get-deployment-download.md b/docs/examples/kotlin/functions/get-deployment-download.md deleted file mode 100644 index 21e99cb..0000000 --- a/docs/examples/kotlin/functions/get-deployment-download.md +++ /dev/null @@ -1,14 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Functions - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val functions = Functions(client) - -val result = functions.getDeploymentDownload( - functionId = "", - deploymentId = "", -) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/get-template.md b/docs/examples/kotlin/functions/get-template.md deleted file mode 100644 index 4af83bd..0000000 --- a/docs/examples/kotlin/functions/get-template.md +++ /dev/null @@ -1,13 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Functions - -val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val functions = Functions(client) - -val result = functions.getTemplate( - templateId = "", -) \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/TemplateFunction.kt b/library/src/main/java/io/appwrite/models/TemplateFunction.kt deleted file mode 100644 index 3da1135..0000000 --- a/library/src/main/java/io/appwrite/models/TemplateFunction.kt +++ /dev/null @@ -1,158 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * Template Function - */ -data class TemplateFunction( - /** - * Function Template Icon. - */ - @SerializedName("icon") - val icon: String, - - /** - * Function Template ID. - */ - @SerializedName("id") - val id: String, - - /** - * Function Template Name. - */ - @SerializedName("name") - val name: String, - - /** - * Function Template Tagline. - */ - @SerializedName("tagline") - val tagline: String, - - /** - * Execution permissions. - */ - @SerializedName("permissions") - val permissions: List, - - /** - * Function trigger events. - */ - @SerializedName("events") - val events: List, - - /** - * Function execution schedult in CRON format. - */ - @SerializedName("cron") - val cron: String, - - /** - * Function execution timeout in seconds. - */ - @SerializedName("timeout") - val timeout: Long, - - /** - * Function use cases. - */ - @SerializedName("useCases") - val useCases: List, - - /** - * List of runtimes that can be used with this template. - */ - @SerializedName("runtimes") - val runtimes: List, - - /** - * Function Template Instructions. - */ - @SerializedName("instructions") - val instructions: String, - - /** - * VCS (Version Control System) Provider. - */ - @SerializedName("vcsProvider") - val vcsProvider: String, - - /** - * VCS (Version Control System) Repository ID - */ - @SerializedName("providerRepositoryId") - val providerRepositoryId: String, - - /** - * VCS (Version Control System) Owner. - */ - @SerializedName("providerOwner") - val providerOwner: String, - - /** - * VCS (Version Control System) branch version (tag). - */ - @SerializedName("providerVersion") - val providerVersion: String, - - /** - * Function variables. - */ - @SerializedName("variables") - val variables: List, - - /** - * Function scopes. - */ - @SerializedName("scopes") - val scopes: List, - -) { - fun toMap(): Map = mapOf( - "icon" to icon as Any, - "id" to id as Any, - "name" to name as Any, - "tagline" to tagline as Any, - "permissions" to permissions as Any, - "events" to events as Any, - "cron" to cron as Any, - "timeout" to timeout as Any, - "useCases" to useCases as Any, - "runtimes" to runtimes.map { it.toMap() } as Any, - "instructions" to instructions as Any, - "vcsProvider" to vcsProvider as Any, - "providerRepositoryId" to providerRepositoryId as Any, - "providerOwner" to providerOwner as Any, - "providerVersion" to providerVersion as Any, - "variables" to variables.map { it.toMap() } as Any, - "scopes" to scopes as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = TemplateFunction( - icon = map["icon"] as String, - id = map["id"] as String, - name = map["name"] as String, - tagline = map["tagline"] as String, - permissions = map["permissions"] as List, - events = map["events"] as List, - cron = map["cron"] as String, - timeout = (map["timeout"] as Number).toLong(), - useCases = map["useCases"] as List, - runtimes = (map["runtimes"] as List>).map { TemplateRuntime.from(map = it) }, - instructions = map["instructions"] as String, - vcsProvider = map["vcsProvider"] as String, - providerRepositoryId = map["providerRepositoryId"] as String, - providerOwner = map["providerOwner"] as String, - providerVersion = map["providerVersion"] as String, - variables = (map["variables"] as List>).map { TemplateVariable.from(map = it) }, - scopes = map["scopes"] as List, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/TemplateRuntime.kt b/library/src/main/java/io/appwrite/models/TemplateRuntime.kt deleted file mode 100644 index d354239..0000000 --- a/library/src/main/java/io/appwrite/models/TemplateRuntime.kt +++ /dev/null @@ -1,54 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * Template Runtime - */ -data class TemplateRuntime( - /** - * Runtime Name. - */ - @SerializedName("name") - val name: String, - - /** - * The build command used to build the deployment. - */ - @SerializedName("commands") - val commands: String, - - /** - * The entrypoint file used to execute the deployment. - */ - @SerializedName("entrypoint") - val entrypoint: String, - - /** - * Path to function in VCS (Version Control System) repository - */ - @SerializedName("providerRootDirectory") - val providerRootDirectory: String, - -) { - fun toMap(): Map = mapOf( - "name" to name as Any, - "commands" to commands as Any, - "entrypoint" to entrypoint as Any, - "providerRootDirectory" to providerRootDirectory as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = TemplateRuntime( - name = map["name"] as String, - commands = map["commands"] as String, - entrypoint = map["entrypoint"] as String, - providerRootDirectory = map["providerRootDirectory"] as String, - ) - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/TemplateVariable.kt b/library/src/main/java/io/appwrite/models/TemplateVariable.kt deleted file mode 100644 index 96d6607..0000000 --- a/library/src/main/java/io/appwrite/models/TemplateVariable.kt +++ /dev/null @@ -1,70 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * Template Variable - */ -data class TemplateVariable( - /** - * Variable Name. - */ - @SerializedName("name") - val name: String, - - /** - * Variable Description. - */ - @SerializedName("description") - val description: String, - - /** - * Variable Value. - */ - @SerializedName("value") - val value: String, - - /** - * Variable Placeholder. - */ - @SerializedName("placeholder") - val placeholder: String, - - /** - * Is the variable required? - */ - @SerializedName("required") - val required: Boolean, - - /** - * Variable Type. - */ - @SerializedName("type") - val type: String, - -) { - fun toMap(): Map = mapOf( - "name" to name as Any, - "description" to description as Any, - "value" to value as Any, - "placeholder" to placeholder as Any, - "required" to required as Any, - "type" to type as Any, - ) - - companion object { - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - ) = TemplateVariable( - name = map["name"] as String, - description = map["description"] as String, - value = map["value"] as String, - placeholder = map["placeholder"] as String, - required = map["required"] as Boolean, - type = map["type"] as String, - ) - } -} \ 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 c3c6120..d31e853 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -8,8 +8,6 @@ import io.appwrite.enums.* import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.classOf import okhttp3.Cookie -import okhttp3.HttpUrl -import okhttp3.HttpUrl.Companion.toHttpUrl import java.io.File /** @@ -17,69 +15,6 @@ import java.io.File **/ class Functions(client: Client) : Service(client) { - /** - * Get function template - * - * Get a function template using ID. You can use template details in [createFunction](/docs/references/cloud/server-nodejs/functions#create) method. - * - * @param templateId Template ID. - * @return [io.appwrite.models.TemplateFunction] - */ - suspend fun getTemplate( - templateId: String, - ): io.appwrite.models.TemplateFunction { - val apiPath = "/functions/templates/{templateId}" - .replace("{templateId}", templateId) - - val apiParams = mutableMapOf( - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.TemplateFunction = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.TemplateFunction.from(map = it as Map) - } - return client.call( - "GET", - apiPath, - apiHeaders, - apiParams, - responseType = io.appwrite.models.TemplateFunction::class.java, - converter, - ) - } - - - /** - * Download deployment - * - * Get a Deployment's contents by its unique ID. This endpoint supports range requests for partial or streaming file download. - * - * @param functionId Function ID. - * @param deploymentId Deployment ID. - * @return [ByteArray] - */ - suspend fun getDeploymentDownload( - functionId: String, - deploymentId: String, - ): ByteArray { - val apiPath = "/functions/{functionId}/deployments/{deploymentId}/download" - .replace("{functionId}", functionId) - .replace("{deploymentId}", deploymentId) - - val apiParams = mutableMapOf( - "project" to client.config["project"], - ) - return client.call( - "GET", - apiPath, - params = apiParams, - responseType = ByteArray::class.java - ) - } - - /** * List executions * From f4fb8d2dfd9cf0d2922b755b85dd8726e6f97a6e Mon Sep 17 00:00:00 2001 From: root Date: Wed, 18 Sep 2024 15:52:13 +0000 Subject: [PATCH 084/118] SDK binary support for executions --- README.md | 8 +- .../java/account/create-anonymous-session.md | 2 +- .../account/create-email-password-session.md | 6 +- .../java/account/create-email-token.md | 6 +- docs/examples/java/account/create-j-w-t.md | 2 +- .../java/account/create-magic-u-r-l-token.md | 8 +- .../java/account/create-mfa-authenticator.md | 2 +- .../java/account/create-mfa-challenge.md | 2 +- .../java/account/create-mfa-recovery-codes.md | 2 +- .../java/account/create-o-auth2session.md | 6 +- .../java/account/create-o-auth2token.md | 6 +- .../java/account/create-phone-token.md | 6 +- .../java/account/create-phone-verification.md | 2 +- .../java/account/create-push-target.md | 8 +- docs/examples/java/account/create-recovery.md | 6 +- docs/examples/java/account/create-session.md | 6 +- .../java/account/create-verification.md | 4 +- docs/examples/java/account/create.md | 8 +- docs/examples/java/account/delete-identity.md | 4 +- .../java/account/delete-mfa-authenticator.md | 3 +- .../java/account/delete-push-target.md | 4 +- docs/examples/java/account/delete-session.md | 4 +- docs/examples/java/account/delete-sessions.md | 2 +- .../java/account/get-mfa-recovery-codes.md | 2 +- docs/examples/java/account/get-prefs.md | 2 +- docs/examples/java/account/get-session.md | 4 +- docs/examples/java/account/get.md | 2 +- docs/examples/java/account/list-identities.md | 2 +- docs/examples/java/account/list-logs.md | 2 +- .../examples/java/account/list-mfa-factors.md | 2 +- docs/examples/java/account/list-sessions.md | 2 +- docs/examples/java/account/update-email.md | 6 +- docs/examples/java/account/update-m-f-a.md | 2 +- .../account/update-magic-u-r-l-session.md | 6 +- .../java/account/update-mfa-authenticator.md | 4 +- .../java/account/update-mfa-challenge.md | 6 +- .../java/account/update-mfa-recovery-codes.md | 2 +- docs/examples/java/account/update-name.md | 4 +- docs/examples/java/account/update-password.md | 4 +- .../java/account/update-phone-session.md | 6 +- .../java/account/update-phone-verification.md | 6 +- docs/examples/java/account/update-phone.md | 6 +- docs/examples/java/account/update-prefs.md | 2 +- .../java/account/update-push-target.md | 6 +- docs/examples/java/account/update-recovery.md | 6 +- docs/examples/java/account/update-session.md | 4 +- docs/examples/java/account/update-status.md | 2 +- .../java/account/update-verification.md | 6 +- docs/examples/java/avatars/get-browser.md | 2 +- docs/examples/java/avatars/get-credit-card.md | 2 +- docs/examples/java/avatars/get-favicon.md | 4 +- docs/examples/java/avatars/get-flag.md | 2 +- docs/examples/java/avatars/get-image.md | 4 +- docs/examples/java/avatars/get-initials.md | 4 +- docs/examples/java/avatars/get-q-r.md | 4 +- .../java/databases/create-document.md | 8 +- .../java/databases/delete-document.md | 8 +- docs/examples/java/databases/get-document.md | 8 +- .../examples/java/databases/list-documents.md | 6 +- .../java/databases/update-document.md | 8 +- .../java/functions/create-execution.md | 9 +- docs/examples/java/functions/get-execution.md | 6 +- .../java/functions/list-executions.md | 6 +- docs/examples/java/graphql/mutation.md | 2 +- docs/examples/java/graphql/query.md | 2 +- docs/examples/java/locale/get.md | 2 +- docs/examples/java/locale/list-codes.md | 2 +- docs/examples/java/locale/list-continents.md | 2 +- .../java/locale/list-countries-e-u.md | 2 +- .../java/locale/list-countries-phones.md | 2 +- docs/examples/java/locale/list-countries.md | 2 +- docs/examples/java/locale/list-currencies.md | 2 +- docs/examples/java/locale/list-languages.md | 2 +- .../java/messaging/create-subscriber.md | 8 +- .../java/messaging/delete-subscriber.md | 6 +- docs/examples/java/storage/create-file.md | 10 +- docs/examples/java/storage/delete-file.md | 6 +- .../java/storage/get-file-download.md | 6 +- .../examples/java/storage/get-file-preview.md | 6 +- docs/examples/java/storage/get-file-view.md | 6 +- docs/examples/java/storage/get-file.md | 6 +- docs/examples/java/storage/list-files.md | 6 +- docs/examples/java/storage/update-file.md | 8 +- docs/examples/java/teams/create-membership.md | 14 +- docs/examples/java/teams/create.md | 6 +- docs/examples/java/teams/delete-membership.md | 6 +- docs/examples/java/teams/delete.md | 4 +- docs/examples/java/teams/get-membership.md | 6 +- docs/examples/java/teams/get-prefs.md | 4 +- docs/examples/java/teams/get.md | 4 +- docs/examples/java/teams/list-memberships.md | 6 +- docs/examples/java/teams/list.md | 4 +- .../java/teams/update-membership-status.md | 10 +- docs/examples/java/teams/update-membership.md | 6 +- docs/examples/java/teams/update-name.md | 6 +- docs/examples/java/teams/update-prefs.md | 4 +- .../account/create-anonymous-session.md | 2 +- .../account/create-email-password-session.md | 6 +- .../kotlin/account/create-email-token.md | 6 +- docs/examples/kotlin/account/create-j-w-t.md | 2 +- .../account/create-magic-u-r-l-token.md | 8 +- .../account/create-mfa-authenticator.md | 2 +- .../kotlin/account/create-mfa-challenge.md | 2 +- .../account/create-mfa-recovery-codes.md | 2 +- .../kotlin/account/create-o-auth2session.md | 6 +- .../kotlin/account/create-o-auth2token.md | 6 +- .../kotlin/account/create-phone-token.md | 6 +- .../account/create-phone-verification.md | 2 +- .../kotlin/account/create-push-target.md | 8 +- .../kotlin/account/create-recovery.md | 6 +- .../examples/kotlin/account/create-session.md | 6 +- .../kotlin/account/create-verification.md | 4 +- docs/examples/kotlin/account/create.md | 8 +- .../kotlin/account/delete-identity.md | 4 +- .../account/delete-mfa-authenticator.md | 3 +- .../kotlin/account/delete-push-target.md | 4 +- .../examples/kotlin/account/delete-session.md | 4 +- .../kotlin/account/delete-sessions.md | 2 +- .../kotlin/account/get-mfa-recovery-codes.md | 2 +- docs/examples/kotlin/account/get-prefs.md | 2 +- docs/examples/kotlin/account/get-session.md | 4 +- docs/examples/kotlin/account/get.md | 2 +- .../kotlin/account/list-identities.md | 2 +- docs/examples/kotlin/account/list-logs.md | 2 +- .../kotlin/account/list-mfa-factors.md | 2 +- docs/examples/kotlin/account/list-sessions.md | 2 +- docs/examples/kotlin/account/update-email.md | 6 +- docs/examples/kotlin/account/update-m-f-a.md | 2 +- .../account/update-magic-u-r-l-session.md | 6 +- .../account/update-mfa-authenticator.md | 4 +- .../kotlin/account/update-mfa-challenge.md | 6 +- .../account/update-mfa-recovery-codes.md | 2 +- docs/examples/kotlin/account/update-name.md | 4 +- .../kotlin/account/update-password.md | 4 +- .../kotlin/account/update-phone-session.md | 6 +- .../account/update-phone-verification.md | 6 +- docs/examples/kotlin/account/update-phone.md | 6 +- docs/examples/kotlin/account/update-prefs.md | 2 +- .../kotlin/account/update-push-target.md | 6 +- .../kotlin/account/update-recovery.md | 6 +- .../examples/kotlin/account/update-session.md | 4 +- docs/examples/kotlin/account/update-status.md | 2 +- .../kotlin/account/update-verification.md | 6 +- docs/examples/kotlin/avatars/get-browser.md | 2 +- .../kotlin/avatars/get-credit-card.md | 2 +- docs/examples/kotlin/avatars/get-favicon.md | 4 +- docs/examples/kotlin/avatars/get-flag.md | 2 +- docs/examples/kotlin/avatars/get-image.md | 4 +- docs/examples/kotlin/avatars/get-initials.md | 4 +- docs/examples/kotlin/avatars/get-q-r.md | 4 +- .../kotlin/databases/create-document.md | 8 +- .../kotlin/databases/delete-document.md | 8 +- .../examples/kotlin/databases/get-document.md | 8 +- .../kotlin/databases/list-documents.md | 6 +- .../kotlin/databases/update-document.md | 8 +- .../kotlin/functions/create-execution.md | 9 +- .../kotlin/functions/get-execution.md | 6 +- .../kotlin/functions/list-executions.md | 6 +- docs/examples/kotlin/graphql/mutation.md | 2 +- docs/examples/kotlin/graphql/query.md | 2 +- docs/examples/kotlin/locale/get.md | 2 +- docs/examples/kotlin/locale/list-codes.md | 2 +- .../examples/kotlin/locale/list-continents.md | 2 +- .../kotlin/locale/list-countries-e-u.md | 2 +- .../kotlin/locale/list-countries-phones.md | 2 +- docs/examples/kotlin/locale/list-countries.md | 2 +- .../examples/kotlin/locale/list-currencies.md | 2 +- docs/examples/kotlin/locale/list-languages.md | 2 +- .../kotlin/messaging/create-subscriber.md | 8 +- .../kotlin/messaging/delete-subscriber.md | 6 +- docs/examples/kotlin/storage/create-file.md | 10 +- docs/examples/kotlin/storage/delete-file.md | 6 +- .../kotlin/storage/get-file-download.md | 6 +- .../kotlin/storage/get-file-preview.md | 6 +- docs/examples/kotlin/storage/get-file-view.md | 6 +- docs/examples/kotlin/storage/get-file.md | 6 +- docs/examples/kotlin/storage/list-files.md | 6 +- docs/examples/kotlin/storage/update-file.md | 8 +- .../kotlin/teams/create-membership.md | 14 +- docs/examples/kotlin/teams/create.md | 6 +- .../kotlin/teams/delete-membership.md | 6 +- docs/examples/kotlin/teams/delete.md | 4 +- docs/examples/kotlin/teams/get-membership.md | 6 +- docs/examples/kotlin/teams/get-prefs.md | 4 +- docs/examples/kotlin/teams/get.md | 4 +- .../examples/kotlin/teams/list-memberships.md | 6 +- docs/examples/kotlin/teams/list.md | 4 +- .../kotlin/teams/update-membership-status.md | 10 +- .../kotlin/teams/update-membership.md | 6 +- docs/examples/kotlin/teams/update-name.md | 6 +- docs/examples/kotlin/teams/update-prefs.md | 4 +- library/src/main/java/io/appwrite/Client.kt | 68 ++- library/src/main/java/io/appwrite/ID.kt | 10 +- .../src/main/java/io/appwrite/Permission.kt | 47 +- library/src/main/java/io/appwrite/Query.kt | 161 +++++- library/src/main/java/io/appwrite/Service.kt | 5 + .../io/appwrite/extensions/TypeExtensions.kt | 101 +++- .../main/java/io/appwrite/models/Execution.kt | 8 + .../main/java/io/appwrite/models/InputFile.kt | 37 -- .../main/java/io/appwrite/models/Payload.kt | 71 +++ .../main/java/io/appwrite/services/Account.kt | 459 +++++++++--------- .../main/java/io/appwrite/services/Avatars.kt | 62 +-- .../java/io/appwrite/services/Databases.kt | 62 +-- .../java/io/appwrite/services/Functions.kt | 44 +- .../main/java/io/appwrite/services/Graphql.kt | 18 +- .../main/java/io/appwrite/services/Locale.kt | 50 +- .../java/io/appwrite/services/Messaging.kt | 18 +- .../main/java/io/appwrite/services/Storage.kt | 78 +-- .../main/java/io/appwrite/services/Teams.kt | 144 +++--- 209 files changed, 1357 insertions(+), 982 deletions(-) delete mode 100644 library/src/main/java/io/appwrite/models/InputFile.kt create mode 100644 library/src/main/java/io/appwrite/models/Payload.kt diff --git a/README.md b/README.md index 7a8e368..f8dab1a 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.5.6-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.6.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.5.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.6.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:5.1.1") +implementation("io.appwrite:sdk-for-android:6.0.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 5.1.1 + 6.0.0 ``` diff --git a/docs/examples/java/account/create-anonymous-session.md b/docs/examples/java/account/create-anonymous-session.md index 46ae275..1639cdc 100644 --- a/docs/examples/java/account/create-anonymous-session.md +++ b/docs/examples/java/account/create-anonymous-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-email-password-session.md b/docs/examples/java/account/create-email-password-session.md index 85d460e..112fb20 100644 --- a/docs/examples/java/account/create-email-password-session.md +++ b/docs/examples/java/account/create-email-password-session.md @@ -4,13 +4,13 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.createEmailPasswordSession( - "email@example.com", // email - "password", // password + "{$example}", // email + "{$example}", // password new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/create-email-token.md b/docs/examples/java/account/create-email-token.md index adf8b3d..3fafb5e 100644 --- a/docs/examples/java/account/create-email-token.md +++ b/docs/examples/java/account/create-email-token.md @@ -4,13 +4,13 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.createEmailToken( - "", // userId - "email@example.com", // email + "{$example}", // userId + "{$example}", // email false, // phrase (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/account/create-j-w-t.md b/docs/examples/java/account/create-j-w-t.md index 13e6e49..9aeb29c 100644 --- a/docs/examples/java/account/create-j-w-t.md +++ b/docs/examples/java/account/create-j-w-t.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-magic-u-r-l-token.md b/docs/examples/java/account/create-magic-u-r-l-token.md index 21108cc..e84b213 100644 --- a/docs/examples/java/account/create-magic-u-r-l-token.md +++ b/docs/examples/java/account/create-magic-u-r-l-token.md @@ -4,14 +4,14 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.createMagicURLToken( - "", // userId - "email@example.com", // email - "https://example.com", // url (optional) + "{$example}", // userId + "{$example}", // email + "{$example}", // url (optional) false, // phrase (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/account/create-mfa-authenticator.md b/docs/examples/java/account/create-mfa-authenticator.md index cc64341..b8b06c3 100644 --- a/docs/examples/java/account/create-mfa-authenticator.md +++ b/docs/examples/java/account/create-mfa-authenticator.md @@ -5,7 +5,7 @@ import io.appwrite.enums.AuthenticatorType; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-mfa-challenge.md b/docs/examples/java/account/create-mfa-challenge.md index a2c2aa4..d9d9bb6 100644 --- a/docs/examples/java/account/create-mfa-challenge.md +++ b/docs/examples/java/account/create-mfa-challenge.md @@ -5,7 +5,7 @@ import io.appwrite.enums.AuthenticationFactor; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-mfa-recovery-codes.md b/docs/examples/java/account/create-mfa-recovery-codes.md index 8ed8573..6e23ad2 100644 --- a/docs/examples/java/account/create-mfa-recovery-codes.md +++ b/docs/examples/java/account/create-mfa-recovery-codes.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-o-auth2session.md b/docs/examples/java/account/create-o-auth2session.md index ba284a1..591f85e 100644 --- a/docs/examples/java/account/create-o-auth2session.md +++ b/docs/examples/java/account/create-o-auth2session.md @@ -5,14 +5,14 @@ import io.appwrite.enums.OAuthProvider; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.createOAuth2Session( OAuthProvider.AMAZON, // provider - "https://example.com", // success (optional) - "https://example.com", // failure (optional) + "{$example}", // success (optional) + "{$example}", // failure (optional) listOf(), // scopes (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/account/create-o-auth2token.md b/docs/examples/java/account/create-o-auth2token.md index eb64da1..0866fef 100644 --- a/docs/examples/java/account/create-o-auth2token.md +++ b/docs/examples/java/account/create-o-auth2token.md @@ -5,14 +5,14 @@ import io.appwrite.enums.OAuthProvider; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.createOAuth2Token( OAuthProvider.AMAZON, // provider - "https://example.com", // success (optional) - "https://example.com", // failure (optional) + "{$example}", // success (optional) + "{$example}", // failure (optional) listOf(), // scopes (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/account/create-phone-token.md b/docs/examples/java/account/create-phone-token.md index 29ef311..ef60cfa 100644 --- a/docs/examples/java/account/create-phone-token.md +++ b/docs/examples/java/account/create-phone-token.md @@ -4,13 +4,13 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.createPhoneToken( - "", // userId - "+12065550100", // phone + "{$example}", // userId + "{$example}", // phone new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/create-phone-verification.md b/docs/examples/java/account/create-phone-verification.md index ef14ce8..cca9283 100644 --- a/docs/examples/java/account/create-phone-verification.md +++ b/docs/examples/java/account/create-phone-verification.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-push-target.md b/docs/examples/java/account/create-push-target.md index 7eff453..a0dc5a8 100644 --- a/docs/examples/java/account/create-push-target.md +++ b/docs/examples/java/account/create-push-target.md @@ -4,14 +4,14 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.createPushTarget( - "", // targetId - "", // identifier - "", // providerId (optional) + "{$example}", // targetId + "{$example}", // identifier + "{$example}", // providerId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/create-recovery.md b/docs/examples/java/account/create-recovery.md index 19006f6..7fba792 100644 --- a/docs/examples/java/account/create-recovery.md +++ b/docs/examples/java/account/create-recovery.md @@ -4,13 +4,13 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.createRecovery( - "email@example.com", // email - "https://example.com", // url + "{$example}", // email + "{$example}", // url new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/create-session.md b/docs/examples/java/account/create-session.md index 013d372..ff3391f 100644 --- a/docs/examples/java/account/create-session.md +++ b/docs/examples/java/account/create-session.md @@ -4,13 +4,13 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.createSession( - "", // userId - "", // secret + "{$example}", // userId + "{$example}", // secret new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/create-verification.md b/docs/examples/java/account/create-verification.md index 254a31b..74e5b3d 100644 --- a/docs/examples/java/account/create-verification.md +++ b/docs/examples/java/account/create-verification.md @@ -4,12 +4,12 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.createVerification( - "https://example.com", // url + "{$example}", // url new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/create.md b/docs/examples/java/account/create.md index 8ee1de3..d23bcac 100644 --- a/docs/examples/java/account/create.md +++ b/docs/examples/java/account/create.md @@ -4,15 +4,15 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.create( - "", // userId - "email@example.com", // email + "{$example}", // userId + "{$example}", // email "", // password - "", // name (optional) + "{$example}", // name (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/delete-identity.md b/docs/examples/java/account/delete-identity.md index 1d6922a..d72c1e6 100644 --- a/docs/examples/java/account/delete-identity.md +++ b/docs/examples/java/account/delete-identity.md @@ -4,12 +4,12 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.deleteIdentity( - "", // identityId + "{$example}", // identityId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/delete-mfa-authenticator.md b/docs/examples/java/account/delete-mfa-authenticator.md index e821930..bb6cb09 100644 --- a/docs/examples/java/account/delete-mfa-authenticator.md +++ b/docs/examples/java/account/delete-mfa-authenticator.md @@ -5,13 +5,12 @@ import io.appwrite.enums.AuthenticatorType; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.deleteMfaAuthenticator( AuthenticatorType.TOTP, // type - "", // otp new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/delete-push-target.md b/docs/examples/java/account/delete-push-target.md index 484fc2c..366a473 100644 --- a/docs/examples/java/account/delete-push-target.md +++ b/docs/examples/java/account/delete-push-target.md @@ -4,12 +4,12 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.deletePushTarget( - "", // targetId + "{$example}", // targetId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/delete-session.md b/docs/examples/java/account/delete-session.md index 4344061..cb152f4 100644 --- a/docs/examples/java/account/delete-session.md +++ b/docs/examples/java/account/delete-session.md @@ -4,12 +4,12 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.deleteSession( - "", // sessionId + "{$example}", // sessionId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/delete-sessions.md b/docs/examples/java/account/delete-sessions.md index 147523e..d4c4380 100644 --- a/docs/examples/java/account/delete-sessions.md +++ b/docs/examples/java/account/delete-sessions.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/get-mfa-recovery-codes.md b/docs/examples/java/account/get-mfa-recovery-codes.md index 14e5023..acf5984 100644 --- a/docs/examples/java/account/get-mfa-recovery-codes.md +++ b/docs/examples/java/account/get-mfa-recovery-codes.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/get-prefs.md b/docs/examples/java/account/get-prefs.md index bfa3c1a..0fea3fe 100644 --- a/docs/examples/java/account/get-prefs.md +++ b/docs/examples/java/account/get-prefs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/get-session.md b/docs/examples/java/account/get-session.md index 470f643..627026d 100644 --- a/docs/examples/java/account/get-session.md +++ b/docs/examples/java/account/get-session.md @@ -4,12 +4,12 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.getSession( - "", // sessionId + "{$example}", // sessionId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/get.md b/docs/examples/java/account/get.md index 9006cb8..5c25ed0 100644 --- a/docs/examples/java/account/get.md +++ b/docs/examples/java/account/get.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/list-identities.md b/docs/examples/java/account/list-identities.md index cb5f74e..7f9449d 100644 --- a/docs/examples/java/account/list-identities.md +++ b/docs/examples/java/account/list-identities.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/list-logs.md b/docs/examples/java/account/list-logs.md index 998d8a8..3aa66e2 100644 --- a/docs/examples/java/account/list-logs.md +++ b/docs/examples/java/account/list-logs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/list-mfa-factors.md b/docs/examples/java/account/list-mfa-factors.md index e1a6fa6..a10cb8d 100644 --- a/docs/examples/java/account/list-mfa-factors.md +++ b/docs/examples/java/account/list-mfa-factors.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/list-sessions.md b/docs/examples/java/account/list-sessions.md index 9e70f0d..aa8d37b 100644 --- a/docs/examples/java/account/list-sessions.md +++ b/docs/examples/java/account/list-sessions.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-email.md b/docs/examples/java/account/update-email.md index 13c5b65..37894f7 100644 --- a/docs/examples/java/account/update-email.md +++ b/docs/examples/java/account/update-email.md @@ -4,13 +4,13 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.updateEmail( - "email@example.com", // email - "password", // password + "{$example}", // email + "{$example}", // password new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-m-f-a.md b/docs/examples/java/account/update-m-f-a.md index 7c774c7..620a20c 100644 --- a/docs/examples/java/account/update-m-f-a.md +++ b/docs/examples/java/account/update-m-f-a.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); 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 339b1f7..4f09fb3 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 @@ -4,13 +4,13 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.updateMagicURLSession( - "", // userId - "", // secret + "{$example}", // userId + "{$example}", // secret new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-mfa-authenticator.md b/docs/examples/java/account/update-mfa-authenticator.md index 44bb7f0..9b3c3f6 100644 --- a/docs/examples/java/account/update-mfa-authenticator.md +++ b/docs/examples/java/account/update-mfa-authenticator.md @@ -5,13 +5,13 @@ import io.appwrite.enums.AuthenticatorType; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.updateMfaAuthenticator( AuthenticatorType.TOTP, // type - "", // otp + "{$example}", // otp new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-mfa-challenge.md b/docs/examples/java/account/update-mfa-challenge.md index e30c733..c898904 100644 --- a/docs/examples/java/account/update-mfa-challenge.md +++ b/docs/examples/java/account/update-mfa-challenge.md @@ -4,13 +4,13 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.updateMfaChallenge( - "", // challengeId - "", // otp + "{$example}", // challengeId + "{$example}", // otp new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-mfa-recovery-codes.md b/docs/examples/java/account/update-mfa-recovery-codes.md index 880d478..2aa82b1 100644 --- a/docs/examples/java/account/update-mfa-recovery-codes.md +++ b/docs/examples/java/account/update-mfa-recovery-codes.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-name.md b/docs/examples/java/account/update-name.md index ff23ace..cd00362 100644 --- a/docs/examples/java/account/update-name.md +++ b/docs/examples/java/account/update-name.md @@ -4,12 +4,12 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.updateName( - "", // name + "{$example}", // name new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-password.md b/docs/examples/java/account/update-password.md index 764debf..a8b9be7 100644 --- a/docs/examples/java/account/update-password.md +++ b/docs/examples/java/account/update-password.md @@ -4,13 +4,13 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.updatePassword( "", // password - "password", // oldPassword (optional) + "{$example}", // oldPassword (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-phone-session.md b/docs/examples/java/account/update-phone-session.md index 69d2dd7..9166d36 100644 --- a/docs/examples/java/account/update-phone-session.md +++ b/docs/examples/java/account/update-phone-session.md @@ -4,13 +4,13 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.updatePhoneSession( - "", // userId - "", // secret + "{$example}", // userId + "{$example}", // secret new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-phone-verification.md b/docs/examples/java/account/update-phone-verification.md index 304e73e..eb50644 100644 --- a/docs/examples/java/account/update-phone-verification.md +++ b/docs/examples/java/account/update-phone-verification.md @@ -4,13 +4,13 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.updatePhoneVerification( - "", // userId - "", // secret + "{$example}", // userId + "{$example}", // secret new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-phone.md b/docs/examples/java/account/update-phone.md index 795700a..1e7a1bc 100644 --- a/docs/examples/java/account/update-phone.md +++ b/docs/examples/java/account/update-phone.md @@ -4,13 +4,13 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.updatePhone( - "+12065550100", // phone - "password", // password + "{$example}", // phone + "{$example}", // password new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-prefs.md b/docs/examples/java/account/update-prefs.md index 71eae4c..d746067 100644 --- a/docs/examples/java/account/update-prefs.md +++ b/docs/examples/java/account/update-prefs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-push-target.md b/docs/examples/java/account/update-push-target.md index 90dc29e..15f9b0a 100644 --- a/docs/examples/java/account/update-push-target.md +++ b/docs/examples/java/account/update-push-target.md @@ -4,13 +4,13 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.updatePushTarget( - "", // targetId - "", // identifier + "{$example}", // targetId + "{$example}", // identifier new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-recovery.md b/docs/examples/java/account/update-recovery.md index 527351c..9ec90c3 100644 --- a/docs/examples/java/account/update-recovery.md +++ b/docs/examples/java/account/update-recovery.md @@ -4,13 +4,13 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.updateRecovery( - "", // userId - "", // secret + "{$example}", // userId + "{$example}", // secret "", // password new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/account/update-session.md b/docs/examples/java/account/update-session.md index e2ef0c3..d6093d9 100644 --- a/docs/examples/java/account/update-session.md +++ b/docs/examples/java/account/update-session.md @@ -4,12 +4,12 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.updateSession( - "", // sessionId + "{$example}", // sessionId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-status.md b/docs/examples/java/account/update-status.md index 61cb944..2216649 100644 --- a/docs/examples/java/account/update-status.md +++ b/docs/examples/java/account/update-status.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-verification.md b/docs/examples/java/account/update-verification.md index 3f14196..ebced41 100644 --- a/docs/examples/java/account/update-verification.md +++ b/docs/examples/java/account/update-verification.md @@ -4,13 +4,13 @@ import io.appwrite.services.Account; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Account account = new Account(client); account.updateVerification( - "", // userId - "", // secret + "{$example}", // userId + "{$example}", // secret new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/avatars/get-browser.md b/docs/examples/java/avatars/get-browser.md index a7b9e7f..f7e8651 100644 --- a/docs/examples/java/avatars/get-browser.md +++ b/docs/examples/java/avatars/get-browser.md @@ -5,7 +5,7 @@ import io.appwrite.enums.Browser; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-credit-card.md b/docs/examples/java/avatars/get-credit-card.md index 61a8a51..5b1ee06 100644 --- a/docs/examples/java/avatars/get-credit-card.md +++ b/docs/examples/java/avatars/get-credit-card.md @@ -5,7 +5,7 @@ import io.appwrite.enums.CreditCard; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-favicon.md b/docs/examples/java/avatars/get-favicon.md index d2f86c0..ac8e6e6 100644 --- a/docs/examples/java/avatars/get-favicon.md +++ b/docs/examples/java/avatars/get-favicon.md @@ -4,12 +4,12 @@ import io.appwrite.services.Avatars; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Avatars avatars = new Avatars(client); avatars.getFavicon( - "https://example.com", // url + "{$example}", // url new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/avatars/get-flag.md b/docs/examples/java/avatars/get-flag.md index dc8cc29..6a2185c 100644 --- a/docs/examples/java/avatars/get-flag.md +++ b/docs/examples/java/avatars/get-flag.md @@ -5,7 +5,7 @@ import io.appwrite.enums.Flag; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-image.md b/docs/examples/java/avatars/get-image.md index 81e8029..85eacb1 100644 --- a/docs/examples/java/avatars/get-image.md +++ b/docs/examples/java/avatars/get-image.md @@ -4,12 +4,12 @@ import io.appwrite.services.Avatars; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Avatars avatars = new Avatars(client); avatars.getImage( - "https://example.com", // url + "{$example}", // url 0, // width (optional) 0, // height (optional) new CoroutineCallback<>((result, error) -> { diff --git a/docs/examples/java/avatars/get-initials.md b/docs/examples/java/avatars/get-initials.md index f6c3ee6..d687c7b 100644 --- a/docs/examples/java/avatars/get-initials.md +++ b/docs/examples/java/avatars/get-initials.md @@ -4,12 +4,12 @@ import io.appwrite.services.Avatars; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Avatars avatars = new Avatars(client); avatars.getInitials( - "", // name (optional) + "{$example}", // name (optional) 0, // width (optional) 0, // height (optional) "", // background (optional) diff --git a/docs/examples/java/avatars/get-q-r.md b/docs/examples/java/avatars/get-q-r.md index d75b3b3..05a5e8d 100644 --- a/docs/examples/java/avatars/get-q-r.md +++ b/docs/examples/java/avatars/get-q-r.md @@ -4,12 +4,12 @@ import io.appwrite.services.Avatars; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Avatars avatars = new Avatars(client); avatars.getQR( - "", // text + "{$example}", // text 1, // size (optional) 0, // margin (optional) false, // download (optional) diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index 361d5fe..fc0465f 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -4,14 +4,14 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Databases databases = new Databases(client); databases.createDocument( - "", // databaseId - "", // collectionId - "", // documentId + "{$example}", // databaseId + "{$example}", // collectionId + "{$example}", // documentId mapOf( "a" to "b" ), // data listOf("read("any")"), // permissions (optional) new CoroutineCallback<>((result, error) -> { diff --git a/docs/examples/java/databases/delete-document.md b/docs/examples/java/databases/delete-document.md index 26b67a2..50bd674 100644 --- a/docs/examples/java/databases/delete-document.md +++ b/docs/examples/java/databases/delete-document.md @@ -4,14 +4,14 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Databases databases = new Databases(client); databases.deleteDocument( - "", // databaseId - "", // collectionId - "", // documentId + "{$example}", // databaseId + "{$example}", // collectionId + "{$example}", // documentId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/get-document.md b/docs/examples/java/databases/get-document.md index ac89489..cbcca6e 100644 --- a/docs/examples/java/databases/get-document.md +++ b/docs/examples/java/databases/get-document.md @@ -4,14 +4,14 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Databases databases = new Databases(client); databases.getDocument( - "", // databaseId - "", // collectionId - "", // documentId + "{$example}", // databaseId + "{$example}", // collectionId + "{$example}", // documentId listOf(), // queries (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/databases/list-documents.md b/docs/examples/java/databases/list-documents.md index 9f70425..a63e929 100644 --- a/docs/examples/java/databases/list-documents.md +++ b/docs/examples/java/databases/list-documents.md @@ -4,13 +4,13 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Databases databases = new Databases(client); databases.listDocuments( - "", // databaseId - "", // collectionId + "{$example}", // databaseId + "{$example}", // collectionId listOf(), // queries (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/databases/update-document.md b/docs/examples/java/databases/update-document.md index 430a617..3831c2d 100644 --- a/docs/examples/java/databases/update-document.md +++ b/docs/examples/java/databases/update-document.md @@ -4,14 +4,14 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Databases databases = new Databases(client); databases.updateDocument( - "", // databaseId - "", // collectionId - "", // documentId + "{$example}", // databaseId + "{$example}", // collectionId + "{$example}", // documentId mapOf( "a" to "b" ), // data (optional) listOf("read("any")"), // permissions (optional) new CoroutineCallback<>((result, error) -> { diff --git a/docs/examples/java/functions/create-execution.md b/docs/examples/java/functions/create-execution.md index 0db569b..89bf4c1 100644 --- a/docs/examples/java/functions/create-execution.md +++ b/docs/examples/java/functions/create-execution.md @@ -4,17 +4,18 @@ import io.appwrite.services.Functions; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Functions functions = new Functions(client); functions.createExecution( - "", // functionId - "", // body (optional) + "{$example}", // functionId + Payload.fromJson(mapOf("x" to "y" as Any)), // body (optional) false, // async (optional) - "", // path (optional) + "{$example}", // path (optional) ExecutionMethod.GET, // method (optional) mapOf( "a" to "b" ), // headers (optional) + "", // scheduledAt (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/functions/get-execution.md b/docs/examples/java/functions/get-execution.md index 66bf263..feabf8f 100644 --- a/docs/examples/java/functions/get-execution.md +++ b/docs/examples/java/functions/get-execution.md @@ -4,13 +4,13 @@ import io.appwrite.services.Functions; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Functions functions = new Functions(client); functions.getExecution( - "", // functionId - "", // executionId + "{$example}", // functionId + "{$example}", // executionId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/functions/list-executions.md b/docs/examples/java/functions/list-executions.md index 1bb510a..1efd982 100644 --- a/docs/examples/java/functions/list-executions.md +++ b/docs/examples/java/functions/list-executions.md @@ -4,14 +4,14 @@ import io.appwrite.services.Functions; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Functions functions = new Functions(client); functions.listExecutions( - "", // functionId + "{$example}", // functionId listOf(), // queries (optional) - "", // search (optional) + "{$example}", // search (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/graphql/mutation.md b/docs/examples/java/graphql/mutation.md index a7e5f6e..b79903b 100644 --- a/docs/examples/java/graphql/mutation.md +++ b/docs/examples/java/graphql/mutation.md @@ -4,7 +4,7 @@ import io.appwrite.services.Graphql; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Graphql graphql = new Graphql(client); diff --git a/docs/examples/java/graphql/query.md b/docs/examples/java/graphql/query.md index a6420b4..82bad13 100644 --- a/docs/examples/java/graphql/query.md +++ b/docs/examples/java/graphql/query.md @@ -4,7 +4,7 @@ import io.appwrite.services.Graphql; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Graphql graphql = new Graphql(client); diff --git a/docs/examples/java/locale/get.md b/docs/examples/java/locale/get.md index cc37896..29b542f 100644 --- a/docs/examples/java/locale/get.md +++ b/docs/examples/java/locale/get.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-codes.md b/docs/examples/java/locale/list-codes.md index 3fbdf85..d8c9a0b 100644 --- a/docs/examples/java/locale/list-codes.md +++ b/docs/examples/java/locale/list-codes.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-continents.md b/docs/examples/java/locale/list-continents.md index 296eade..cf43045 100644 --- a/docs/examples/java/locale/list-continents.md +++ b/docs/examples/java/locale/list-continents.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-countries-e-u.md b/docs/examples/java/locale/list-countries-e-u.md index f674ac5..b7b56ab 100644 --- a/docs/examples/java/locale/list-countries-e-u.md +++ b/docs/examples/java/locale/list-countries-e-u.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-countries-phones.md b/docs/examples/java/locale/list-countries-phones.md index 6280cbb..c3598c0 100644 --- a/docs/examples/java/locale/list-countries-phones.md +++ b/docs/examples/java/locale/list-countries-phones.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-countries.md b/docs/examples/java/locale/list-countries.md index eab9ae2..91ac052 100644 --- a/docs/examples/java/locale/list-countries.md +++ b/docs/examples/java/locale/list-countries.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-currencies.md b/docs/examples/java/locale/list-currencies.md index 662e025..5233004 100644 --- a/docs/examples/java/locale/list-currencies.md +++ b/docs/examples/java/locale/list-currencies.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-languages.md b/docs/examples/java/locale/list-languages.md index dd68bf2..0f10563 100644 --- a/docs/examples/java/locale/list-languages.md +++ b/docs/examples/java/locale/list-languages.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/messaging/create-subscriber.md b/docs/examples/java/messaging/create-subscriber.md index e83b43c..1ce5d6d 100644 --- a/docs/examples/java/messaging/create-subscriber.md +++ b/docs/examples/java/messaging/create-subscriber.md @@ -4,14 +4,14 @@ import io.appwrite.services.Messaging; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Messaging messaging = new Messaging(client); messaging.createSubscriber( - "", // topicId - "", // subscriberId - "", // targetId + "{$example}", // topicId + "{$example}", // subscriberId + "{$example}", // targetId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/messaging/delete-subscriber.md b/docs/examples/java/messaging/delete-subscriber.md index 5e8302b..07fbd2f 100644 --- a/docs/examples/java/messaging/delete-subscriber.md +++ b/docs/examples/java/messaging/delete-subscriber.md @@ -4,13 +4,13 @@ import io.appwrite.services.Messaging; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Messaging messaging = new Messaging(client); messaging.deleteSubscriber( - "", // topicId - "", // subscriberId + "{$example}", // topicId + "{$example}", // subscriberId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/create-file.md b/docs/examples/java/storage/create-file.md index a060552..6da1bf5 100644 --- a/docs/examples/java/storage/create-file.md +++ b/docs/examples/java/storage/create-file.md @@ -1,18 +1,18 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.models.InputFile; +import io.appwrite.models.Payload; import io.appwrite.services.Storage; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Storage storage = new Storage(client); storage.createFile( - "", // bucketId - "", // fileId - InputFile.fromPath("file.png"), // file + "{$example}", // bucketId + "{$example}", // fileId + Payload.fromFile("/path/to/file.png"), // file listOf("read("any")"), // permissions (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/storage/delete-file.md b/docs/examples/java/storage/delete-file.md index 113dfce..1defa04 100644 --- a/docs/examples/java/storage/delete-file.md +++ b/docs/examples/java/storage/delete-file.md @@ -4,13 +4,13 @@ import io.appwrite.services.Storage; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Storage storage = new Storage(client); storage.deleteFile( - "", // bucketId - "", // fileId + "{$example}", // bucketId + "{$example}", // fileId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/get-file-download.md b/docs/examples/java/storage/get-file-download.md index 22207ca..611b5c7 100644 --- a/docs/examples/java/storage/get-file-download.md +++ b/docs/examples/java/storage/get-file-download.md @@ -4,13 +4,13 @@ import io.appwrite.services.Storage; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Storage storage = new Storage(client); storage.getFileDownload( - "", // bucketId - "", // fileId + "{$example}", // bucketId + "{$example}", // fileId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/get-file-preview.md b/docs/examples/java/storage/get-file-preview.md index df81fb4..c29be40 100644 --- a/docs/examples/java/storage/get-file-preview.md +++ b/docs/examples/java/storage/get-file-preview.md @@ -4,13 +4,13 @@ import io.appwrite.services.Storage; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Storage storage = new Storage(client); storage.getFilePreview( - "", // bucketId - "", // fileId + "{$example}", // bucketId + "{$example}", // fileId 0, // width (optional) 0, // height (optional) ImageGravity.CENTER, // gravity (optional) diff --git a/docs/examples/java/storage/get-file-view.md b/docs/examples/java/storage/get-file-view.md index d64c3e6..5cac2ce 100644 --- a/docs/examples/java/storage/get-file-view.md +++ b/docs/examples/java/storage/get-file-view.md @@ -4,13 +4,13 @@ import io.appwrite.services.Storage; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Storage storage = new Storage(client); storage.getFileView( - "", // bucketId - "", // fileId + "{$example}", // bucketId + "{$example}", // fileId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/get-file.md b/docs/examples/java/storage/get-file.md index b68bf78..54dd453 100644 --- a/docs/examples/java/storage/get-file.md +++ b/docs/examples/java/storage/get-file.md @@ -4,13 +4,13 @@ import io.appwrite.services.Storage; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Storage storage = new Storage(client); storage.getFile( - "", // bucketId - "", // fileId + "{$example}", // bucketId + "{$example}", // fileId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/list-files.md b/docs/examples/java/storage/list-files.md index 8b84ecb..56ec1a8 100644 --- a/docs/examples/java/storage/list-files.md +++ b/docs/examples/java/storage/list-files.md @@ -4,14 +4,14 @@ import io.appwrite.services.Storage; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Storage storage = new Storage(client); storage.listFiles( - "", // bucketId + "{$example}", // bucketId listOf(), // queries (optional) - "", // search (optional) + "{$example}", // search (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/update-file.md b/docs/examples/java/storage/update-file.md index 12b6443..563a413 100644 --- a/docs/examples/java/storage/update-file.md +++ b/docs/examples/java/storage/update-file.md @@ -4,14 +4,14 @@ import io.appwrite.services.Storage; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Storage storage = new Storage(client); storage.updateFile( - "", // bucketId - "", // fileId - "", // name (optional) + "{$example}", // bucketId + "{$example}", // fileId + "{$example}", // name (optional) listOf("read("any")"), // permissions (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/teams/create-membership.md b/docs/examples/java/teams/create-membership.md index 468571e..60461af 100644 --- a/docs/examples/java/teams/create-membership.md +++ b/docs/examples/java/teams/create-membership.md @@ -4,18 +4,18 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); teams.createMembership( - "", // teamId + "{$example}", // teamId listOf(), // roles - "email@example.com", // email (optional) - "", // userId (optional) - "+12065550100", // phone (optional) - "https://example.com", // url (optional) - "", // name (optional) + "{$example}", // email (optional) + "{$example}", // userId (optional) + "{$example}", // phone (optional) + "{$example}", // url (optional) + "{$example}", // name (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/create.md b/docs/examples/java/teams/create.md index 3c757ac..00f691b 100644 --- a/docs/examples/java/teams/create.md +++ b/docs/examples/java/teams/create.md @@ -4,13 +4,13 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); teams.create( - "", // teamId - "", // name + "{$example}", // teamId + "{$example}", // name listOf(), // roles (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/teams/delete-membership.md b/docs/examples/java/teams/delete-membership.md index e23409f..bf6c877 100644 --- a/docs/examples/java/teams/delete-membership.md +++ b/docs/examples/java/teams/delete-membership.md @@ -4,13 +4,13 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); teams.deleteMembership( - "", // teamId - "", // membershipId + "{$example}", // teamId + "{$example}", // membershipId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/delete.md b/docs/examples/java/teams/delete.md index 567ea3d..aa8bfac 100644 --- a/docs/examples/java/teams/delete.md +++ b/docs/examples/java/teams/delete.md @@ -4,12 +4,12 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); teams.delete( - "", // teamId + "{$example}", // teamId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/get-membership.md b/docs/examples/java/teams/get-membership.md index c09a267..6da129e 100644 --- a/docs/examples/java/teams/get-membership.md +++ b/docs/examples/java/teams/get-membership.md @@ -4,13 +4,13 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); teams.getMembership( - "", // teamId - "", // membershipId + "{$example}", // teamId + "{$example}", // membershipId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/get-prefs.md b/docs/examples/java/teams/get-prefs.md index 48a9815..81f344b 100644 --- a/docs/examples/java/teams/get-prefs.md +++ b/docs/examples/java/teams/get-prefs.md @@ -4,12 +4,12 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); teams.getPrefs( - "", // teamId + "{$example}", // teamId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/get.md b/docs/examples/java/teams/get.md index 20a6f6a..c53aeba 100644 --- a/docs/examples/java/teams/get.md +++ b/docs/examples/java/teams/get.md @@ -4,12 +4,12 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); teams.get( - "", // teamId + "{$example}", // teamId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/list-memberships.md b/docs/examples/java/teams/list-memberships.md index 2de609c..137ee2a 100644 --- a/docs/examples/java/teams/list-memberships.md +++ b/docs/examples/java/teams/list-memberships.md @@ -4,14 +4,14 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); teams.listMemberships( - "", // teamId + "{$example}", // teamId listOf(), // queries (optional) - "", // search (optional) + "{$example}", // search (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/list.md b/docs/examples/java/teams/list.md index 7f7910c..e918ac8 100644 --- a/docs/examples/java/teams/list.md +++ b/docs/examples/java/teams/list.md @@ -4,13 +4,13 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); teams.list( listOf(), // queries (optional) - "", // search (optional) + "{$example}", // search (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/update-membership-status.md b/docs/examples/java/teams/update-membership-status.md index 97e8242..80bfe17 100644 --- a/docs/examples/java/teams/update-membership-status.md +++ b/docs/examples/java/teams/update-membership-status.md @@ -4,15 +4,15 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); teams.updateMembershipStatus( - "", // teamId - "", // membershipId - "", // userId - "", // secret + "{$example}", // teamId + "{$example}", // membershipId + "{$example}", // userId + "{$example}", // secret new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/update-membership.md b/docs/examples/java/teams/update-membership.md index 86f0ddd..69c99b6 100644 --- a/docs/examples/java/teams/update-membership.md +++ b/docs/examples/java/teams/update-membership.md @@ -4,13 +4,13 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); teams.updateMembership( - "", // teamId - "", // membershipId + "{$example}", // teamId + "{$example}", // membershipId listOf(), // roles new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/teams/update-name.md b/docs/examples/java/teams/update-name.md index 1aa96f8..7d9d96d 100644 --- a/docs/examples/java/teams/update-name.md +++ b/docs/examples/java/teams/update-name.md @@ -4,13 +4,13 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); teams.updateName( - "", // teamId - "", // name + "{$example}", // teamId + "{$example}", // name new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/update-prefs.md b/docs/examples/java/teams/update-prefs.md index e188a99..334fd6d 100644 --- a/docs/examples/java/teams/update-prefs.md +++ b/docs/examples/java/teams/update-prefs.md @@ -4,12 +4,12 @@ import io.appwrite.services.Teams; Client client = new Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2"); // Your project ID + .setProject(""); // Your project ID Teams teams = new Teams(client); teams.updatePrefs( - "", // teamId + "{$example}", // teamId mapOf( "a" to "b" ), // prefs new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/kotlin/account/create-anonymous-session.md b/docs/examples/kotlin/account/create-anonymous-session.md index 7961cc0..50a011a 100644 --- a/docs/examples/kotlin/account/create-anonymous-session.md +++ b/docs/examples/kotlin/account/create-anonymous-session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-email-password-session.md b/docs/examples/kotlin/account/create-email-password-session.md index 57bc99b..6b69b3a 100644 --- a/docs/examples/kotlin/account/create-email-password-session.md +++ b/docs/examples/kotlin/account/create-email-password-session.md @@ -4,11 +4,11 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.createEmailPasswordSession( - email = "email@example.com", - password = "password", + email = "{$example}", + password = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-email-token.md b/docs/examples/kotlin/account/create-email-token.md index dd0bdf3..46e6926 100644 --- a/docs/examples/kotlin/account/create-email-token.md +++ b/docs/examples/kotlin/account/create-email-token.md @@ -4,12 +4,12 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.createEmailToken( - userId = "", - email = "email@example.com", + userId = "{$example}", + email = "{$example}", phrase = false, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-j-w-t.md b/docs/examples/kotlin/account/create-j-w-t.md index 3aefe4a..50014d4 100644 --- a/docs/examples/kotlin/account/create-j-w-t.md +++ b/docs/examples/kotlin/account/create-j-w-t.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-magic-u-r-l-token.md b/docs/examples/kotlin/account/create-magic-u-r-l-token.md index dad908e..9851dab 100644 --- a/docs/examples/kotlin/account/create-magic-u-r-l-token.md +++ b/docs/examples/kotlin/account/create-magic-u-r-l-token.md @@ -4,13 +4,13 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.createMagicURLToken( - userId = "", - email = "email@example.com", - url = "https://example.com", // (optional) + userId = "{$example}", + email = "{$example}", + url = "{$example}", // (optional) phrase = false, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-mfa-authenticator.md b/docs/examples/kotlin/account/create-mfa-authenticator.md index f2ff748..dacf56a 100644 --- a/docs/examples/kotlin/account/create-mfa-authenticator.md +++ b/docs/examples/kotlin/account/create-mfa-authenticator.md @@ -5,7 +5,7 @@ import io.appwrite.enums.AuthenticatorType val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-mfa-challenge.md b/docs/examples/kotlin/account/create-mfa-challenge.md index d43aa39..22c9658 100644 --- a/docs/examples/kotlin/account/create-mfa-challenge.md +++ b/docs/examples/kotlin/account/create-mfa-challenge.md @@ -5,7 +5,7 @@ import io.appwrite.enums.AuthenticationFactor val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-mfa-recovery-codes.md b/docs/examples/kotlin/account/create-mfa-recovery-codes.md index be25e74..364bc0e 100644 --- a/docs/examples/kotlin/account/create-mfa-recovery-codes.md +++ b/docs/examples/kotlin/account/create-mfa-recovery-codes.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-o-auth2session.md b/docs/examples/kotlin/account/create-o-auth2session.md index d642de8..7f63375 100644 --- a/docs/examples/kotlin/account/create-o-auth2session.md +++ b/docs/examples/kotlin/account/create-o-auth2session.md @@ -5,13 +5,13 @@ import io.appwrite.enums.OAuthProvider val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) account.createOAuth2Session( provider = OAuthProvider.AMAZON, - success = "https://example.com", // (optional) - failure = "https://example.com", // (optional) + success = "{$example}", // (optional) + failure = "{$example}", // (optional) scopes = listOf(), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-o-auth2token.md b/docs/examples/kotlin/account/create-o-auth2token.md index 7d651b1..7607380 100644 --- a/docs/examples/kotlin/account/create-o-auth2token.md +++ b/docs/examples/kotlin/account/create-o-auth2token.md @@ -5,13 +5,13 @@ import io.appwrite.enums.OAuthProvider val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) account.createOAuth2Token( provider = OAuthProvider.AMAZON, - success = "https://example.com", // (optional) - failure = "https://example.com", // (optional) + success = "{$example}", // (optional) + failure = "{$example}", // (optional) scopes = listOf(), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-phone-token.md b/docs/examples/kotlin/account/create-phone-token.md index 9e72059..acea79b 100644 --- a/docs/examples/kotlin/account/create-phone-token.md +++ b/docs/examples/kotlin/account/create-phone-token.md @@ -4,11 +4,11 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.createPhoneToken( - userId = "", - phone = "+12065550100", + userId = "{$example}", + phone = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-phone-verification.md b/docs/examples/kotlin/account/create-phone-verification.md index 3c94fb8..531aead 100644 --- a/docs/examples/kotlin/account/create-phone-verification.md +++ b/docs/examples/kotlin/account/create-phone-verification.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-push-target.md b/docs/examples/kotlin/account/create-push-target.md index 66729cc..df6d9fe 100644 --- a/docs/examples/kotlin/account/create-push-target.md +++ b/docs/examples/kotlin/account/create-push-target.md @@ -4,12 +4,12 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.createPushTarget( - targetId = "", - identifier = "", - providerId = "", // (optional) + targetId = "{$example}", + identifier = "{$example}", + providerId = "{$example}", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-recovery.md b/docs/examples/kotlin/account/create-recovery.md index 8afb76c..13e8fbc 100644 --- a/docs/examples/kotlin/account/create-recovery.md +++ b/docs/examples/kotlin/account/create-recovery.md @@ -4,11 +4,11 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.createRecovery( - email = "email@example.com", - url = "https://example.com", + email = "{$example}", + url = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-session.md b/docs/examples/kotlin/account/create-session.md index 49daa6b..000ddb8 100644 --- a/docs/examples/kotlin/account/create-session.md +++ b/docs/examples/kotlin/account/create-session.md @@ -4,11 +4,11 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.createSession( - userId = "", - secret = "", + userId = "{$example}", + secret = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-verification.md b/docs/examples/kotlin/account/create-verification.md index 0638a36..e0a6b38 100644 --- a/docs/examples/kotlin/account/create-verification.md +++ b/docs/examples/kotlin/account/create-verification.md @@ -4,10 +4,10 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.createVerification( - url = "https://example.com", + url = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create.md b/docs/examples/kotlin/account/create.md index 48b8b66..38fbca9 100644 --- a/docs/examples/kotlin/account/create.md +++ b/docs/examples/kotlin/account/create.md @@ -4,13 +4,13 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.create( - userId = "", - email = "email@example.com", + userId = "{$example}", + email = "{$example}", password = "", - name = "", // (optional) + name = "{$example}", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-identity.md b/docs/examples/kotlin/account/delete-identity.md index 099b5ac..78bdc8d 100644 --- a/docs/examples/kotlin/account/delete-identity.md +++ b/docs/examples/kotlin/account/delete-identity.md @@ -4,10 +4,10 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.deleteIdentity( - identityId = "", + identityId = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-mfa-authenticator.md b/docs/examples/kotlin/account/delete-mfa-authenticator.md index c07afd0..48220b2 100644 --- a/docs/examples/kotlin/account/delete-mfa-authenticator.md +++ b/docs/examples/kotlin/account/delete-mfa-authenticator.md @@ -5,11 +5,10 @@ import io.appwrite.enums.AuthenticatorType val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.deleteMfaAuthenticator( type = AuthenticatorType.TOTP, - otp = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-push-target.md b/docs/examples/kotlin/account/delete-push-target.md index c20d04a..257bd3e 100644 --- a/docs/examples/kotlin/account/delete-push-target.md +++ b/docs/examples/kotlin/account/delete-push-target.md @@ -4,10 +4,10 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.deletePushTarget( - targetId = "", + targetId = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-session.md b/docs/examples/kotlin/account/delete-session.md index ae2ed67..53db6d4 100644 --- a/docs/examples/kotlin/account/delete-session.md +++ b/docs/examples/kotlin/account/delete-session.md @@ -4,10 +4,10 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.deleteSession( - sessionId = "", + sessionId = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-sessions.md b/docs/examples/kotlin/account/delete-sessions.md index 7caaea4..8c464e0 100644 --- a/docs/examples/kotlin/account/delete-sessions.md +++ b/docs/examples/kotlin/account/delete-sessions.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/get-mfa-recovery-codes.md b/docs/examples/kotlin/account/get-mfa-recovery-codes.md index 4a1652c..bd12e83 100644 --- a/docs/examples/kotlin/account/get-mfa-recovery-codes.md +++ b/docs/examples/kotlin/account/get-mfa-recovery-codes.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/get-prefs.md b/docs/examples/kotlin/account/get-prefs.md index 08fdd13..9227eff 100644 --- a/docs/examples/kotlin/account/get-prefs.md +++ b/docs/examples/kotlin/account/get-prefs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/get-session.md b/docs/examples/kotlin/account/get-session.md index d0520ce..bb39027 100644 --- a/docs/examples/kotlin/account/get-session.md +++ b/docs/examples/kotlin/account/get-session.md @@ -4,10 +4,10 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.getSession( - sessionId = "", + sessionId = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/get.md b/docs/examples/kotlin/account/get.md index ed4874b..8c90304 100644 --- a/docs/examples/kotlin/account/get.md +++ b/docs/examples/kotlin/account/get.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/list-identities.md b/docs/examples/kotlin/account/list-identities.md index bde6023..53e388d 100644 --- a/docs/examples/kotlin/account/list-identities.md +++ b/docs/examples/kotlin/account/list-identities.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/list-logs.md b/docs/examples/kotlin/account/list-logs.md index 56238f9..683a94b 100644 --- a/docs/examples/kotlin/account/list-logs.md +++ b/docs/examples/kotlin/account/list-logs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/list-mfa-factors.md b/docs/examples/kotlin/account/list-mfa-factors.md index 9f8572c..ecfa6c2 100644 --- a/docs/examples/kotlin/account/list-mfa-factors.md +++ b/docs/examples/kotlin/account/list-mfa-factors.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/list-sessions.md b/docs/examples/kotlin/account/list-sessions.md index 9d64c74..2da413d 100644 --- a/docs/examples/kotlin/account/list-sessions.md +++ b/docs/examples/kotlin/account/list-sessions.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-email.md b/docs/examples/kotlin/account/update-email.md index 5068962..b2d749a 100644 --- a/docs/examples/kotlin/account/update-email.md +++ b/docs/examples/kotlin/account/update-email.md @@ -4,11 +4,11 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.updateEmail( - email = "email@example.com", - password = "password", + email = "{$example}", + password = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-m-f-a.md b/docs/examples/kotlin/account/update-m-f-a.md index 7949490..3cac098 100644 --- a/docs/examples/kotlin/account/update-m-f-a.md +++ b/docs/examples/kotlin/account/update-m-f-a.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) 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 0abb033..d4f2043 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 @@ -4,11 +4,11 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.updateMagicURLSession( - userId = "", - secret = "", + userId = "{$example}", + secret = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-mfa-authenticator.md b/docs/examples/kotlin/account/update-mfa-authenticator.md index 8b19680..3959917 100644 --- a/docs/examples/kotlin/account/update-mfa-authenticator.md +++ b/docs/examples/kotlin/account/update-mfa-authenticator.md @@ -5,11 +5,11 @@ import io.appwrite.enums.AuthenticatorType val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.updateMfaAuthenticator( type = AuthenticatorType.TOTP, - otp = "", + otp = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-mfa-challenge.md b/docs/examples/kotlin/account/update-mfa-challenge.md index fe4cb1e..40fa58e 100644 --- a/docs/examples/kotlin/account/update-mfa-challenge.md +++ b/docs/examples/kotlin/account/update-mfa-challenge.md @@ -4,11 +4,11 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.updateMfaChallenge( - challengeId = "", - otp = "", + challengeId = "{$example}", + otp = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-mfa-recovery-codes.md b/docs/examples/kotlin/account/update-mfa-recovery-codes.md index f39b7c6..d4ea7f5 100644 --- a/docs/examples/kotlin/account/update-mfa-recovery-codes.md +++ b/docs/examples/kotlin/account/update-mfa-recovery-codes.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-name.md b/docs/examples/kotlin/account/update-name.md index 20aab9d..0a52615 100644 --- a/docs/examples/kotlin/account/update-name.md +++ b/docs/examples/kotlin/account/update-name.md @@ -4,10 +4,10 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.updateName( - name = "", + name = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-password.md b/docs/examples/kotlin/account/update-password.md index 86c862c..75c57f4 100644 --- a/docs/examples/kotlin/account/update-password.md +++ b/docs/examples/kotlin/account/update-password.md @@ -4,11 +4,11 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.updatePassword( password = "", - oldPassword = "password", // (optional) + oldPassword = "{$example}", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-phone-session.md b/docs/examples/kotlin/account/update-phone-session.md index 6c8fa65..31ccdef 100644 --- a/docs/examples/kotlin/account/update-phone-session.md +++ b/docs/examples/kotlin/account/update-phone-session.md @@ -4,11 +4,11 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.updatePhoneSession( - userId = "", - secret = "", + userId = "{$example}", + secret = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-phone-verification.md b/docs/examples/kotlin/account/update-phone-verification.md index 445a47e..9636ecd 100644 --- a/docs/examples/kotlin/account/update-phone-verification.md +++ b/docs/examples/kotlin/account/update-phone-verification.md @@ -4,11 +4,11 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.updatePhoneVerification( - userId = "", - secret = "", + userId = "{$example}", + secret = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-phone.md b/docs/examples/kotlin/account/update-phone.md index c8f50c3..3f882b2 100644 --- a/docs/examples/kotlin/account/update-phone.md +++ b/docs/examples/kotlin/account/update-phone.md @@ -4,11 +4,11 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.updatePhone( - phone = "+12065550100", - password = "password", + phone = "{$example}", + password = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-prefs.md b/docs/examples/kotlin/account/update-prefs.md index f449ccb..c5c7a3d 100644 --- a/docs/examples/kotlin/account/update-prefs.md +++ b/docs/examples/kotlin/account/update-prefs.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-push-target.md b/docs/examples/kotlin/account/update-push-target.md index 5fff554..315d770 100644 --- a/docs/examples/kotlin/account/update-push-target.md +++ b/docs/examples/kotlin/account/update-push-target.md @@ -4,11 +4,11 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.updatePushTarget( - targetId = "", - identifier = "", + targetId = "{$example}", + identifier = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-recovery.md b/docs/examples/kotlin/account/update-recovery.md index da1f27e..5e9866d 100644 --- a/docs/examples/kotlin/account/update-recovery.md +++ b/docs/examples/kotlin/account/update-recovery.md @@ -4,12 +4,12 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.updateRecovery( - userId = "", - secret = "", + userId = "{$example}", + secret = "{$example}", password = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-session.md b/docs/examples/kotlin/account/update-session.md index 3252039..e4b85a8 100644 --- a/docs/examples/kotlin/account/update-session.md +++ b/docs/examples/kotlin/account/update-session.md @@ -4,10 +4,10 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.updateSession( - sessionId = "", + sessionId = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-status.md b/docs/examples/kotlin/account/update-status.md index 2b54214..4f44ce1 100644 --- a/docs/examples/kotlin/account/update-status.md +++ b/docs/examples/kotlin/account/update-status.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-verification.md b/docs/examples/kotlin/account/update-verification.md index 5f7f902..7a58116 100644 --- a/docs/examples/kotlin/account/update-verification.md +++ b/docs/examples/kotlin/account/update-verification.md @@ -4,11 +4,11 @@ import io.appwrite.services.Account val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val account = Account(client) val result = account.updateVerification( - userId = "", - secret = "", + userId = "{$example}", + secret = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-browser.md b/docs/examples/kotlin/avatars/get-browser.md index 1e63217..34f6f28 100644 --- a/docs/examples/kotlin/avatars/get-browser.md +++ b/docs/examples/kotlin/avatars/get-browser.md @@ -5,7 +5,7 @@ import io.appwrite.enums.Browser val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-credit-card.md b/docs/examples/kotlin/avatars/get-credit-card.md index 23fbbfd..52eea79 100644 --- a/docs/examples/kotlin/avatars/get-credit-card.md +++ b/docs/examples/kotlin/avatars/get-credit-card.md @@ -5,7 +5,7 @@ import io.appwrite.enums.CreditCard val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-favicon.md b/docs/examples/kotlin/avatars/get-favicon.md index a2d5e18..b95f9c8 100644 --- a/docs/examples/kotlin/avatars/get-favicon.md +++ b/docs/examples/kotlin/avatars/get-favicon.md @@ -4,10 +4,10 @@ import io.appwrite.services.Avatars val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val avatars = Avatars(client) val result = avatars.getFavicon( - url = "https://example.com", + url = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-flag.md b/docs/examples/kotlin/avatars/get-flag.md index b1ac632..cfd5d01 100644 --- a/docs/examples/kotlin/avatars/get-flag.md +++ b/docs/examples/kotlin/avatars/get-flag.md @@ -5,7 +5,7 @@ import io.appwrite.enums.Flag val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-image.md b/docs/examples/kotlin/avatars/get-image.md index bb76b4c..64d8619 100644 --- a/docs/examples/kotlin/avatars/get-image.md +++ b/docs/examples/kotlin/avatars/get-image.md @@ -4,12 +4,12 @@ import io.appwrite.services.Avatars val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val avatars = Avatars(client) val result = avatars.getImage( - url = "https://example.com", + url = "{$example}", width = 0, // (optional) height = 0, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-initials.md b/docs/examples/kotlin/avatars/get-initials.md index b2a1c25..c7388b0 100644 --- a/docs/examples/kotlin/avatars/get-initials.md +++ b/docs/examples/kotlin/avatars/get-initials.md @@ -4,12 +4,12 @@ import io.appwrite.services.Avatars val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val avatars = Avatars(client) val result = avatars.getInitials( - name = "", // (optional) + name = "{$example}", // (optional) width = 0, // (optional) height = 0, // (optional) background = "", // (optional) diff --git a/docs/examples/kotlin/avatars/get-q-r.md b/docs/examples/kotlin/avatars/get-q-r.md index 853d94e..1157d95 100644 --- a/docs/examples/kotlin/avatars/get-q-r.md +++ b/docs/examples/kotlin/avatars/get-q-r.md @@ -4,12 +4,12 @@ import io.appwrite.services.Avatars val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val avatars = Avatars(client) val result = avatars.getQR( - text = "", + text = "{$example}", size = 1, // (optional) margin = 0, // (optional) download = false, // (optional) diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index 10b6fdf..ef2a268 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -4,14 +4,14 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val databases = Databases(client) val result = databases.createDocument( - databaseId = "", - collectionId = "", - documentId = "", + databaseId = "{$example}", + collectionId = "{$example}", + documentId = "{$example}", data = mapOf( "a" to "b" ), permissions = listOf("read("any")"), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/delete-document.md b/docs/examples/kotlin/databases/delete-document.md index 3eb1147..240e308 100644 --- a/docs/examples/kotlin/databases/delete-document.md +++ b/docs/examples/kotlin/databases/delete-document.md @@ -4,12 +4,12 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val databases = Databases(client) val result = databases.deleteDocument( - databaseId = "", - collectionId = "", - documentId = "", + databaseId = "{$example}", + collectionId = "{$example}", + documentId = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/get-document.md b/docs/examples/kotlin/databases/get-document.md index 6c5f92a..fb13fb1 100644 --- a/docs/examples/kotlin/databases/get-document.md +++ b/docs/examples/kotlin/databases/get-document.md @@ -4,13 +4,13 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val databases = Databases(client) val result = databases.getDocument( - databaseId = "", - collectionId = "", - documentId = "", + databaseId = "{$example}", + collectionId = "{$example}", + documentId = "{$example}", queries = listOf(), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/list-documents.md b/docs/examples/kotlin/databases/list-documents.md index 7b1e851..2f4c8ae 100644 --- a/docs/examples/kotlin/databases/list-documents.md +++ b/docs/examples/kotlin/databases/list-documents.md @@ -4,12 +4,12 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val databases = Databases(client) val result = databases.listDocuments( - databaseId = "", - collectionId = "", + databaseId = "{$example}", + collectionId = "{$example}", queries = listOf(), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/update-document.md b/docs/examples/kotlin/databases/update-document.md index de6b192..fb9b17c 100644 --- a/docs/examples/kotlin/databases/update-document.md +++ b/docs/examples/kotlin/databases/update-document.md @@ -4,14 +4,14 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val databases = Databases(client) val result = databases.updateDocument( - databaseId = "", - collectionId = "", - documentId = "", + databaseId = "{$example}", + collectionId = "{$example}", + documentId = "{$example}", data = mapOf( "a" to "b" ), // (optional) permissions = listOf("read("any")"), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/create-execution.md b/docs/examples/kotlin/functions/create-execution.md index de84186..d6ca800 100644 --- a/docs/examples/kotlin/functions/create-execution.md +++ b/docs/examples/kotlin/functions/create-execution.md @@ -4,15 +4,16 @@ import io.appwrite.services.Functions val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val functions = Functions(client) val result = functions.createExecution( - functionId = "", - body = "", // (optional) + functionId = "{$example}", + body = Payload.fromJson(mapOf("x" to "y" as Any)), // (optional) async = false, // (optional) - path = "", // (optional) + path = "{$example}", // (optional) method = ExecutionMethod.GET, // (optional) headers = mapOf( "a" to "b" ), // (optional) + scheduledAt = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/get-execution.md b/docs/examples/kotlin/functions/get-execution.md index 0c4de1e..2e2c54e 100644 --- a/docs/examples/kotlin/functions/get-execution.md +++ b/docs/examples/kotlin/functions/get-execution.md @@ -4,11 +4,11 @@ import io.appwrite.services.Functions val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val functions = Functions(client) val result = functions.getExecution( - functionId = "", - executionId = "", + functionId = "{$example}", + executionId = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/list-executions.md b/docs/examples/kotlin/functions/list-executions.md index d28b32c..f916c9d 100644 --- a/docs/examples/kotlin/functions/list-executions.md +++ b/docs/examples/kotlin/functions/list-executions.md @@ -4,12 +4,12 @@ import io.appwrite.services.Functions val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val functions = Functions(client) val result = functions.listExecutions( - functionId = "", + functionId = "{$example}", queries = listOf(), // (optional) - search = "", // (optional) + search = "{$example}", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/graphql/mutation.md b/docs/examples/kotlin/graphql/mutation.md index a429a66..e90c9ae 100644 --- a/docs/examples/kotlin/graphql/mutation.md +++ b/docs/examples/kotlin/graphql/mutation.md @@ -4,7 +4,7 @@ import io.appwrite.services.Graphql val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val graphql = Graphql(client) diff --git a/docs/examples/kotlin/graphql/query.md b/docs/examples/kotlin/graphql/query.md index 0c39edd..2ce0cb1 100644 --- a/docs/examples/kotlin/graphql/query.md +++ b/docs/examples/kotlin/graphql/query.md @@ -4,7 +4,7 @@ import io.appwrite.services.Graphql val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val graphql = Graphql(client) diff --git a/docs/examples/kotlin/locale/get.md b/docs/examples/kotlin/locale/get.md index d38572a..f2f235a 100644 --- a/docs/examples/kotlin/locale/get.md +++ b/docs/examples/kotlin/locale/get.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-codes.md b/docs/examples/kotlin/locale/list-codes.md index 9f506f0..895c96d 100644 --- a/docs/examples/kotlin/locale/list-codes.md +++ b/docs/examples/kotlin/locale/list-codes.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-continents.md b/docs/examples/kotlin/locale/list-continents.md index 96cfda5..e320344 100644 --- a/docs/examples/kotlin/locale/list-continents.md +++ b/docs/examples/kotlin/locale/list-continents.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-countries-e-u.md b/docs/examples/kotlin/locale/list-countries-e-u.md index 54faf5e..b9182aa 100644 --- a/docs/examples/kotlin/locale/list-countries-e-u.md +++ b/docs/examples/kotlin/locale/list-countries-e-u.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-countries-phones.md b/docs/examples/kotlin/locale/list-countries-phones.md index 9e4bec1..961ebd3 100644 --- a/docs/examples/kotlin/locale/list-countries-phones.md +++ b/docs/examples/kotlin/locale/list-countries-phones.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-countries.md b/docs/examples/kotlin/locale/list-countries.md index 4299efb..1ebae69 100644 --- a/docs/examples/kotlin/locale/list-countries.md +++ b/docs/examples/kotlin/locale/list-countries.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-currencies.md b/docs/examples/kotlin/locale/list-currencies.md index 2bb7ca7..7500aa7 100644 --- a/docs/examples/kotlin/locale/list-currencies.md +++ b/docs/examples/kotlin/locale/list-currencies.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-languages.md b/docs/examples/kotlin/locale/list-languages.md index a9035e9..2be0ba5 100644 --- a/docs/examples/kotlin/locale/list-languages.md +++ b/docs/examples/kotlin/locale/list-languages.md @@ -4,7 +4,7 @@ import io.appwrite.services.Locale val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/messaging/create-subscriber.md b/docs/examples/kotlin/messaging/create-subscriber.md index 3f1d476..4292dec 100644 --- a/docs/examples/kotlin/messaging/create-subscriber.md +++ b/docs/examples/kotlin/messaging/create-subscriber.md @@ -4,12 +4,12 @@ import io.appwrite.services.Messaging val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val messaging = Messaging(client) val result = messaging.createSubscriber( - topicId = "", - subscriberId = "", - targetId = "", + topicId = "{$example}", + subscriberId = "{$example}", + targetId = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/messaging/delete-subscriber.md b/docs/examples/kotlin/messaging/delete-subscriber.md index febf622..0617824 100644 --- a/docs/examples/kotlin/messaging/delete-subscriber.md +++ b/docs/examples/kotlin/messaging/delete-subscriber.md @@ -4,11 +4,11 @@ import io.appwrite.services.Messaging val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val messaging = Messaging(client) val result = messaging.deleteSubscriber( - topicId = "", - subscriberId = "", + topicId = "{$example}", + subscriberId = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/create-file.md b/docs/examples/kotlin/storage/create-file.md index ccd342e..816ece1 100644 --- a/docs/examples/kotlin/storage/create-file.md +++ b/docs/examples/kotlin/storage/create-file.md @@ -1,17 +1,17 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.models.InputFile +import io.appwrite.models.Payload import io.appwrite.services.Storage val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val storage = Storage(client) val result = storage.createFile( - bucketId = "", - fileId = "", - file = InputFile.fromPath("file.png"), + bucketId = "{$example}", + fileId = "{$example}", + file = Payload.fromFile("/path/to/file.png"), permissions = listOf("read("any")"), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/delete-file.md b/docs/examples/kotlin/storage/delete-file.md index 8def7d9..d4f802b 100644 --- a/docs/examples/kotlin/storage/delete-file.md +++ b/docs/examples/kotlin/storage/delete-file.md @@ -4,11 +4,11 @@ import io.appwrite.services.Storage val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val storage = Storage(client) val result = storage.deleteFile( - bucketId = "", - fileId = "", + bucketId = "{$example}", + fileId = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file-download.md b/docs/examples/kotlin/storage/get-file-download.md index c6e8fa4..3ae382e 100644 --- a/docs/examples/kotlin/storage/get-file-download.md +++ b/docs/examples/kotlin/storage/get-file-download.md @@ -4,11 +4,11 @@ import io.appwrite.services.Storage val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val storage = Storage(client) val result = storage.getFileDownload( - bucketId = "", - fileId = "", + bucketId = "{$example}", + fileId = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file-preview.md b/docs/examples/kotlin/storage/get-file-preview.md index 9c9993c..cc6911a 100644 --- a/docs/examples/kotlin/storage/get-file-preview.md +++ b/docs/examples/kotlin/storage/get-file-preview.md @@ -4,13 +4,13 @@ import io.appwrite.services.Storage val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val storage = Storage(client) val result = storage.getFilePreview( - bucketId = "", - fileId = "", + bucketId = "{$example}", + fileId = "{$example}", width = 0, // (optional) height = 0, // (optional) gravity = ImageGravity.CENTER, // (optional) diff --git a/docs/examples/kotlin/storage/get-file-view.md b/docs/examples/kotlin/storage/get-file-view.md index 83f8b31..bf50695 100644 --- a/docs/examples/kotlin/storage/get-file-view.md +++ b/docs/examples/kotlin/storage/get-file-view.md @@ -4,11 +4,11 @@ import io.appwrite.services.Storage val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val storage = Storage(client) val result = storage.getFileView( - bucketId = "", - fileId = "", + bucketId = "{$example}", + fileId = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file.md b/docs/examples/kotlin/storage/get-file.md index df662ea..040559b 100644 --- a/docs/examples/kotlin/storage/get-file.md +++ b/docs/examples/kotlin/storage/get-file.md @@ -4,11 +4,11 @@ import io.appwrite.services.Storage val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val storage = Storage(client) val result = storage.getFile( - bucketId = "", - fileId = "", + bucketId = "{$example}", + fileId = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/list-files.md b/docs/examples/kotlin/storage/list-files.md index 4e28fc5..e7f09a2 100644 --- a/docs/examples/kotlin/storage/list-files.md +++ b/docs/examples/kotlin/storage/list-files.md @@ -4,12 +4,12 @@ import io.appwrite.services.Storage val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val storage = Storage(client) val result = storage.listFiles( - bucketId = "", + bucketId = "{$example}", queries = listOf(), // (optional) - search = "", // (optional) + search = "{$example}", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/update-file.md b/docs/examples/kotlin/storage/update-file.md index c84dadb..325fc44 100644 --- a/docs/examples/kotlin/storage/update-file.md +++ b/docs/examples/kotlin/storage/update-file.md @@ -4,13 +4,13 @@ import io.appwrite.services.Storage val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val storage = Storage(client) val result = storage.updateFile( - bucketId = "", - fileId = "", - name = "", // (optional) + bucketId = "{$example}", + fileId = "{$example}", + name = "{$example}", // (optional) permissions = listOf("read("any")"), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/create-membership.md b/docs/examples/kotlin/teams/create-membership.md index a892663..6b4b6f1 100644 --- a/docs/examples/kotlin/teams/create-membership.md +++ b/docs/examples/kotlin/teams/create-membership.md @@ -4,16 +4,16 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) val result = teams.createMembership( - teamId = "", + teamId = "{$example}", roles = listOf(), - email = "email@example.com", // (optional) - userId = "", // (optional) - phone = "+12065550100", // (optional) - url = "https://example.com", // (optional) - name = "", // (optional) + email = "{$example}", // (optional) + userId = "{$example}", // (optional) + phone = "{$example}", // (optional) + url = "{$example}", // (optional) + name = "{$example}", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/create.md b/docs/examples/kotlin/teams/create.md index 22d6e7f..93ef2c6 100644 --- a/docs/examples/kotlin/teams/create.md +++ b/docs/examples/kotlin/teams/create.md @@ -4,12 +4,12 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) val result = teams.create( - teamId = "", - name = "", + teamId = "{$example}", + name = "{$example}", roles = listOf(), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/delete-membership.md b/docs/examples/kotlin/teams/delete-membership.md index 66e5716..97cf4d5 100644 --- a/docs/examples/kotlin/teams/delete-membership.md +++ b/docs/examples/kotlin/teams/delete-membership.md @@ -4,11 +4,11 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) val result = teams.deleteMembership( - teamId = "", - membershipId = "", + teamId = "{$example}", + membershipId = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/delete.md b/docs/examples/kotlin/teams/delete.md index a73fa75..9ffc6db 100644 --- a/docs/examples/kotlin/teams/delete.md +++ b/docs/examples/kotlin/teams/delete.md @@ -4,10 +4,10 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) val result = teams.delete( - teamId = "", + teamId = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/get-membership.md b/docs/examples/kotlin/teams/get-membership.md index 80640c7..3277431 100644 --- a/docs/examples/kotlin/teams/get-membership.md +++ b/docs/examples/kotlin/teams/get-membership.md @@ -4,11 +4,11 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) val result = teams.getMembership( - teamId = "", - membershipId = "", + teamId = "{$example}", + membershipId = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/get-prefs.md b/docs/examples/kotlin/teams/get-prefs.md index 31001bd..2791cda 100644 --- a/docs/examples/kotlin/teams/get-prefs.md +++ b/docs/examples/kotlin/teams/get-prefs.md @@ -4,10 +4,10 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) val result = teams.getPrefs( - teamId = "", + teamId = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/get.md b/docs/examples/kotlin/teams/get.md index 4387118..9278e43 100644 --- a/docs/examples/kotlin/teams/get.md +++ b/docs/examples/kotlin/teams/get.md @@ -4,10 +4,10 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) val result = teams.get( - teamId = "", + teamId = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/list-memberships.md b/docs/examples/kotlin/teams/list-memberships.md index 7c8c686..789a810 100644 --- a/docs/examples/kotlin/teams/list-memberships.md +++ b/docs/examples/kotlin/teams/list-memberships.md @@ -4,12 +4,12 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) val result = teams.listMemberships( - teamId = "", + teamId = "{$example}", queries = listOf(), // (optional) - search = "", // (optional) + search = "{$example}", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/list.md b/docs/examples/kotlin/teams/list.md index e73d9e4..0cffc22 100644 --- a/docs/examples/kotlin/teams/list.md +++ b/docs/examples/kotlin/teams/list.md @@ -4,11 +4,11 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) val result = teams.list( queries = listOf(), // (optional) - search = "", // (optional) + search = "{$example}", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-membership-status.md b/docs/examples/kotlin/teams/update-membership-status.md index 0866892..d9454eb 100644 --- a/docs/examples/kotlin/teams/update-membership-status.md +++ b/docs/examples/kotlin/teams/update-membership-status.md @@ -4,13 +4,13 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) val result = teams.updateMembershipStatus( - teamId = "", - membershipId = "", - userId = "", - secret = "", + teamId = "{$example}", + membershipId = "{$example}", + userId = "{$example}", + secret = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-membership.md b/docs/examples/kotlin/teams/update-membership.md index 799c594..5fbec70 100644 --- a/docs/examples/kotlin/teams/update-membership.md +++ b/docs/examples/kotlin/teams/update-membership.md @@ -4,12 +4,12 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) val result = teams.updateMembership( - teamId = "", - membershipId = "", + teamId = "{$example}", + membershipId = "{$example}", roles = listOf(), ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-name.md b/docs/examples/kotlin/teams/update-name.md index 5e2399a..aec0dcb 100644 --- a/docs/examples/kotlin/teams/update-name.md +++ b/docs/examples/kotlin/teams/update-name.md @@ -4,11 +4,11 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) val result = teams.updateName( - teamId = "", - name = "", + teamId = "{$example}", + name = "{$example}", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-prefs.md b/docs/examples/kotlin/teams/update-prefs.md index 62febab..a292333 100644 --- a/docs/examples/kotlin/teams/update-prefs.md +++ b/docs/examples/kotlin/teams/update-prefs.md @@ -4,11 +4,11 @@ import io.appwrite.services.Teams val client = Client(context) .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setProject("") // Your project ID val teams = Teams(client) val result = teams.updatePrefs( - teamId = "", + teamId = "{$example}", prefs = mapOf( "a" to "b" ), ) \ 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 a27cf48..6520241 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -7,8 +7,9 @@ import io.appwrite.cookies.ListenableCookieJar import io.appwrite.cookies.stores.SharedPreferencesCookieStore import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.fromJson +import io.appwrite.extensions.fromMultiPart import io.appwrite.extensions.toJson -import io.appwrite.models.InputFile +import io.appwrite.models.Payload import io.appwrite.models.UploadProgress import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -44,6 +45,9 @@ class Client @JvmOverloads constructor( ) : CoroutineScope { companion object { + /** + * The size for chunked uploads in bytes. + */ internal const val CHUNK_SIZE = 5*1024*1024; // 5MB internal const val GLOBAL_PREFS = "io.appwrite" internal const val COOKIE_PREFS = "myCookie" @@ -57,7 +61,7 @@ class Client @JvmOverloads constructor( internal lateinit var http: OkHttpClient internal val headers: MutableMap - + val config: MutableMap internal val cookieJar = ListenableCookieJar(CookieManager( @@ -83,11 +87,11 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "5.1.1", - "x-appwrite-response-format" to "1.5.0" + "x-sdk-version" to "6.0.0", + "x-appwrite-response-format" to "1.6.0" ) config = mutableMapOf() - + setSelfSigned(selfSigned) } @@ -151,10 +155,10 @@ class Client @JvmOverloads constructor( /** * Set self Signed - * + * * @param status * - * @return this + * @return this */ fun setSelfSigned(status: Boolean): Client { selfSigned = status @@ -203,10 +207,10 @@ class Client @JvmOverloads constructor( /** * Set endpoint and realtime endpoint. - * + * * @param endpoint * - * @return this + * @return this */ fun setEndpoint(endpoint: String): Client { this.endpoint = endpoint @@ -232,11 +236,11 @@ class Client @JvmOverloads constructor( /** * Add Header - * + * * @param key * @param value * - * @return this + * @return this */ fun addHeader(key: String, value: String): Client { headers[key] = value @@ -245,19 +249,19 @@ class Client @JvmOverloads constructor( /** * Send the HTTP request - * + * * @param method * @param path * @param headers * @param params * - * @return [T] + * @return [T] */ @Throws(AppwriteException::class) suspend fun call( - method: String, - path: String, - headers: Map = mapOf(), + method: String, + path: String, + headers: Map = mapOf(), params: Map = mapOf(), responseType: Class, converter: ((Any) -> T)? = null @@ -358,14 +362,14 @@ class Client @JvmOverloads constructor( onProgress: ((UploadProgress) -> Unit)? = null, ): T { var file: RandomAccessFile? = null - val input = params[paramName] as InputFile + val input = params[paramName] as Payload val size: Long = when(input.sourceType) { "path", "file" -> { file = RandomAccessFile(input.path, "r") file.length() } "bytes" -> { - (input.data as ByteArray).size.toLong() + input.toBinary().size.toLong() } else -> throw UnsupportedOperationException() } @@ -373,7 +377,7 @@ class Client @JvmOverloads constructor( if (size < CHUNK_SIZE) { val data = when(input.sourceType) { "file", "path" -> File(input.path).asRequestBody() - "bytes" -> (input.data as ByteArray).toRequestBody(input.mimeType.toMediaType()) + "bytes" -> input.toBinary().toRequestBody(input.mimeType?.toMediaType()) else -> throw UnsupportedOperationException() } params[paramName] = MultipartBody.Part.createFormData( @@ -420,7 +424,7 @@ class Client @JvmOverloads constructor( } else { size - 1 } - (input.data as ByteArray).copyInto( + input.toBinary().copyInto( buffer, startIndex = offset.toInt(), endIndex = end.toInt() @@ -492,14 +496,14 @@ class Client @JvmOverloads constructor( .charStream() .buffered() .use(BufferedReader::readText) - + val error = if (response.headers["content-type"]?.contains("application/json") == true) { val map = body.fromJson>() AppwriteException( - map["message"] as? String ?: "", + map["message"] as? String ?: "", (map["code"] as Number).toInt(), - map["type"] as? String ?: "", + map["type"] as? String ?: "", body ) } else { @@ -508,6 +512,14 @@ class Client @JvmOverloads constructor( it.cancel(error) return } + + val warnings = response.headers["x-appwrite-warning"] + if (warnings != null) { + warnings.split(";").forEach { warning -> + println("Warning: $warning") + } + } + when { responseType == Boolean::class.java -> { it.resume(true as T) @@ -526,6 +538,14 @@ class Client @JvmOverloads constructor( return } } + if (response.headers["content-type"]?.contains("multipart/form-data") == true) { + val binaryBody = response.body!!.bytes() + val body = String(binaryBody) + val map = body.fromMultiPart(binaryBody) + it.resume(converter?.invoke(map) ?: map as T) + return + } + val body = response.body!! .charStream() .buffered() @@ -543,4 +563,4 @@ class Client @JvmOverloads constructor( } }) } -} \ No newline at end of file +} diff --git a/library/src/main/java/io/appwrite/ID.kt b/library/src/main/java/io/appwrite/ID.kt index e661192..b89957b 100644 --- a/library/src/main/java/io/appwrite/ID.kt +++ b/library/src/main/java/io/appwrite/ID.kt @@ -4,6 +4,9 @@ import java.time.Instant import kotlin.math.floor import kotlin.random.Random +/** + * Helper class to generate ID strings for resources. + */ class ID { companion object { // Generate an hex ID based on timestamp @@ -21,7 +24,12 @@ class ID { fun custom(id: String): String = id - // Generate a unique ID with padding to have a longer ID + /** + * Generate a unique ID with padding to have a longer ID + * + * @param padding The number of characters to add to the ID + * @returns The unique ID + */ fun unique(padding: Int = 7): String { val baseId = hexTimestamp() val randomPadding = (1..padding) diff --git a/library/src/main/java/io/appwrite/Permission.kt b/library/src/main/java/io/appwrite/Permission.kt index a540dcf..462b8e4 100644 --- a/library/src/main/java/io/appwrite/Permission.kt +++ b/library/src/main/java/io/appwrite/Permission.kt @@ -1,19 +1,60 @@ package io.appwrite +/** + * Helper class to generate permission strings for resources. + */ class Permission { companion object { + + /** + * Generate read permission string for the provided role. + * + * @param role The role for which to generate the permission. + * @returns The read permission string. + */ fun read(role: String): String { return "read(\"${role}\")" - } + } + + /** + * Generate write permission string for the provided role. + * + * This is an alias of update, delete, and possibly create. + * Don't use write in combination with update, delete, or create. + * + * @param role The role for which to generate the permission. + * @returns The write permission string. + */ fun write(role: String): String { return "write(\"${role}\")" } + + /** + * Generate create permission string for the provided role. + * + * @param role The role for which to generate the permission. + * @returns The create permission string. + */ fun create(role: String): String { return "create(\"${role}\")" - } + } + + /** + * Generate update permission string for the provided role. + * + * @param role The role for which to generate the permission. + * @returns The update permission string. + */ fun update(role: String): String { return "update(\"${role}\")" - } + } + + /** + * Generate delete permission string for the provided role. + * + * @param role The role for which to generate the permission. + * @returns The delete permission string. + */ fun delete(role: String): String { return "delete(\"${role}\")" } diff --git a/library/src/main/java/io/appwrite/Query.kt b/library/src/main/java/io/appwrite/Query.kt index 6efbb11..e326335 100644 --- a/library/src/main/java/io/appwrite/Query.kt +++ b/library/src/main/java/io/appwrite/Query.kt @@ -3,58 +3,217 @@ package io.appwrite import io.appwrite.extensions.toJson import io.appwrite.extensions.fromJson +/** + * Helper class to generate query strings. + */ class Query( val method: String, val attribute: String? = null, val values: List? = null, ) { + /** + * Convert the query object to a JSON string. + * + * @returns The JSON string representation of the query object. + */ override fun toString() = this.toJson() companion object { + + /** + * Filter resources where attribute is equal to value. + * + * @param attribute The attribute to filter on. + * @param value The value to compare against. + * @returns The query string. + */ fun equal(attribute: String, value: Any) = Query("equal", attribute, parseValue(value)).toJson() + /** + * Filter resources where attribute is not equal to value. + * + * @param attribute The attribute to filter on. + * @param value The value to compare against. + * @returns The query string. + */ fun notEqual(attribute: String, value: Any) = Query("notEqual", attribute, parseValue(value)).toJson() + /** + * Filter resources where attribute is less than value. + * + * @param attribute The attribute to filter on. + * @param value The value to compare against. + * @returns The query string. + */ fun lessThan(attribute: String, value: Any) = Query("lessThan", attribute, parseValue(value)).toJson() + /** + * Filter resources where attribute is less than or equal to value. + * + * @param attribute The attribute to filter on. + * @param value The value to compare against. + * @returns The query string. + */ fun lessThanEqual(attribute: String, value: Any) = Query("lessThanEqual", attribute, parseValue(value)).toJson() + /** + * Filter resources where attribute is greater than value. + * + * @param attribute The attribute to filter on. + * @param value The value to compare against. + * @returns The query string. + */ fun greaterThan(attribute: String, value: Any) = Query("greaterThan", attribute, parseValue(value)).toJson() + /** + * Filter resources where attribute is greater than or equal to value. + * + * @param attribute The attribute to filter on. + * @param value The value to compare against. + * @returns The query string. + */ fun greaterThanEqual(attribute: String, value: Any) = Query("greaterThanEqual", attribute, parseValue(value)).toJson() + /** + * Filter resources where attribute matches the search value. + * + * @param attribute The attribute to filter on. + * @param value The search value to match against. + * @returns The query string. + */ fun search(attribute: String, value: String) = Query("search", attribute, listOf(value)).toJson() + /** + * Filter resources where attribute is null. + * + * @param attribute The attribute to filter on. + * @returns The query string. + */ fun isNull(attribute: String) = Query("isNull", attribute).toJson() + /** + * Filter resources where attribute is not null. + * + * @param attribute The attribute to filter on. + * @returns The query string. + */ fun isNotNull(attribute: String) = Query("isNotNull", attribute).toJson() + /** + * Filter resources where attribute is between start and end (inclusive). + * + * @param attribute The attribute to filter on. + * @param start The start value of the range. + * @param end The end value of the range. + * @returns The query string. + */ fun between(attribute: String, start: Any, end: Any) = Query("between", attribute, listOf(start, end)).toJson() + /** + * Filter resources where attribute starts with value. + * + * @param attribute The attribute to filter on. + * @param value The value to compare against. + * @returns The query string. + */ fun startsWith(attribute: String, value: String) = Query("startsWith", attribute, listOf(value)).toJson() + /** + * Filter resources where attribute ends with value. + * + * @param attribute The attribute to filter on. + * @param value The value to compare against. + * @returns The query string. + */ fun endsWith(attribute: String, value: String) = Query("endsWith", attribute, listOf(value)).toJson() + /** + * Specify which attributes should be returned by the API call. + * + * @param attributes The list of attributes to select. + * @returns The query string. + */ fun select(attributes: List) = Query("select", null, attributes).toJson() + /** + * Sort results by attribute ascending. + * + * @param attribute The attribute to sort by. + * @returns The query string. + */ fun orderAsc(attribute: String) = Query("orderAsc", attribute).toJson() + /** + * Sort results by attribute descending. + * + * @param attribute The attribute to sort by. + * @returns The query string. + */ fun orderDesc(attribute: String) = Query("orderDesc", attribute).toJson() + /** + * Return results before documentId. + * + * @param documentId The document ID to use as cursor. + * @returns The query string. + */ fun cursorBefore(documentId: String) = Query("cursorBefore", null, listOf(documentId)).toJson() + /** + * Return results after documentId. + * + * @param documentId The document ID to use as cursor. + * @returns The query string. + */ fun cursorAfter(documentId: String) = Query("cursorAfter", null, listOf(documentId)).toJson() - + + /** + * Return only limit results. + * + * @param limit The number of results to return. + * @returns The query string. + */ fun limit(limit: Int) = Query("limit", null, listOf(limit)).toJson() + /** + * Filter resources by skipping the first offset results. + * + * @param offset The number of results to skip. + * @returns The query string. + */ fun offset(offset: Int) = Query("offset", null, listOf(offset)).toJson() + /** + * Filter resources where attribute contains the specified value. + * + * @param attribute The attribute to filter on. + * @param value The value to compare against. + * @returns The query string. + */ fun contains(attribute: String, value: Any) = Query("contains", attribute, parseValue(value)).toJson() + /** + * Combine multiple queries using logical OR operator. + * + * @param queries The list of query strings to combine. + * @returns The query string. + */ fun or(queries: List) = Query("or", null, queries.map { it.fromJson() }).toJson() + /** + * Combine multiple queries using logical AND operator. + * + * @param queries The list of query strings to combine. + * @returns The query string. + */ fun and(queries: List) = Query("and", null, queries.map { it.fromJson() }).toJson() + /** + * Parse the value to a list of values. + * + * @param value The value to parse. + * @returns The list of parsed values. + */ private fun parseValue(value: Any): List { return when (value) { is List<*> -> value as List diff --git a/library/src/main/java/io/appwrite/Service.kt b/library/src/main/java/io/appwrite/Service.kt index 8efdb9b..7a01b4b 100644 --- a/library/src/main/java/io/appwrite/Service.kt +++ b/library/src/main/java/io/appwrite/Service.kt @@ -2,4 +2,9 @@ package io.appwrite import io.appwrite.Client +/** + * Abstract class for services. + * + * @param client The Appwrite client. + */ abstract class Service(val client: Client) diff --git a/library/src/main/java/io/appwrite/extensions/TypeExtensions.kt b/library/src/main/java/io/appwrite/extensions/TypeExtensions.kt index e699a54..ad26379 100644 --- a/library/src/main/java/io/appwrite/extensions/TypeExtensions.kt +++ b/library/src/main/java/io/appwrite/extensions/TypeExtensions.kt @@ -1,9 +1,104 @@ package io.appwrite.extensions +import io.appwrite.models.Payload import kotlin.reflect.KClass import kotlin.reflect.typeOf inline fun classOf(): Class { - @Suppress("UNCHECKED_CAST") - return (typeOf().classifier!! as KClass).java -} \ No newline at end of file + @Suppress("UNCHECKED_CAST") return (typeOf().classifier!! as KClass).java +} + +fun String.fromMultiPart(binaryBody: ByteArray): Map { + val match = Regex("(-+\\w+)--").find(this) ?: return emptyMap() + // For kotlin + + val boundary = match.groupValues[1] + + var map = + mutableMapOf( + "\$id" to "", + "\$createdAt" to "", + "\$updatedAt" to "", + "\$permissions" to emptyList(), + "functionId" to "", + "trigger" to "", + "status" to "", + "requestMethod" to "", + "requestPath" to "", + "requestHeaders" to emptyList>(), + "responseStatusCode" to 0, + "responseBody" to Payload.fromBinary(ByteArray(0)), + "responseHeaders" to emptyList>(), + "logs" to "", + "errors" to "", + "duration" to 0.0, + "scheduledAt" to "", + ) + val parts = this.split(boundary) + for (part in parts) { + var lines = part.split("\r\n") + + val name = Regex("name=\"?(\\w+)").find(part) ?: continue + + lines = + lines + .dropWhile { it.isEmpty() } + .drop(1) + .dropWhile { it.isEmpty() } + .dropLastWhile { it.isEmpty() } + val key = name.groupValues[1] + + if (lines.isEmpty()) { + continue + } + + if (key == "responseBody") { + val needle = "name=\"responseBody\"\r\n\r\n" + val indexOf = this.indexOf(needle) + needle.length + val endBytes = "\r\n-------".toByteArray() + val list = ByteArray(binaryBody.size - indexOf) + val multipart = binaryBody.drop(indexOf) + var weHitTheEnd = false + var j = 0 + for (i in multipart) { + if (multipart.size > j + endBytes.size) { + var jj = 0 + for (byte in endBytes) { + if (byte != multipart[j + jj]) break + jj++ + if (jj != endBytes.size - 1) continue + weHitTheEnd = true + } + } + if (weHitTheEnd) { + break + } + + list[j] = multipart[j] + j++ + } + + map["responseBody"] = + Payload.fromBinary(list.dropLastWhile { it == 0.toByte() }.toByteArray()) + continue + } + + if (lines[0] == "Content-Type: application/json") { + lines = lines.drop(1).dropWhile { it.isEmpty() } + val list = lines.joinToString("\r\n").fromJson>() + map[key] = list + continue + } + + val value = lines.joinToString("\r\n") + + map[key] = + when (key) { + "responseStatusCode" -> value.toInt() + "duration" -> value.toFloat() + else -> value + } + } + + return map +} diff --git a/library/src/main/java/io/appwrite/models/Execution.kt b/library/src/main/java/io/appwrite/models/Execution.kt index 8252aa1..44724fa 100644 --- a/library/src/main/java/io/appwrite/models/Execution.kt +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -103,6 +103,12 @@ data class Execution( @SerializedName("duration") val duration: Double, + /** + * The scheduled time for execution. If left empty, execution will be queued immediately. + */ + @SerializedName("scheduledAt") + var scheduledAt: String?, + ) { fun toMap(): Map = mapOf( "\$id" to id as Any, @@ -121,6 +127,7 @@ data class Execution( "logs" to logs as Any, "errors" to errors as Any, "duration" to duration as Any, + "scheduledAt" to scheduledAt as Any, ) companion object { @@ -145,6 +152,7 @@ data class Execution( logs = map["logs"] as String, errors = map["errors"] as String, duration = (map["duration"] as Number).toDouble(), + scheduledAt = map["scheduledAt"] as? String?, ) } } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/InputFile.kt b/library/src/main/java/io/appwrite/models/InputFile.kt deleted file mode 100644 index afbb2e9..0000000 --- a/library/src/main/java/io/appwrite/models/InputFile.kt +++ /dev/null @@ -1,37 +0,0 @@ -package io.appwrite.models - -import java.io.File -import java.net.URLConnection -import java.nio.file.Files -import java.nio.file.Paths - -class InputFile private constructor() { - - lateinit var path: String - lateinit var filename: String - lateinit var mimeType: String - lateinit var sourceType: String - lateinit var data: Any - - companion object { - fun fromFile(file: File) = InputFile().apply { - path = file.canonicalPath - filename = file.name - mimeType = Files.probeContentType(Paths.get(file.canonicalPath)) - ?: URLConnection.guessContentTypeFromName(filename) - ?: "" - sourceType = "file" - } - - fun fromPath(path: String): InputFile = fromFile(File(path)).apply { - sourceType = "path" - } - - fun fromBytes(bytes: ByteArray, filename: String = "", mimeType: String = "") = InputFile().apply { - this.filename = filename - this.mimeType = mimeType - data = bytes - sourceType = "bytes" - } - } -} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Payload.kt b/library/src/main/java/io/appwrite/models/Payload.kt new file mode 100644 index 0000000..46a13e3 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Payload.kt @@ -0,0 +1,71 @@ +package io.appwrite.models + +import io.appwrite.extensions.gson +import java.io.File +import java.net.URLConnection +import java.nio.file.Files +import java.nio.file.Paths + +class Payload private constructor() { + + lateinit var path: String + lateinit var filename: String + lateinit var sourceType: String + lateinit var data: Any + var mimeType: String? = null + + override fun toString(): String { + if (sourceType != "bytes") { + throw IllegalArgumentException("source type is not supported: $sourceType") + } + + return String(data as ByteArray) + } + + fun toBinary(): ByteArray { + if (sourceType != "bytes") { + throw IllegalArgumentException("source type is not supported: $sourceType") + } + + return data as ByteArray + } + + fun toJson(): MutableMap { + if (sourceType != "bytes") { + throw IllegalArgumentException("source type is not supported: $sourceType") + } + + return gson.fromJson(toString(), MutableMap::class.java) as MutableMap + } + + fun toFile(path: String): File { + val file = File(path) + file.appendBytes(toBinary()) + return file + } + + companion object { + fun fromFile(path: String,filename: String = ""): Payload = fromFileObject(File(path), filename).apply { + sourceType = "path" + } + + fun fromBinary(bytes: ByteArray, filename: String = "") = Payload().apply { + this.filename = filename + data = bytes + sourceType = "bytes" + } + + fun fromString(string: String) = fromBinary(string.toByteArray()) + + fun fromJson(data: Any) = fromString(gson.toJson(data)) + + fun fromFileObject(file: File, name: String = "") = Payload().apply { + path = file.canonicalPath + filename = if (name != "") name else file.name + mimeType = Files.probeContentType(Paths.get(file.canonicalPath)) + ?: URLConnection.guessContentTypeFromName(filename) + ?: "" + sourceType = "file" + } + } +} diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 95dd107..0962796 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -28,19 +28,19 @@ class Account(client: Client) : Service(client) { */ suspend fun get( nestedType: Class, - ): io.appwrite.models.User { + ): io.appwrite.models.User { val apiPath = "/account" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -59,9 +59,9 @@ class Account(client: Client) : Service(client) { */ @Throws(AppwriteException::class) suspend fun get( - ): io.appwrite.models.User> = get( + ): io.appwrite.models.User> = get( nestedType = classOf(), - ) + ) /** * Create account @@ -81,23 +81,23 @@ class Account(client: Client) : Service(client) { password: String, name: String? = null, nestedType: Class, - ): io.appwrite.models.User { + ): io.appwrite.models.User { val apiPath = "/account" val apiParams = mutableMapOf( - "userId" to userId, - "email" to email, - "password" to password, - "name" to name, + "userId" to userId, + "email" to email, + "password" to password, + "name" to name, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -125,13 +125,13 @@ class Account(client: Client) : Service(client) { email: String, password: String, name: String? = null, - ): io.appwrite.models.User> = create( + ): io.appwrite.models.User> = create( userId, email, password, name, nestedType = classOf(), - ) + ) /** * Update email @@ -146,21 +146,21 @@ class Account(client: Client) : Service(client) { email: String, password: String, nestedType: Class, - ): io.appwrite.models.User { + ): io.appwrite.models.User { val apiPath = "/account/email" val apiParams = mutableMapOf( - "email" to email, - "password" to password, + "email" to email, + "password" to password, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } - return client.call( + return client.call( "PATCH", apiPath, apiHeaders, @@ -183,11 +183,11 @@ class Account(client: Client) : Service(client) { suspend fun updateEmail( email: String, password: String, - ): io.appwrite.models.User> = updateEmail( + ): io.appwrite.models.User> = updateEmail( email, password, nestedType = classOf(), - ) + ) /** * List Identities @@ -200,20 +200,20 @@ class Account(client: Client) : Service(client) { @JvmOverloads suspend fun listIdentities( queries: List? = null, - ): io.appwrite.models.IdentityList { + ): io.appwrite.models.IdentityList { val apiPath = "/account/identities" val apiParams = mutableMapOf( - "queries" to queries, + "queries" to queries, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.IdentityList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.IdentityList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -234,16 +234,16 @@ class Account(client: Client) : Service(client) { */ suspend fun deleteIdentity( identityId: String, - ): Any { + ): Any { val apiPath = "/account/identities/{identityId}" .replace("{identityId}", identityId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - return client.call( + return client.call( "DELETE", apiPath, apiHeaders, @@ -261,19 +261,19 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.Jwt] */ suspend fun createJWT( - ): io.appwrite.models.Jwt { - val apiPath = "/account/jwt" + ): io.appwrite.models.Jwt { + val apiPath = "/account/jwts" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Jwt = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Jwt.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -295,20 +295,20 @@ class Account(client: Client) : Service(client) { @JvmOverloads suspend fun listLogs( queries: List? = null, - ): io.appwrite.models.LogList { + ): io.appwrite.models.LogList { val apiPath = "/account/logs" val apiParams = mutableMapOf( - "queries" to queries, + "queries" to queries, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LogList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.LogList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -330,20 +330,20 @@ class Account(client: Client) : Service(client) { suspend fun updateMFA( mfa: Boolean, nestedType: Class, - ): io.appwrite.models.User { + ): io.appwrite.models.User { val apiPath = "/account/mfa" val apiParams = mutableMapOf( - "mfa" to mfa, + "mfa" to mfa, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } - return client.call( + return client.call( "PATCH", apiPath, apiHeaders, @@ -364,13 +364,13 @@ class Account(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun updateMFA( mfa: Boolean, - ): io.appwrite.models.User> = updateMFA( + ): io.appwrite.models.User> = updateMFA( mfa, nestedType = classOf(), - ) + ) /** - * Add Authenticator + * Create Authenticator * * Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. * @@ -379,20 +379,20 @@ class Account(client: Client) : Service(client) { */ suspend fun createMfaAuthenticator( type: io.appwrite.enums.AuthenticatorType, - ): io.appwrite.models.MfaType { + ): io.appwrite.models.MfaType { val apiPath = "/account/mfa/authenticators/{type}" .replace("{type}", type.value) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MfaType = { @Suppress("UNCHECKED_CAST") io.appwrite.models.MfaType.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -406,7 +406,7 @@ class Account(client: Client) : Service(client) { /** * Verify Authenticator * - * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. add + * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. * * @param type Type of authenticator. * @param otp Valid verification token. @@ -416,21 +416,21 @@ class Account(client: Client) : Service(client) { type: io.appwrite.enums.AuthenticatorType, otp: String, nestedType: Class, - ): io.appwrite.models.User { + ): io.appwrite.models.User { val apiPath = "/account/mfa/authenticators/{type}" .replace("{type}", type.value) val apiParams = mutableMapOf( - "otp" to otp, + "otp" to otp, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } - return client.call( + return client.call( "PUT", apiPath, apiHeaders, @@ -443,7 +443,7 @@ class Account(client: Client) : Service(client) { /** * Verify Authenticator * - * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. add + * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. * * @param type Type of authenticator. * @param otp Valid verification token. @@ -453,11 +453,11 @@ class Account(client: Client) : Service(client) { suspend fun updateMfaAuthenticator( type: io.appwrite.enums.AuthenticatorType, otp: String, - ): io.appwrite.models.User> = updateMfaAuthenticator( + ): io.appwrite.models.User> = updateMfaAuthenticator( type, otp, nestedType = classOf(), - ) + ) /** * Delete Authenticator @@ -465,23 +465,20 @@ class Account(client: Client) : Service(client) { * Delete an authenticator for a user by ID. * * @param type Type of authenticator. - * @param otp Valid verification token. * @return [Any] */ suspend fun deleteMfaAuthenticator( type: io.appwrite.enums.AuthenticatorType, - otp: String, - ): Any { + ): Any { val apiPath = "/account/mfa/authenticators/{type}" .replace("{type}", type.value) val apiParams = mutableMapOf( - "otp" to otp, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - return client.call( + return client.call( "DELETE", apiPath, apiHeaders, @@ -492,7 +489,7 @@ class Account(client: Client) : Service(client) { /** - * Create 2FA Challenge + * Create MFA Challenge * * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. * @@ -501,20 +498,20 @@ class Account(client: Client) : Service(client) { */ suspend fun createMfaChallenge( factor: io.appwrite.enums.AuthenticationFactor, - ): io.appwrite.models.MfaChallenge { + ): io.appwrite.models.MfaChallenge { val apiPath = "/account/mfa/challenge" val apiParams = mutableMapOf( - "factor" to factor, + "factor" to factor, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MfaChallenge = { @Suppress("UNCHECKED_CAST") io.appwrite.models.MfaChallenge.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -537,17 +534,17 @@ class Account(client: Client) : Service(client) { suspend fun updateMfaChallenge( challengeId: String, otp: String, - ): Any { + ): Any { val apiPath = "/account/mfa/challenge" val apiParams = mutableMapOf( - "challengeId" to challengeId, - "otp" to otp, + "challengeId" to challengeId, + "otp" to otp, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - return client.call( + return client.call( "PUT", apiPath, apiHeaders, @@ -565,19 +562,19 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.MfaFactors] */ suspend fun listMfaFactors( - ): io.appwrite.models.MfaFactors { + ): io.appwrite.models.MfaFactors { val apiPath = "/account/mfa/factors" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MfaFactors = { @Suppress("UNCHECKED_CAST") io.appwrite.models.MfaFactors.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -596,19 +593,19 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.MfaRecoveryCodes] */ suspend fun getMfaRecoveryCodes( - ): io.appwrite.models.MfaRecoveryCodes { + ): io.appwrite.models.MfaRecoveryCodes { val apiPath = "/account/mfa/recovery-codes" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MfaRecoveryCodes = { @Suppress("UNCHECKED_CAST") io.appwrite.models.MfaRecoveryCodes.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -627,19 +624,19 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.MfaRecoveryCodes] */ suspend fun createMfaRecoveryCodes( - ): io.appwrite.models.MfaRecoveryCodes { + ): io.appwrite.models.MfaRecoveryCodes { val apiPath = "/account/mfa/recovery-codes" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MfaRecoveryCodes = { @Suppress("UNCHECKED_CAST") io.appwrite.models.MfaRecoveryCodes.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -658,19 +655,19 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.MfaRecoveryCodes] */ suspend fun updateMfaRecoveryCodes( - ): io.appwrite.models.MfaRecoveryCodes { + ): io.appwrite.models.MfaRecoveryCodes { val apiPath = "/account/mfa/recovery-codes" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MfaRecoveryCodes = { @Suppress("UNCHECKED_CAST") io.appwrite.models.MfaRecoveryCodes.from(map = it as Map) } - return client.call( + return client.call( "PATCH", apiPath, apiHeaders, @@ -692,20 +689,20 @@ class Account(client: Client) : Service(client) { suspend fun updateName( name: String, nestedType: Class, - ): io.appwrite.models.User { + ): io.appwrite.models.User { val apiPath = "/account/name" val apiParams = mutableMapOf( - "name" to name, + "name" to name, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } - return client.call( + return client.call( "PATCH", apiPath, apiHeaders, @@ -726,10 +723,10 @@ class Account(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun updateName( name: String, - ): io.appwrite.models.User> = updateName( + ): io.appwrite.models.User> = updateName( name, nestedType = classOf(), - ) + ) /** * Update password @@ -745,21 +742,21 @@ class Account(client: Client) : Service(client) { password: String, oldPassword: String? = null, nestedType: Class, - ): io.appwrite.models.User { + ): io.appwrite.models.User { val apiPath = "/account/password" val apiParams = mutableMapOf( - "password" to password, - "oldPassword" to oldPassword, + "password" to password, + "oldPassword" to oldPassword, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } - return client.call( + return client.call( "PATCH", apiPath, apiHeaders, @@ -783,11 +780,11 @@ class Account(client: Client) : Service(client) { suspend fun updatePassword( password: String, oldPassword: String? = null, - ): io.appwrite.models.User> = updatePassword( + ): io.appwrite.models.User> = updatePassword( password, oldPassword, nestedType = classOf(), - ) + ) /** * Update phone @@ -802,21 +799,21 @@ class Account(client: Client) : Service(client) { phone: String, password: String, nestedType: Class, - ): io.appwrite.models.User { + ): io.appwrite.models.User { val apiPath = "/account/phone" val apiParams = mutableMapOf( - "phone" to phone, - "password" to password, + "phone" to phone, + "password" to password, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } - return client.call( + return client.call( "PATCH", apiPath, apiHeaders, @@ -839,11 +836,11 @@ class Account(client: Client) : Service(client) { suspend fun updatePhone( phone: String, password: String, - ): io.appwrite.models.User> = updatePhone( + ): io.appwrite.models.User> = updatePhone( phone, password, nestedType = classOf(), - ) + ) /** * Get account preferences @@ -854,19 +851,19 @@ class Account(client: Client) : Service(client) { */ suspend fun getPrefs( nestedType: Class, - ): io.appwrite.models.Preferences { + ): io.appwrite.models.Preferences { val apiPath = "/account/prefs" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Preferences.from(map = it as Map, nestedType) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -885,9 +882,9 @@ class Account(client: Client) : Service(client) { */ @Throws(AppwriteException::class) suspend fun getPrefs( - ): io.appwrite.models.Preferences> = getPrefs( + ): io.appwrite.models.Preferences> = getPrefs( nestedType = classOf(), - ) + ) /** * Update preferences @@ -900,20 +897,20 @@ class Account(client: Client) : Service(client) { suspend fun updatePrefs( prefs: Any, nestedType: Class, - ): io.appwrite.models.User { + ): io.appwrite.models.User { val apiPath = "/account/prefs" val apiParams = mutableMapOf( - "prefs" to prefs, + "prefs" to prefs, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } - return client.call( + return client.call( "PATCH", apiPath, apiHeaders, @@ -934,10 +931,10 @@ class Account(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun updatePrefs( prefs: Any, - ): io.appwrite.models.User> = updatePrefs( + ): io.appwrite.models.User> = updatePrefs( prefs, nestedType = classOf(), - ) + ) /** * Create password recovery @@ -951,21 +948,21 @@ class Account(client: Client) : Service(client) { suspend fun createRecovery( email: String, url: String, - ): io.appwrite.models.Token { + ): io.appwrite.models.Token { val apiPath = "/account/recovery" val apiParams = mutableMapOf( - "email" to email, - "url" to url, + "email" to email, + "url" to url, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -990,22 +987,22 @@ class Account(client: Client) : Service(client) { userId: String, secret: String, password: String, - ): io.appwrite.models.Token { + ): io.appwrite.models.Token { val apiPath = "/account/recovery" val apiParams = mutableMapOf( - "userId" to userId, - "secret" to secret, - "password" to password, + "userId" to userId, + "secret" to secret, + "password" to password, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } - return client.call( + return client.call( "PUT", apiPath, apiHeaders, @@ -1024,19 +1021,19 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.SessionList] */ suspend fun listSessions( - ): io.appwrite.models.SessionList { + ): io.appwrite.models.SessionList { val apiPath = "/account/sessions" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.SessionList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.SessionList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -1055,15 +1052,15 @@ class Account(client: Client) : Service(client) { * @return [Any] */ suspend fun deleteSessions( - ): Any { + ): Any { val apiPath = "/account/sessions" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - return client.call( + return client.call( "DELETE", apiPath, apiHeaders, @@ -1081,19 +1078,19 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.Session] */ suspend fun createAnonymousSession( - ): io.appwrite.models.Session { + ): io.appwrite.models.Session { val apiPath = "/account/sessions/anonymous" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -1116,21 +1113,21 @@ class Account(client: Client) : Service(client) { suspend fun createEmailPasswordSession( email: String, password: String, - ): io.appwrite.models.Session { + ): io.appwrite.models.Session { val apiPath = "/account/sessions/email" val apiParams = mutableMapOf( - "email" to email, - "password" to password, + "email" to email, + "password" to password, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -1153,21 +1150,21 @@ class Account(client: Client) : Service(client) { suspend fun updateMagicURLSession( userId: String, secret: String, - ): io.appwrite.models.Session { + ): io.appwrite.models.Session { val apiPath = "/account/sessions/magic-url" val apiParams = mutableMapOf( - "userId" to userId, - "secret" to secret, + "userId" to userId, + "secret" to secret, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } - return client.call( + return client.call( "PUT", apiPath, apiHeaders, @@ -1195,14 +1192,14 @@ class Account(client: Client) : Service(client) { success: String? = null, failure: String? = null, scopes: List? = null, - ) { + ) { val apiPath = "/account/sessions/oauth2/{provider}" .replace("{provider}", provider.value) val apiParams = mutableMapOf( - "success" to success, - "failure" to failure, - "scopes" to scopes, + "success" to success, + "failure" to failure, + "scopes" to scopes, "project" to client.config["project"], ) val apiQuery = mutableListOf() @@ -1212,7 +1209,9 @@ class Account(client: Client) : Service(client) { return@forEach } is List<*> -> { - apiQuery.add("${it.key}[]=${it.value.toString()}") + (it.value as List<*>).forEach { v -> + apiQuery.add("${it.key}[]=${v.toString()}") + } } else -> { apiQuery.add("${it.key}=${it.value.toString()}") @@ -1241,7 +1240,7 @@ class Account(client: Client) : Service(client) { .domain(Uri.parse(client.endpoint).host!!) .httpOnly() .build() - + client.http.cookieJar.saveFromResponse( client.endpoint.toHttpUrl(), listOf(cookie) @@ -1262,21 +1261,21 @@ class Account(client: Client) : Service(client) { suspend fun updatePhoneSession( userId: String, secret: String, - ): io.appwrite.models.Session { + ): io.appwrite.models.Session { val apiPath = "/account/sessions/phone" val apiParams = mutableMapOf( - "userId" to userId, - "secret" to secret, + "userId" to userId, + "secret" to secret, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } - return client.call( + return client.call( "PUT", apiPath, apiHeaders, @@ -1299,21 +1298,21 @@ class Account(client: Client) : Service(client) { suspend fun createSession( userId: String, secret: String, - ): io.appwrite.models.Session { + ): io.appwrite.models.Session { val apiPath = "/account/sessions/token" val apiParams = mutableMapOf( - "userId" to userId, - "secret" to secret, + "userId" to userId, + "secret" to secret, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -1334,20 +1333,20 @@ class Account(client: Client) : Service(client) { */ suspend fun getSession( sessionId: String, - ): io.appwrite.models.Session { + ): io.appwrite.models.Session { val apiPath = "/account/sessions/{sessionId}" .replace("{sessionId}", sessionId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -1368,20 +1367,20 @@ class Account(client: Client) : Service(client) { */ suspend fun updateSession( sessionId: String, - ): io.appwrite.models.Session { + ): io.appwrite.models.Session { val apiPath = "/account/sessions/{sessionId}" .replace("{sessionId}", sessionId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } - return client.call( + return client.call( "PATCH", apiPath, apiHeaders, @@ -1402,16 +1401,16 @@ class Account(client: Client) : Service(client) { */ suspend fun deleteSession( sessionId: String, - ): Any { + ): Any { val apiPath = "/account/sessions/{sessionId}" .replace("{sessionId}", sessionId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - return client.call( + return client.call( "DELETE", apiPath, apiHeaders, @@ -1430,19 +1429,19 @@ class Account(client: Client) : Service(client) { */ suspend fun updateStatus( nestedType: Class, - ): io.appwrite.models.User { + ): io.appwrite.models.User { val apiPath = "/account/status" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } - return client.call( + return client.call( "PATCH", apiPath, apiHeaders, @@ -1461,9 +1460,9 @@ class Account(client: Client) : Service(client) { */ @Throws(AppwriteException::class) suspend fun updateStatus( - ): io.appwrite.models.User> = updateStatus( + ): io.appwrite.models.User> = updateStatus( nestedType = classOf(), - ) + ) /** * Create push target @@ -1480,22 +1479,22 @@ class Account(client: Client) : Service(client) { targetId: String, identifier: String, providerId: String? = null, - ): io.appwrite.models.Target { + ): io.appwrite.models.Target { val apiPath = "/account/targets/push" val apiParams = mutableMapOf( - "targetId" to targetId, - "identifier" to identifier, - "providerId" to providerId, + "targetId" to targetId, + "identifier" to identifier, + "providerId" to providerId, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Target = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Target.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -1518,21 +1517,21 @@ class Account(client: Client) : Service(client) { suspend fun updatePushTarget( targetId: String, identifier: String, - ): io.appwrite.models.Target { + ): io.appwrite.models.Target { val apiPath = "/account/targets/{targetId}/push" .replace("{targetId}", targetId) val apiParams = mutableMapOf( - "identifier" to identifier, + "identifier" to identifier, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Target = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Target.from(map = it as Map) } - return client.call( + return client.call( "PUT", apiPath, apiHeaders, @@ -1553,16 +1552,16 @@ class Account(client: Client) : Service(client) { */ suspend fun deletePushTarget( targetId: String, - ): Any { + ): Any { val apiPath = "/account/targets/{targetId}/push" .replace("{targetId}", targetId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - return client.call( + return client.call( "DELETE", apiPath, apiHeaders, @@ -1587,22 +1586,22 @@ class Account(client: Client) : Service(client) { userId: String, email: String, phrase: Boolean? = null, - ): io.appwrite.models.Token { + ): io.appwrite.models.Token { val apiPath = "/account/tokens/email" val apiParams = mutableMapOf( - "userId" to userId, - "email" to email, - "phrase" to phrase, + "userId" to userId, + "email" to email, + "phrase" to phrase, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -1630,23 +1629,23 @@ class Account(client: Client) : Service(client) { email: String, url: String? = null, phrase: Boolean? = null, - ): io.appwrite.models.Token { + ): io.appwrite.models.Token { val apiPath = "/account/tokens/magic-url" val apiParams = mutableMapOf( - "userId" to userId, - "email" to email, - "url" to url, - "phrase" to phrase, + "userId" to userId, + "email" to email, + "url" to url, + "phrase" to phrase, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -1674,14 +1673,14 @@ class Account(client: Client) : Service(client) { success: String? = null, failure: String? = null, scopes: List? = null, - ) { + ) { val apiPath = "/account/tokens/oauth2/{provider}" .replace("{provider}", provider.value) val apiParams = mutableMapOf( - "success" to success, - "failure" to failure, - "scopes" to scopes, + "success" to success, + "failure" to failure, + "scopes" to scopes, "project" to client.config["project"], ) val apiQuery = mutableListOf() @@ -1691,7 +1690,9 @@ class Account(client: Client) : Service(client) { return@forEach } is List<*> -> { - apiQuery.add("${it.key}[]=${it.value.toString()}") + (it.value as List<*>).forEach { v -> + apiQuery.add("${it.key}[]=${v.toString()}") + } } else -> { apiQuery.add("${it.key}=${it.value.toString()}") @@ -1720,7 +1721,7 @@ class Account(client: Client) : Service(client) { .domain(Uri.parse(client.endpoint).host!!) .httpOnly() .build() - + client.http.cookieJar.saveFromResponse( client.endpoint.toHttpUrl(), listOf(cookie) @@ -1741,21 +1742,21 @@ class Account(client: Client) : Service(client) { suspend fun createPhoneToken( userId: String, phone: String, - ): io.appwrite.models.Token { + ): io.appwrite.models.Token { val apiPath = "/account/tokens/phone" val apiParams = mutableMapOf( - "userId" to userId, - "phone" to phone, + "userId" to userId, + "phone" to phone, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -1776,20 +1777,20 @@ class Account(client: Client) : Service(client) { */ suspend fun createVerification( url: String, - ): io.appwrite.models.Token { + ): io.appwrite.models.Token { val apiPath = "/account/verification" val apiParams = mutableMapOf( - "url" to url, + "url" to url, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -1812,21 +1813,21 @@ class Account(client: Client) : Service(client) { suspend fun updateVerification( userId: String, secret: String, - ): io.appwrite.models.Token { + ): io.appwrite.models.Token { val apiPath = "/account/verification" val apiParams = mutableMapOf( - "userId" to userId, - "secret" to secret, + "userId" to userId, + "secret" to secret, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } - return client.call( + return client.call( "PUT", apiPath, apiHeaders, @@ -1845,19 +1846,19 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.Token] */ suspend fun createPhoneVerification( - ): io.appwrite.models.Token { + ): io.appwrite.models.Token { val apiPath = "/account/verification/phone" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -1869,7 +1870,7 @@ class Account(client: Client) : Service(client) { /** - * Create phone verification (confirmation) + * Update 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. * @@ -1880,21 +1881,21 @@ class Account(client: Client) : Service(client) { suspend fun updatePhoneVerification( userId: String, secret: String, - ): io.appwrite.models.Token { + ): io.appwrite.models.Token { val apiPath = "/account/verification/phone" val apiParams = mutableMapOf( - "userId" to userId, - "secret" to secret, + "userId" to userId, + "secret" to secret, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } - return client.call( + return client.call( "PUT", apiPath, apiHeaders, @@ -1905,4 +1906,4 @@ class Account(client: Client) : Service(client) { } -} \ 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 2cb130d..fb926f0 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -34,14 +34,14 @@ class Avatars(client: Client) : Service(client) { width: Long? = null, height: Long? = null, quality: Long? = null, - ): ByteArray { + ): ByteArray { val apiPath = "/avatars/browsers/{code}" .replace("{code}", code.value) val apiParams = mutableMapOf( - "width" to width, - "height" to height, - "quality" to quality, + "width" to width, + "height" to height, + "quality" to quality, "project" to client.config["project"], ) return client.call( @@ -70,14 +70,14 @@ class Avatars(client: Client) : Service(client) { width: Long? = null, height: Long? = null, quality: Long? = null, - ): ByteArray { + ): ByteArray { val apiPath = "/avatars/credit-cards/{code}" .replace("{code}", code.value) val apiParams = mutableMapOf( - "width" to width, - "height" to height, - "quality" to quality, + "width" to width, + "height" to height, + "quality" to quality, "project" to client.config["project"], ) return client.call( @@ -92,18 +92,18 @@ class Avatars(client: Client) : Service(client) { /** * 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.This endpoint does not follow HTTP redirects. * * @param url Website URL which you want to fetch the favicon from. * @return [ByteArray] */ suspend fun getFavicon( url: String, - ): ByteArray { + ): ByteArray { val apiPath = "/avatars/favicon" val apiParams = mutableMapOf( - "url" to url, + "url" to url, "project" to client.config["project"], ) return client.call( @@ -132,14 +132,14 @@ class Avatars(client: Client) : Service(client) { width: Long? = null, height: Long? = null, quality: Long? = null, - ): ByteArray { + ): ByteArray { val apiPath = "/avatars/flags/{code}" .replace("{code}", code.value) val apiParams = mutableMapOf( - "width" to width, - "height" to height, - "quality" to quality, + "width" to width, + "height" to height, + "quality" to quality, "project" to client.config["project"], ) return client.call( @@ -154,7 +154,7 @@ class Avatars(client: Client) : Service(client) { /** * 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.This endpoint does not follow HTTP redirects. * * @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. @@ -166,13 +166,13 @@ class Avatars(client: Client) : Service(client) { url: String, width: Long? = null, height: Long? = null, - ): ByteArray { + ): ByteArray { val apiPath = "/avatars/image" val apiParams = mutableMapOf( - "url" to url, - "width" to width, - "height" to height, + "url" to url, + "width" to width, + "height" to height, "project" to client.config["project"], ) return client.call( @@ -201,14 +201,14 @@ class Avatars(client: Client) : Service(client) { width: Long? = null, height: Long? = null, background: String? = null, - ): ByteArray { + ): ByteArray { val apiPath = "/avatars/initials" val apiParams = mutableMapOf( - "name" to name, - "width" to width, - "height" to height, - "background" to background, + "name" to name, + "width" to width, + "height" to height, + "background" to background, "project" to client.config["project"], ) return client.call( @@ -237,14 +237,14 @@ class Avatars(client: Client) : Service(client) { size: Long? = null, margin: Long? = null, download: Boolean? = null, - ): ByteArray { + ): ByteArray { val apiPath = "/avatars/qr" val apiParams = mutableMapOf( - "text" to text, - "size" to size, - "margin" to margin, - "download" to download, + "text" to text, + "size" to size, + "margin" to margin, + "download" to download, "project" to client.config["project"], ) return client.call( @@ -256,4 +256,4 @@ class Avatars(client: Client) : Service(client) { } -} \ 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 70ecf23..22d5375 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -31,22 +31,22 @@ class Databases(client: Client) : Service(client) { collectionId: String, queries: List? = null, nestedType: Class, - ): io.appwrite.models.DocumentList { + ): io.appwrite.models.DocumentList { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) val apiParams = mutableMapOf( - "queries" to queries, + "queries" to queries, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.DocumentList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.DocumentList.from(map = it as Map, nestedType) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -72,12 +72,12 @@ class Databases(client: Client) : Service(client) { databaseId: String, collectionId: String, queries: List? = null, - ): io.appwrite.models.DocumentList> = listDocuments( + ): io.appwrite.models.DocumentList> = listDocuments( databaseId, collectionId, queries, nestedType = classOf(), - ) + ) /** * Create document @@ -99,24 +99,24 @@ class Databases(client: Client) : Service(client) { data: Any, permissions: List? = null, nestedType: Class, - ): io.appwrite.models.Document { + ): io.appwrite.models.Document { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) val apiParams = mutableMapOf( - "documentId" to documentId, - "data" to data, - "permissions" to permissions, + "documentId" to documentId, + "data" to data, + "permissions" to permissions, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Document.from(map = it as Map, nestedType) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -146,14 +146,14 @@ class Databases(client: Client) : Service(client) { documentId: String, data: Any, permissions: List? = null, - ): io.appwrite.models.Document> = createDocument( + ): io.appwrite.models.Document> = createDocument( databaseId, collectionId, documentId, data, permissions, nestedType = classOf(), - ) + ) /** * Get document @@ -173,23 +173,23 @@ class Databases(client: Client) : Service(client) { documentId: String, queries: List? = null, nestedType: Class, - ): io.appwrite.models.Document { + ): io.appwrite.models.Document { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) .replace("{documentId}", documentId) val apiParams = mutableMapOf( - "queries" to queries, + "queries" to queries, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Document.from(map = it as Map, nestedType) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -217,13 +217,13 @@ class Databases(client: Client) : Service(client) { collectionId: String, documentId: String, queries: List? = null, - ): io.appwrite.models.Document> = getDocument( + ): io.appwrite.models.Document> = getDocument( databaseId, collectionId, documentId, queries, nestedType = classOf(), - ) + ) /** * Update document @@ -245,24 +245,24 @@ class Databases(client: Client) : Service(client) { data: Any? = null, permissions: List? = null, nestedType: Class, - ): io.appwrite.models.Document { + ): io.appwrite.models.Document { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) .replace("{documentId}", documentId) val apiParams = mutableMapOf( - "data" to data, - "permissions" to permissions, + "data" to data, + "permissions" to permissions, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Document.from(map = it as Map, nestedType) } - return client.call( + return client.call( "PATCH", apiPath, apiHeaders, @@ -292,14 +292,14 @@ class Databases(client: Client) : Service(client) { documentId: String, data: Any? = null, permissions: List? = null, - ): io.appwrite.models.Document> = updateDocument( + ): io.appwrite.models.Document> = updateDocument( databaseId, collectionId, documentId, data, permissions, nestedType = classOf(), - ) + ) /** * Delete document @@ -315,7 +315,7 @@ class Databases(client: Client) : Service(client) { databaseId: String, collectionId: String, documentId: String, - ): Any { + ): Any { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) @@ -323,10 +323,10 @@ class Databases(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - return client.call( + return client.call( "DELETE", apiPath, apiHeaders, @@ -336,4 +336,4 @@ class Databases(client: Client) : Service(client) { } -} \ 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 c7a81ad..59809dc 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -21,7 +21,7 @@ class Functions(client: Client) : Service(client) { * 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/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, responseStatusCode, duration + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.ExecutionList] */ @@ -30,22 +30,22 @@ class Functions(client: Client) : Service(client) { functionId: String, queries: List? = null, search: String? = null, - ): io.appwrite.models.ExecutionList { + ): io.appwrite.models.ExecutionList { val apiPath = "/functions/{functionId}/executions" .replace("{functionId}", functionId) val apiParams = mutableMapOf( - "queries" to queries, - "search" to search, + "queries" to queries, + "search" to search, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.ExecutionList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.ExecutionList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -67,35 +67,39 @@ class Functions(client: Client) : Service(client) { * @param path HTTP path of execution. Path can include query params. Default value is / * @param method HTTP method of execution. Default value is GET. * @param headers HTTP headers of execution. Defaults to empty. + * @param scheduledAt Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. * @return [io.appwrite.models.Execution] */ @JvmOverloads suspend fun createExecution( functionId: String, - body: String? = null, + body: Payload? = null, async: Boolean? = null, path: String? = null, method: io.appwrite.enums.ExecutionMethod? = null, headers: Any? = null, - ): io.appwrite.models.Execution { + scheduledAt: String? = null, + ): io.appwrite.models.Execution { val apiPath = "/functions/{functionId}/executions" .replace("{functionId}", functionId) val apiParams = mutableMapOf( - "body" to body, - "async" to async, - "path" to path, - "method" to method, - "headers" to headers, + "body" to (body?.toBinary() ?: ""), + "async" to async, + "path" to path, + "method" to method, + "headers" to headers, + "scheduledAt" to scheduledAt, ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", + val apiHeaders = mutableMapOf( + "content-type" to "multipart/form-data", + "accept" to "multipart/form-data", ) val converter: (Any) -> io.appwrite.models.Execution = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Execution.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -118,21 +122,21 @@ class Functions(client: Client) : Service(client) { suspend fun getExecution( functionId: String, executionId: String, - ): io.appwrite.models.Execution { + ): io.appwrite.models.Execution { val apiPath = "/functions/{functionId}/executions/{executionId}" .replace("{functionId}", functionId) .replace("{executionId}", executionId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Execution = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Execution.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -143,4 +147,4 @@ class Functions(client: Client) : Service(client) { } -} \ 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 index 6c977a2..1052e67 100644 --- a/library/src/main/java/io/appwrite/services/Graphql.kt +++ b/library/src/main/java/io/appwrite/services/Graphql.kt @@ -25,20 +25,20 @@ class Graphql(client: Client) : Service(client) { */ suspend fun query( query: Any, - ): Any { + ): Any { val apiPath = "/graphql" val apiParams = mutableMapOf( - "query" to query, + "query" to query, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "x-sdk-graphql" to "true", "content-type" to "application/json", ) val converter: (Any) -> Any = { it } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -59,20 +59,20 @@ class Graphql(client: Client) : Service(client) { */ suspend fun mutation( query: Any, - ): Any { + ): Any { val apiPath = "/graphql/mutation" val apiParams = mutableMapOf( - "query" to query, + "query" to query, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "x-sdk-graphql" to "true", "content-type" to "application/json", ) val converter: (Any) -> Any = { it } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -83,4 +83,4 @@ class Graphql(client: Client) : Service(client) { } -} \ 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 ad3a6f6..bcee309 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -23,19 +23,19 @@ class Locale(client: Client) : Service(client) { * @return [io.appwrite.models.Locale] */ suspend fun get( - ): io.appwrite.models.Locale { + ): io.appwrite.models.Locale { val apiPath = "/locale" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Locale = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Locale.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -54,19 +54,19 @@ class Locale(client: Client) : Service(client) { * @return [io.appwrite.models.LocaleCodeList] */ suspend fun listCodes( - ): io.appwrite.models.LocaleCodeList { + ): io.appwrite.models.LocaleCodeList { val apiPath = "/locale/codes" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LocaleCodeList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.LocaleCodeList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -85,19 +85,19 @@ class Locale(client: Client) : Service(client) { * @return [io.appwrite.models.ContinentList] */ suspend fun listContinents( - ): io.appwrite.models.ContinentList { + ): io.appwrite.models.ContinentList { val apiPath = "/locale/continents" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.ContinentList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.ContinentList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -116,19 +116,19 @@ class Locale(client: Client) : Service(client) { * @return [io.appwrite.models.CountryList] */ suspend fun listCountries( - ): io.appwrite.models.CountryList { + ): io.appwrite.models.CountryList { val apiPath = "/locale/countries" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CountryList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.CountryList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -147,19 +147,19 @@ class Locale(client: Client) : Service(client) { * @return [io.appwrite.models.CountryList] */ suspend fun listCountriesEU( - ): io.appwrite.models.CountryList { + ): io.appwrite.models.CountryList { val apiPath = "/locale/countries/eu" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CountryList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.CountryList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -178,19 +178,19 @@ class Locale(client: Client) : Service(client) { * @return [io.appwrite.models.PhoneList] */ suspend fun listCountriesPhones( - ): io.appwrite.models.PhoneList { + ): io.appwrite.models.PhoneList { val apiPath = "/locale/countries/phones" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.PhoneList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.PhoneList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -209,19 +209,19 @@ class Locale(client: Client) : Service(client) { * @return [io.appwrite.models.CurrencyList] */ suspend fun listCurrencies( - ): io.appwrite.models.CurrencyList { + ): io.appwrite.models.CurrencyList { val apiPath = "/locale/currencies" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CurrencyList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.CurrencyList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -240,19 +240,19 @@ class Locale(client: Client) : Service(client) { * @return [io.appwrite.models.LanguageList] */ suspend fun listLanguages( - ): io.appwrite.models.LanguageList { + ): io.appwrite.models.LanguageList { val apiPath = "/locale/languages" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LanguageList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.LanguageList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -263,4 +263,4 @@ class Locale(client: Client) : Service(client) { } -} \ No newline at end of file +} diff --git a/library/src/main/java/io/appwrite/services/Messaging.kt b/library/src/main/java/io/appwrite/services/Messaging.kt index baca2c4..5c6504f 100644 --- a/library/src/main/java/io/appwrite/services/Messaging.kt +++ b/library/src/main/java/io/appwrite/services/Messaging.kt @@ -29,22 +29,22 @@ class Messaging(client: Client) : Service(client) { topicId: String, subscriberId: String, targetId: String, - ): io.appwrite.models.Subscriber { + ): io.appwrite.models.Subscriber { val apiPath = "/messaging/topics/{topicId}/subscribers" .replace("{topicId}", topicId) val apiParams = mutableMapOf( - "subscriberId" to subscriberId, - "targetId" to targetId, + "subscriberId" to subscriberId, + "targetId" to targetId, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Subscriber = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Subscriber.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -67,17 +67,17 @@ class Messaging(client: Client) : Service(client) { suspend fun deleteSubscriber( topicId: String, subscriberId: String, - ): Any { + ): Any { val apiPath = "/messaging/topics/{topicId}/subscribers/{subscriberId}" .replace("{topicId}", topicId) .replace("{subscriberId}", subscriberId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - return client.call( + return client.call( "DELETE", apiPath, apiHeaders, @@ -87,4 +87,4 @@ class Messaging(client: Client) : Service(client) { } -} \ 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 80dd45b..a65d5e6 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -32,22 +32,22 @@ class Storage(client: Client) : Service(client) { bucketId: String, queries: List? = null, search: String? = null, - ): io.appwrite.models.FileList { + ): io.appwrite.models.FileList { val apiPath = "/storage/buckets/{bucketId}/files" .replace("{bucketId}", bucketId) val apiParams = mutableMapOf( - "queries" to queries, - "search" to search, + "queries" to queries, + "search" to search, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.FileList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.FileList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -65,7 +65,7 @@ class Storage(client: Client) : Service(client) { * * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). * @param fileId File ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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. Appwrite SDKs provide helpers to handle file input. [Learn about file input](https://appwrite.io/docs/storage#file-input). + * @param file Binary file. Appwrite SDKs provide helpers to handle file input. [Learn about file input](https://appwrite.io/docs/products/storage/upload-download#input-file). * @param permissions An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.File] */ @@ -73,26 +73,26 @@ class Storage(client: Client) : Service(client) { suspend fun createFile( bucketId: String, fileId: String, - file: InputFile, + file: Payload, permissions: List? = null, - onProgress: ((UploadProgress) -> Unit)? = null + onProgress: ((UploadProgress) -> Unit)? = null ): io.appwrite.models.File { val apiPath = "/storage/buckets/{bucketId}/files" .replace("{bucketId}", bucketId) val apiParams = mutableMapOf( - "fileId" to fileId, - "file" to file, - "permissions" to permissions, + "fileId" to fileId, + "file" to file, + "permissions" to permissions, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "multipart/form-data", ) val converter: (Any) -> io.appwrite.models.File = { @Suppress("UNCHECKED_CAST") io.appwrite.models.File.from(map = it as Map) } - val idParamName: String? = "fileId" + val idParamName: String? = "fileId" val paramName = "file" return client.chunkedUpload( apiPath, @@ -119,21 +119,21 @@ class Storage(client: Client) : Service(client) { suspend fun getFile( bucketId: String, fileId: String, - ): io.appwrite.models.File { + ): io.appwrite.models.File { val apiPath = "/storage/buckets/{bucketId}/files/{fileId}" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.File = { @Suppress("UNCHECKED_CAST") io.appwrite.models.File.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -161,23 +161,23 @@ class Storage(client: Client) : Service(client) { fileId: String, name: String? = null, permissions: List? = null, - ): io.appwrite.models.File { + ): io.appwrite.models.File { val apiPath = "/storage/buckets/{bucketId}/files/{fileId}" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) val apiParams = mutableMapOf( - "name" to name, - "permissions" to permissions, + "name" to name, + "permissions" to permissions, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.File = { @Suppress("UNCHECKED_CAST") io.appwrite.models.File.from(map = it as Map) } - return client.call( + return client.call( "PUT", apiPath, apiHeaders, @@ -200,17 +200,17 @@ class Storage(client: Client) : Service(client) { suspend fun deleteFile( bucketId: String, fileId: String, - ): Any { + ): Any { val apiPath = "/storage/buckets/{bucketId}/files/{fileId}" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - return client.call( + return client.call( "DELETE", apiPath, apiHeaders, @@ -232,7 +232,7 @@ class Storage(client: Client) : Service(client) { suspend fun getFileDownload( bucketId: String, fileId: String, - ): ByteArray { + ): ByteArray { val apiPath = "/storage/buckets/{bucketId}/files/{fileId}/download" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) @@ -284,23 +284,23 @@ class Storage(client: Client) : Service(client) { rotation: Long? = null, background: String? = null, output: io.appwrite.enums.ImageFormat? = null, - ): ByteArray { + ): ByteArray { val apiPath = "/storage/buckets/{bucketId}/files/{fileId}/preview" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) val apiParams = mutableMapOf( - "width" to width, - "height" to height, - "gravity" to gravity, - "quality" to quality, - "borderWidth" to borderWidth, - "borderColor" to borderColor, - "borderRadius" to borderRadius, - "opacity" to opacity, - "rotation" to rotation, - "background" to background, - "output" to output, + "width" to width, + "height" to height, + "gravity" to gravity, + "quality" to quality, + "borderWidth" to borderWidth, + "borderColor" to borderColor, + "borderRadius" to borderRadius, + "opacity" to opacity, + "rotation" to rotation, + "background" to background, + "output" to output, "project" to client.config["project"], ) return client.call( @@ -324,7 +324,7 @@ class Storage(client: Client) : Service(client) { suspend fun getFileView( bucketId: String, fileId: String, - ): ByteArray { + ): ByteArray { val apiPath = "/storage/buckets/{bucketId}/files/{fileId}/view" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) @@ -341,4 +341,4 @@ class Storage(client: Client) : Service(client) { } -} \ 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 304e60d..cf611ba 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -29,21 +29,21 @@ class Teams(client: Client) : Service(client) { queries: List? = null, search: String? = null, nestedType: Class, - ): io.appwrite.models.TeamList { + ): io.appwrite.models.TeamList { val apiPath = "/teams" val apiParams = mutableMapOf( - "queries" to queries, - "search" to search, + "queries" to queries, + "search" to search, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.TeamList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.TeamList.from(map = it as Map, nestedType) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -67,11 +67,11 @@ class Teams(client: Client) : Service(client) { suspend fun list( queries: List? = null, search: String? = null, - ): io.appwrite.models.TeamList> = list( + ): io.appwrite.models.TeamList> = list( queries, search, nestedType = classOf(), - ) + ) /** * Create team @@ -89,22 +89,22 @@ class Teams(client: Client) : Service(client) { name: String, roles: List? = null, nestedType: Class, - ): io.appwrite.models.Team { + ): io.appwrite.models.Team { val apiPath = "/teams" val apiParams = mutableMapOf( - "teamId" to teamId, - "name" to name, - "roles" to roles, + "teamId" to teamId, + "name" to name, + "roles" to roles, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Team = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Team.from(map = it as Map, nestedType) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -130,12 +130,12 @@ class Teams(client: Client) : Service(client) { teamId: String, name: String, roles: List? = null, - ): io.appwrite.models.Team> = create( + ): io.appwrite.models.Team> = create( teamId, name, roles, nestedType = classOf(), - ) + ) /** * Get team @@ -148,20 +148,20 @@ class Teams(client: Client) : Service(client) { suspend fun get( teamId: String, nestedType: Class, - ): io.appwrite.models.Team { + ): io.appwrite.models.Team { val apiPath = "/teams/{teamId}" .replace("{teamId}", teamId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Team = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Team.from(map = it as Map, nestedType) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -182,10 +182,10 @@ class Teams(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun get( teamId: String, - ): io.appwrite.models.Team> = get( + ): io.appwrite.models.Team> = get( teamId, nestedType = classOf(), - ) + ) /** * Update name @@ -200,21 +200,21 @@ class Teams(client: Client) : Service(client) { teamId: String, name: String, nestedType: Class, - ): io.appwrite.models.Team { + ): io.appwrite.models.Team { val apiPath = "/teams/{teamId}" .replace("{teamId}", teamId) val apiParams = mutableMapOf( - "name" to name, + "name" to name, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Team = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Team.from(map = it as Map, nestedType) } - return client.call( + return client.call( "PUT", apiPath, apiHeaders, @@ -237,11 +237,11 @@ class Teams(client: Client) : Service(client) { suspend fun updateName( teamId: String, name: String, - ): io.appwrite.models.Team> = updateName( + ): io.appwrite.models.Team> = updateName( teamId, name, nestedType = classOf(), - ) + ) /** * Delete team @@ -253,16 +253,16 @@ class Teams(client: Client) : Service(client) { */ suspend fun delete( teamId: String, - ): Any { + ): Any { val apiPath = "/teams/{teamId}" .replace("{teamId}", teamId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - return client.call( + return client.call( "DELETE", apiPath, apiHeaders, @@ -287,22 +287,22 @@ class Teams(client: Client) : Service(client) { teamId: String, queries: List? = null, search: String? = null, - ): io.appwrite.models.MembershipList { + ): io.appwrite.models.MembershipList { val apiPath = "/teams/{teamId}/memberships" .replace("{teamId}", teamId) val apiParams = mutableMapOf( - "queries" to queries, - "search" to search, + "queries" to queries, + "search" to search, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MembershipList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.MembershipList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -323,7 +323,7 @@ class Teams(client: Client) : Service(client) { * @param email Email of the new team member. * @param userId ID of the user to be added to a team. * @param phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. - * @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 url URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. 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] */ @@ -336,26 +336,26 @@ class Teams(client: Client) : Service(client) { phone: String? = null, url: String? = null, name: String? = null, - ): io.appwrite.models.Membership { + ): io.appwrite.models.Membership { val apiPath = "/teams/{teamId}/memberships" .replace("{teamId}", teamId) val apiParams = mutableMapOf( - "email" to email, - "userId" to userId, - "phone" to phone, - "roles" to roles, - "url" to url, - "name" to name, - ) - val apiHeaders = mutableMapOf( + "email" to email, + "userId" to userId, + "phone" to phone, + "roles" to roles, + "url" to url, + "name" to name, + ) + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Membership.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -378,21 +378,21 @@ class Teams(client: Client) : Service(client) { suspend fun getMembership( teamId: String, membershipId: String, - ): io.appwrite.models.Membership { + ): io.appwrite.models.Membership { val apiPath = "/teams/{teamId}/memberships/{membershipId}" .replace("{teamId}", teamId) .replace("{membershipId}", membershipId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Membership.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -417,22 +417,22 @@ class Teams(client: Client) : Service(client) { teamId: String, membershipId: String, roles: List, - ): io.appwrite.models.Membership { + ): io.appwrite.models.Membership { val apiPath = "/teams/{teamId}/memberships/{membershipId}" .replace("{teamId}", teamId) .replace("{membershipId}", membershipId) val apiParams = mutableMapOf( - "roles" to roles, + "roles" to roles, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Membership.from(map = it as Map) } - return client.call( + return client.call( "PATCH", apiPath, apiHeaders, @@ -455,17 +455,17 @@ class Teams(client: Client) : Service(client) { suspend fun deleteMembership( teamId: String, membershipId: String, - ): Any { + ): Any { val apiPath = "/teams/{teamId}/memberships/{membershipId}" .replace("{teamId}", teamId) .replace("{membershipId}", membershipId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - return client.call( + return client.call( "DELETE", apiPath, apiHeaders, @@ -491,23 +491,23 @@ class Teams(client: Client) : Service(client) { membershipId: String, userId: String, secret: String, - ): io.appwrite.models.Membership { + ): io.appwrite.models.Membership { val apiPath = "/teams/{teamId}/memberships/{membershipId}/status" .replace("{teamId}", teamId) .replace("{membershipId}", membershipId) val apiParams = mutableMapOf( - "userId" to userId, - "secret" to secret, + "userId" to userId, + "secret" to secret, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Membership.from(map = it as Map) } - return client.call( + return client.call( "PATCH", apiPath, apiHeaders, @@ -529,20 +529,20 @@ class Teams(client: Client) : Service(client) { suspend fun getPrefs( teamId: String, nestedType: Class, - ): io.appwrite.models.Preferences { + ): io.appwrite.models.Preferences { val apiPath = "/teams/{teamId}/prefs" .replace("{teamId}", teamId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Preferences.from(map = it as Map, nestedType) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -563,10 +563,10 @@ class Teams(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun getPrefs( teamId: String, - ): io.appwrite.models.Preferences> = getPrefs( + ): io.appwrite.models.Preferences> = getPrefs( teamId, nestedType = classOf(), - ) + ) /** * Update preferences @@ -581,21 +581,21 @@ class Teams(client: Client) : Service(client) { teamId: String, prefs: Any, nestedType: Class, - ): io.appwrite.models.Preferences { + ): io.appwrite.models.Preferences { val apiPath = "/teams/{teamId}/prefs" .replace("{teamId}", teamId) val apiParams = mutableMapOf( - "prefs" to prefs, + "prefs" to prefs, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Preferences.from(map = it as Map, nestedType) } - return client.call( + return client.call( "PUT", apiPath, apiHeaders, @@ -618,10 +618,10 @@ class Teams(client: Client) : Service(client) { suspend fun updatePrefs( teamId: String, prefs: Any, - ): io.appwrite.models.Preferences> = updatePrefs( + ): io.appwrite.models.Preferences> = updatePrefs( teamId, prefs, nestedType = classOf(), - ) + ) -} \ No newline at end of file +} From 3d4e23c83eb026264cd38f5579d4f27cdc6a8754 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 18 Sep 2024 15:55:09 +0000 Subject: [PATCH 085/118] SDK binary support for executions (fix version) --- README.md | 4 ++-- library/src/main/java/io/appwrite/Client.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f8dab1a..9252fc7 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:6.0.0") +implementation("io.appwrite:sdk-for-android:7.0.0-rc1") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 6.0.0 + 7.0.0-rc1 ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 6520241..06a5bf6 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -87,7 +87,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "6.0.0", + "x-sdk-version" to "7.0.0-rc1", "x-appwrite-response-format" to "1.6.0" ) config = mutableMapOf() From 9ac99f6d96d68c3ddd00753ea65e5b58a814c013 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Tue, 1 Oct 2024 21:27:09 +0100 Subject: [PATCH 086/118] fix: multipart testing --- README.md | 4 ++-- library/src/main/java/io/appwrite/Client.kt | 10 ++++++++- .../main/java/io/appwrite/models/Execution.kt | 4 ++-- .../main/java/io/appwrite/models/Payload.kt | 2 ++ .../main/java/io/appwrite/services/Account.kt | 22 +++++++++---------- .../main/java/io/appwrite/services/Locale.kt | 2 +- .../main/java/io/appwrite/services/Storage.kt | 2 +- 7 files changed, 28 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 9252fc7..f8dab1a 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:7.0.0-rc1") +implementation("io.appwrite:sdk-for-android:6.0.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 7.0.0-rc1 + 6.0.0 ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 06a5bf6..635a902 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -87,7 +87,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "7.0.0-rc1", + "x-sdk-version" to "6.0.0", "x-appwrite-response-format" to "1.6.0" ) config = mutableMapOf() @@ -320,6 +320,14 @@ class Client @JvmOverloads constructor( ) } } + it.value is Payload -> { + val payload = it.value as Payload + if (payload.sourceType == "path") { + builder.addFormDataPart(it.key, payload.filename, File(payload.path).asRequestBody()) + } else { + builder.addFormDataPart(it.key, payload.toString()) + } + } else -> { builder.addFormDataPart(it.key, it.value.toString()) } diff --git a/library/src/main/java/io/appwrite/models/Execution.kt b/library/src/main/java/io/appwrite/models/Execution.kt index 44724fa..c16659a 100644 --- a/library/src/main/java/io/appwrite/models/Execution.kt +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -77,7 +77,7 @@ data class Execution( * HTTP response body. This will return empty unless execution is created as synchronous. */ @SerializedName("responseBody") - val responseBody: String, + val responseBody: Payload, /** * HTTP response headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. @@ -147,7 +147,7 @@ data class Execution( requestPath = map["requestPath"] as String, requestHeaders = (map["requestHeaders"] as List>).map { Headers.from(map = it) }, responseStatusCode = (map["responseStatusCode"] as Number).toLong(), - responseBody = map["responseBody"] as String, + responseBody = map["responseBody"] as Payload, responseHeaders = (map["responseHeaders"] as List>).map { Headers.from(map = it) }, logs = map["logs"] as String, errors = map["errors"] as String, diff --git a/library/src/main/java/io/appwrite/models/Payload.kt b/library/src/main/java/io/appwrite/models/Payload.kt index 46a13e3..5c9ff7f 100644 --- a/library/src/main/java/io/appwrite/models/Payload.kt +++ b/library/src/main/java/io/appwrite/models/Payload.kt @@ -39,6 +39,8 @@ class Payload private constructor() { } fun toFile(path: String): File { + Files.createDirectories(Paths.get(path).parent); + val file = File(path) file.appendBytes(toBinary()) return file diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 0962796..25c71e3 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -190,7 +190,7 @@ class Account(client: Client) : Service(client) { ) /** - * List Identities + * List identities * * Get the list of identities for the currently logged in user. * @@ -370,7 +370,7 @@ class Account(client: Client) : Service(client) { ) /** - * Create Authenticator + * Create authenticator * * Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. * @@ -404,7 +404,7 @@ class Account(client: Client) : Service(client) { /** - * Verify Authenticator + * Verify authenticator * * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. * @@ -441,7 +441,7 @@ class Account(client: Client) : Service(client) { } /** - * Verify Authenticator + * Verify authenticator * * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. * @@ -460,7 +460,7 @@ class Account(client: Client) : Service(client) { ) /** - * Delete Authenticator + * Delete authenticator * * Delete an authenticator for a user by ID. * @@ -489,7 +489,7 @@ class Account(client: Client) : Service(client) { /** - * Create MFA Challenge + * Create MFA challenge * * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. * @@ -523,7 +523,7 @@ class Account(client: Client) : Service(client) { /** - * Create MFA Challenge (confirmation) + * Create MFA challenge (confirmation) * * Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. * @@ -555,7 +555,7 @@ class Account(client: Client) : Service(client) { /** - * List Factors + * List factors * * List the factors available on the account to be used as a MFA challange. * @@ -586,7 +586,7 @@ class Account(client: Client) : Service(client) { /** - * Get MFA Recovery Codes + * Get MFA recovery codes * * Get recovery codes that can be used as backup for MFA flow. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to read recovery codes. * @@ -617,7 +617,7 @@ class Account(client: Client) : Service(client) { /** - * Create MFA Recovery Codes + * Create MFA recovery codes * * Generate recovery codes as backup for MFA flow. It's recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. * @@ -648,7 +648,7 @@ class Account(client: Client) : Service(client) { /** - * Regenerate MFA Recovery Codes + * Regenerate MFA recovery codes * * Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes. * diff --git a/library/src/main/java/io/appwrite/services/Locale.kt b/library/src/main/java/io/appwrite/services/Locale.kt index bcee309..097e1f7 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -47,7 +47,7 @@ class Locale(client: Client) : Service(client) { /** - * List Locale Codes + * List locale codes * * List of all locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). * diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index a65d5e6..c30d37c 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -189,7 +189,7 @@ class Storage(client: Client) : Service(client) { /** - * Delete File + * Delete file * * Delete a file by its unique ID. Only users with write permissions have access to delete this resource. * From fe1d18e03fea87fd481844156e3cecff9d7ff5c3 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Tue, 8 Oct 2024 16:17:10 +0100 Subject: [PATCH 087/118] feat: multipart --- library/src/main/java/io/appwrite/enums/ImageFormat.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/io/appwrite/enums/ImageFormat.kt b/library/src/main/java/io/appwrite/enums/ImageFormat.kt index c6a3b0f..25eea90 100644 --- a/library/src/main/java/io/appwrite/enums/ImageFormat.kt +++ b/library/src/main/java/io/appwrite/enums/ImageFormat.kt @@ -12,7 +12,9 @@ enum class ImageFormat(val value: String) { @SerializedName("png") PNG("png"), @SerializedName("webp") - WEBP("webp"); + WEBP("webp"), + @SerializedName("avif") + AVIF("avif"); override fun toString() = value } \ No newline at end of file From f07d83610c655e5762abbab801bc32893ec2c9c1 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 13 Dec 2024 13:10:34 +0000 Subject: [PATCH 088/118] feat: realtime heartbeat --- .../account/create-email-password-session.md | 4 +- .../java/account/create-email-token.md | 4 +- .../java/account/create-magic-u-r-l-token.md | 6 +- .../java/account/create-o-auth2session.md | 4 +- .../java/account/create-o-auth2token.md | 4 +- .../java/account/create-phone-token.md | 4 +- .../java/account/create-push-target.md | 6 +- docs/examples/java/account/create-recovery.md | 4 +- docs/examples/java/account/create-session.md | 4 +- .../java/account/create-verification.md | 2 +- docs/examples/java/account/create.md | 6 +- docs/examples/java/account/delete-identity.md | 2 +- .../java/account/delete-push-target.md | 2 +- docs/examples/java/account/delete-session.md | 2 +- docs/examples/java/account/get-session.md | 2 +- docs/examples/java/account/update-email.md | 4 +- .../account/update-magic-u-r-l-session.md | 4 +- .../java/account/update-mfa-authenticator.md | 2 +- .../java/account/update-mfa-challenge.md | 4 +- docs/examples/java/account/update-name.md | 2 +- docs/examples/java/account/update-password.md | 2 +- .../java/account/update-phone-session.md | 4 +- .../java/account/update-phone-verification.md | 4 +- docs/examples/java/account/update-phone.md | 4 +- .../java/account/update-push-target.md | 4 +- docs/examples/java/account/update-recovery.md | 4 +- docs/examples/java/account/update-session.md | 2 +- .../java/account/update-verification.md | 4 +- docs/examples/java/avatars/get-favicon.md | 2 +- docs/examples/java/avatars/get-image.md | 2 +- docs/examples/java/avatars/get-initials.md | 2 +- docs/examples/java/avatars/get-q-r.md | 2 +- .../java/databases/create-document.md | 6 +- .../java/databases/delete-document.md | 6 +- docs/examples/java/databases/get-document.md | 6 +- .../examples/java/databases/list-documents.md | 4 +- .../java/databases/update-document.md | 6 +- .../java/functions/create-execution.md | 6 +- docs/examples/java/functions/get-execution.md | 4 +- .../java/functions/list-executions.md | 4 +- .../java/messaging/create-subscriber.md | 6 +- .../java/messaging/delete-subscriber.md | 4 +- docs/examples/java/storage/create-file.md | 8 +- docs/examples/java/storage/delete-file.md | 4 +- .../java/storage/get-file-download.md | 4 +- .../examples/java/storage/get-file-preview.md | 4 +- docs/examples/java/storage/get-file-view.md | 4 +- docs/examples/java/storage/get-file.md | 4 +- docs/examples/java/storage/list-files.md | 4 +- docs/examples/java/storage/update-file.md | 6 +- docs/examples/java/teams/create-membership.md | 12 +- docs/examples/java/teams/create.md | 4 +- docs/examples/java/teams/delete-membership.md | 4 +- docs/examples/java/teams/delete.md | 2 +- docs/examples/java/teams/get-membership.md | 4 +- docs/examples/java/teams/get-prefs.md | 2 +- docs/examples/java/teams/get.md | 2 +- docs/examples/java/teams/list-memberships.md | 4 +- docs/examples/java/teams/list.md | 2 +- .../java/teams/update-membership-status.md | 8 +- docs/examples/java/teams/update-membership.md | 4 +- docs/examples/java/teams/update-name.md | 4 +- docs/examples/java/teams/update-prefs.md | 2 +- .../account/create-email-password-session.md | 4 +- .../kotlin/account/create-email-token.md | 4 +- .../account/create-magic-u-r-l-token.md | 6 +- .../kotlin/account/create-o-auth2session.md | 4 +- .../kotlin/account/create-o-auth2token.md | 4 +- .../kotlin/account/create-phone-token.md | 4 +- .../kotlin/account/create-push-target.md | 6 +- .../kotlin/account/create-recovery.md | 4 +- .../examples/kotlin/account/create-session.md | 4 +- .../kotlin/account/create-verification.md | 2 +- docs/examples/kotlin/account/create.md | 6 +- .../kotlin/account/delete-identity.md | 2 +- .../kotlin/account/delete-push-target.md | 2 +- .../examples/kotlin/account/delete-session.md | 2 +- docs/examples/kotlin/account/get-session.md | 2 +- docs/examples/kotlin/account/update-email.md | 4 +- .../account/update-magic-u-r-l-session.md | 4 +- .../account/update-mfa-authenticator.md | 2 +- .../kotlin/account/update-mfa-challenge.md | 4 +- docs/examples/kotlin/account/update-name.md | 2 +- .../kotlin/account/update-password.md | 2 +- .../kotlin/account/update-phone-session.md | 4 +- .../account/update-phone-verification.md | 4 +- docs/examples/kotlin/account/update-phone.md | 4 +- .../kotlin/account/update-push-target.md | 4 +- .../kotlin/account/update-recovery.md | 4 +- .../examples/kotlin/account/update-session.md | 2 +- .../kotlin/account/update-verification.md | 4 +- docs/examples/kotlin/avatars/get-favicon.md | 2 +- docs/examples/kotlin/avatars/get-image.md | 2 +- docs/examples/kotlin/avatars/get-initials.md | 2 +- docs/examples/kotlin/avatars/get-q-r.md | 2 +- .../kotlin/databases/create-document.md | 6 +- .../kotlin/databases/delete-document.md | 6 +- .../examples/kotlin/databases/get-document.md | 6 +- .../kotlin/databases/list-documents.md | 4 +- .../kotlin/databases/update-document.md | 6 +- .../kotlin/functions/create-execution.md | 6 +- .../kotlin/functions/get-execution.md | 4 +- .../kotlin/functions/list-executions.md | 4 +- .../kotlin/messaging/create-subscriber.md | 6 +- .../kotlin/messaging/delete-subscriber.md | 4 +- docs/examples/kotlin/storage/create-file.md | 8 +- docs/examples/kotlin/storage/delete-file.md | 4 +- .../kotlin/storage/get-file-download.md | 4 +- .../kotlin/storage/get-file-preview.md | 4 +- docs/examples/kotlin/storage/get-file-view.md | 4 +- docs/examples/kotlin/storage/get-file.md | 4 +- docs/examples/kotlin/storage/list-files.md | 4 +- docs/examples/kotlin/storage/update-file.md | 6 +- .../kotlin/teams/create-membership.md | 12 +- docs/examples/kotlin/teams/create.md | 4 +- .../kotlin/teams/delete-membership.md | 4 +- docs/examples/kotlin/teams/delete.md | 2 +- docs/examples/kotlin/teams/get-membership.md | 4 +- docs/examples/kotlin/teams/get-prefs.md | 2 +- docs/examples/kotlin/teams/get.md | 2 +- .../examples/kotlin/teams/list-memberships.md | 4 +- docs/examples/kotlin/teams/list.md | 2 +- .../kotlin/teams/update-membership-status.md | 8 +- .../kotlin/teams/update-membership.md | 4 +- docs/examples/kotlin/teams/update-name.md | 4 +- docs/examples/kotlin/teams/update-prefs.md | 2 +- .../android/ui/accounts/AccountsViewModel.kt | 4 +- library/src/main/java/io/appwrite/Client.kt | 63 +-- .../io/appwrite/extensions/TypeExtensions.kt | 101 +--- .../main/java/io/appwrite/models/Document.kt | 6 +- .../main/java/io/appwrite/models/Execution.kt | 8 +- .../src/main/java/io/appwrite/models/File.kt | 4 +- .../main/java/io/appwrite/models/InputFile.kt | 37 ++ .../java/io/appwrite/models/Membership.kt | 4 +- .../io/appwrite/models/MfaRecoveryCodes.kt | 4 +- .../main/java/io/appwrite/models/Payload.kt | 73 --- .../main/java/io/appwrite/models/Session.kt | 4 +- .../src/main/java/io/appwrite/models/User.kt | 6 +- .../main/java/io/appwrite/services/Account.kt | 436 +++++++++--------- .../main/java/io/appwrite/services/Avatars.kt | 58 +-- .../java/io/appwrite/services/Databases.kt | 62 +-- .../java/io/appwrite/services/Functions.kt | 41 +- .../main/java/io/appwrite/services/Graphql.kt | 18 +- .../main/java/io/appwrite/services/Locale.kt | 50 +- .../java/io/appwrite/services/Messaging.kt | 18 +- .../java/io/appwrite/services/Realtime.kt | 22 + .../main/java/io/appwrite/services/Storage.kt | 76 +-- .../main/java/io/appwrite/services/Teams.kt | 142 +++--- 148 files changed, 807 insertions(+), 934 deletions(-) create mode 100644 library/src/main/java/io/appwrite/models/InputFile.kt delete mode 100644 library/src/main/java/io/appwrite/models/Payload.kt diff --git a/docs/examples/java/account/create-email-password-session.md b/docs/examples/java/account/create-email-password-session.md index 112fb20..817bda0 100644 --- a/docs/examples/java/account/create-email-password-session.md +++ b/docs/examples/java/account/create-email-password-session.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.createEmailPasswordSession( - "{$example}", // email - "{$example}", // password + "email@example.com", // email + "password", // password new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/create-email-token.md b/docs/examples/java/account/create-email-token.md index 3fafb5e..a4bc83b 100644 --- a/docs/examples/java/account/create-email-token.md +++ b/docs/examples/java/account/create-email-token.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.createEmailToken( - "{$example}", // userId - "{$example}", // email + "", // userId + "email@example.com", // email false, // phrase (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/account/create-magic-u-r-l-token.md b/docs/examples/java/account/create-magic-u-r-l-token.md index e84b213..e57758a 100644 --- a/docs/examples/java/account/create-magic-u-r-l-token.md +++ b/docs/examples/java/account/create-magic-u-r-l-token.md @@ -9,9 +9,9 @@ Client client = new Client(context) Account account = new Account(client); account.createMagicURLToken( - "{$example}", // userId - "{$example}", // email - "{$example}", // url (optional) + "", // userId + "email@example.com", // email + "https://example.com", // url (optional) false, // phrase (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/account/create-o-auth2session.md b/docs/examples/java/account/create-o-auth2session.md index 591f85e..59f5b41 100644 --- a/docs/examples/java/account/create-o-auth2session.md +++ b/docs/examples/java/account/create-o-auth2session.md @@ -11,8 +11,8 @@ Account account = new Account(client); account.createOAuth2Session( OAuthProvider.AMAZON, // provider - "{$example}", // success (optional) - "{$example}", // failure (optional) + "https://example.com", // success (optional) + "https://example.com", // failure (optional) listOf(), // scopes (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/account/create-o-auth2token.md b/docs/examples/java/account/create-o-auth2token.md index 0866fef..6103196 100644 --- a/docs/examples/java/account/create-o-auth2token.md +++ b/docs/examples/java/account/create-o-auth2token.md @@ -11,8 +11,8 @@ Account account = new Account(client); account.createOAuth2Token( OAuthProvider.AMAZON, // provider - "{$example}", // success (optional) - "{$example}", // failure (optional) + "https://example.com", // success (optional) + "https://example.com", // failure (optional) listOf(), // scopes (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/account/create-phone-token.md b/docs/examples/java/account/create-phone-token.md index ef60cfa..a1ad85b 100644 --- a/docs/examples/java/account/create-phone-token.md +++ b/docs/examples/java/account/create-phone-token.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.createPhoneToken( - "{$example}", // userId - "{$example}", // phone + "", // userId + "+12065550100", // phone new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/create-push-target.md b/docs/examples/java/account/create-push-target.md index a0dc5a8..34e8fcb 100644 --- a/docs/examples/java/account/create-push-target.md +++ b/docs/examples/java/account/create-push-target.md @@ -9,9 +9,9 @@ Client client = new Client(context) Account account = new Account(client); account.createPushTarget( - "{$example}", // targetId - "{$example}", // identifier - "{$example}", // providerId (optional) + "", // targetId + "", // identifier + "", // providerId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/create-recovery.md b/docs/examples/java/account/create-recovery.md index 7fba792..4d2af8b 100644 --- a/docs/examples/java/account/create-recovery.md +++ b/docs/examples/java/account/create-recovery.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.createRecovery( - "{$example}", // email - "{$example}", // url + "email@example.com", // email + "https://example.com", // url new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/create-session.md b/docs/examples/java/account/create-session.md index ff3391f..71d11a5 100644 --- a/docs/examples/java/account/create-session.md +++ b/docs/examples/java/account/create-session.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.createSession( - "{$example}", // userId - "{$example}", // secret + "", // userId + "", // secret new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/create-verification.md b/docs/examples/java/account/create-verification.md index 74e5b3d..be4f7c9 100644 --- a/docs/examples/java/account/create-verification.md +++ b/docs/examples/java/account/create-verification.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.createVerification( - "{$example}", // url + "https://example.com", // url new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/create.md b/docs/examples/java/account/create.md index d23bcac..e721248 100644 --- a/docs/examples/java/account/create.md +++ b/docs/examples/java/account/create.md @@ -9,10 +9,10 @@ Client client = new Client(context) Account account = new Account(client); account.create( - "{$example}", // userId - "{$example}", // email + "", // userId + "email@example.com", // email "", // password - "{$example}", // name (optional) + "", // name (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/delete-identity.md b/docs/examples/java/account/delete-identity.md index d72c1e6..6a62ea2 100644 --- a/docs/examples/java/account/delete-identity.md +++ b/docs/examples/java/account/delete-identity.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.deleteIdentity( - "{$example}", // identityId + "", // identityId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/delete-push-target.md b/docs/examples/java/account/delete-push-target.md index 366a473..c320800 100644 --- a/docs/examples/java/account/delete-push-target.md +++ b/docs/examples/java/account/delete-push-target.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.deletePushTarget( - "{$example}", // targetId + "", // targetId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/delete-session.md b/docs/examples/java/account/delete-session.md index cb152f4..2efc0f6 100644 --- a/docs/examples/java/account/delete-session.md +++ b/docs/examples/java/account/delete-session.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.deleteSession( - "{$example}", // sessionId + "", // sessionId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/get-session.md b/docs/examples/java/account/get-session.md index 627026d..3ce4ab5 100644 --- a/docs/examples/java/account/get-session.md +++ b/docs/examples/java/account/get-session.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.getSession( - "{$example}", // sessionId + "", // sessionId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-email.md b/docs/examples/java/account/update-email.md index 37894f7..98cf907 100644 --- a/docs/examples/java/account/update-email.md +++ b/docs/examples/java/account/update-email.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.updateEmail( - "{$example}", // email - "{$example}", // password + "email@example.com", // email + "password", // password new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); 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 4f09fb3..1b79b73 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 @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.updateMagicURLSession( - "{$example}", // userId - "{$example}", // secret + "", // userId + "", // secret new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-mfa-authenticator.md b/docs/examples/java/account/update-mfa-authenticator.md index 9b3c3f6..74321be 100644 --- a/docs/examples/java/account/update-mfa-authenticator.md +++ b/docs/examples/java/account/update-mfa-authenticator.md @@ -11,7 +11,7 @@ Account account = new Account(client); account.updateMfaAuthenticator( AuthenticatorType.TOTP, // type - "{$example}", // otp + "", // otp new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-mfa-challenge.md b/docs/examples/java/account/update-mfa-challenge.md index c898904..a92f007 100644 --- a/docs/examples/java/account/update-mfa-challenge.md +++ b/docs/examples/java/account/update-mfa-challenge.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.updateMfaChallenge( - "{$example}", // challengeId - "{$example}", // otp + "", // challengeId + "", // otp new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-name.md b/docs/examples/java/account/update-name.md index cd00362..40a5e2e 100644 --- a/docs/examples/java/account/update-name.md +++ b/docs/examples/java/account/update-name.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.updateName( - "{$example}", // name + "", // name new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-password.md b/docs/examples/java/account/update-password.md index a8b9be7..355c06d 100644 --- a/docs/examples/java/account/update-password.md +++ b/docs/examples/java/account/update-password.md @@ -10,7 +10,7 @@ Account account = new Account(client); account.updatePassword( "", // password - "{$example}", // oldPassword (optional) + "password", // oldPassword (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-phone-session.md b/docs/examples/java/account/update-phone-session.md index 9166d36..042238e 100644 --- a/docs/examples/java/account/update-phone-session.md +++ b/docs/examples/java/account/update-phone-session.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.updatePhoneSession( - "{$example}", // userId - "{$example}", // secret + "", // userId + "", // secret new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-phone-verification.md b/docs/examples/java/account/update-phone-verification.md index eb50644..ba7b69c 100644 --- a/docs/examples/java/account/update-phone-verification.md +++ b/docs/examples/java/account/update-phone-verification.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.updatePhoneVerification( - "{$example}", // userId - "{$example}", // secret + "", // userId + "", // secret new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-phone.md b/docs/examples/java/account/update-phone.md index 1e7a1bc..b3ce0f6 100644 --- a/docs/examples/java/account/update-phone.md +++ b/docs/examples/java/account/update-phone.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.updatePhone( - "{$example}", // phone - "{$example}", // password + "+12065550100", // phone + "password", // password new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-push-target.md b/docs/examples/java/account/update-push-target.md index 15f9b0a..f9491e0 100644 --- a/docs/examples/java/account/update-push-target.md +++ b/docs/examples/java/account/update-push-target.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.updatePushTarget( - "{$example}", // targetId - "{$example}", // identifier + "", // targetId + "", // identifier new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-recovery.md b/docs/examples/java/account/update-recovery.md index 9ec90c3..e172f12 100644 --- a/docs/examples/java/account/update-recovery.md +++ b/docs/examples/java/account/update-recovery.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.updateRecovery( - "{$example}", // userId - "{$example}", // secret + "", // userId + "", // secret "", // password new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/account/update-session.md b/docs/examples/java/account/update-session.md index d6093d9..b3e8706 100644 --- a/docs/examples/java/account/update-session.md +++ b/docs/examples/java/account/update-session.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); account.updateSession( - "{$example}", // sessionId + "", // sessionId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-verification.md b/docs/examples/java/account/update-verification.md index ebced41..2594943 100644 --- a/docs/examples/java/account/update-verification.md +++ b/docs/examples/java/account/update-verification.md @@ -9,8 +9,8 @@ Client client = new Client(context) Account account = new Account(client); account.updateVerification( - "{$example}", // userId - "{$example}", // secret + "", // userId + "", // secret new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/avatars/get-favicon.md b/docs/examples/java/avatars/get-favicon.md index ac8e6e6..05bf590 100644 --- a/docs/examples/java/avatars/get-favicon.md +++ b/docs/examples/java/avatars/get-favicon.md @@ -9,7 +9,7 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); avatars.getFavicon( - "{$example}", // url + "https://example.com", // url new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/avatars/get-image.md b/docs/examples/java/avatars/get-image.md index 85eacb1..78fbf98 100644 --- a/docs/examples/java/avatars/get-image.md +++ b/docs/examples/java/avatars/get-image.md @@ -9,7 +9,7 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); avatars.getImage( - "{$example}", // url + "https://example.com", // url 0, // width (optional) 0, // height (optional) new CoroutineCallback<>((result, error) -> { diff --git a/docs/examples/java/avatars/get-initials.md b/docs/examples/java/avatars/get-initials.md index d687c7b..621798b 100644 --- a/docs/examples/java/avatars/get-initials.md +++ b/docs/examples/java/avatars/get-initials.md @@ -9,7 +9,7 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); avatars.getInitials( - "{$example}", // name (optional) + "", // name (optional) 0, // width (optional) 0, // height (optional) "", // background (optional) diff --git a/docs/examples/java/avatars/get-q-r.md b/docs/examples/java/avatars/get-q-r.md index 05a5e8d..fc8bc43 100644 --- a/docs/examples/java/avatars/get-q-r.md +++ b/docs/examples/java/avatars/get-q-r.md @@ -9,7 +9,7 @@ Client client = new Client(context) Avatars avatars = new Avatars(client); avatars.getQR( - "{$example}", // text + "", // text 1, // size (optional) 0, // margin (optional) false, // download (optional) diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index fc0465f..6c7e068 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -9,9 +9,9 @@ Client client = new Client(context) Databases databases = new Databases(client); databases.createDocument( - "{$example}", // databaseId - "{$example}", // collectionId - "{$example}", // documentId + "", // databaseId + "", // collectionId + "", // documentId mapOf( "a" to "b" ), // data listOf("read("any")"), // permissions (optional) new CoroutineCallback<>((result, error) -> { diff --git a/docs/examples/java/databases/delete-document.md b/docs/examples/java/databases/delete-document.md index 50bd674..0cbd6b5 100644 --- a/docs/examples/java/databases/delete-document.md +++ b/docs/examples/java/databases/delete-document.md @@ -9,9 +9,9 @@ Client client = new Client(context) Databases databases = new Databases(client); databases.deleteDocument( - "{$example}", // databaseId - "{$example}", // collectionId - "{$example}", // documentId + "", // databaseId + "", // collectionId + "", // documentId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/get-document.md b/docs/examples/java/databases/get-document.md index cbcca6e..0918c88 100644 --- a/docs/examples/java/databases/get-document.md +++ b/docs/examples/java/databases/get-document.md @@ -9,9 +9,9 @@ Client client = new Client(context) Databases databases = new Databases(client); databases.getDocument( - "{$example}", // databaseId - "{$example}", // collectionId - "{$example}", // documentId + "", // databaseId + "", // collectionId + "", // documentId listOf(), // queries (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/databases/list-documents.md b/docs/examples/java/databases/list-documents.md index a63e929..9cc722b 100644 --- a/docs/examples/java/databases/list-documents.md +++ b/docs/examples/java/databases/list-documents.md @@ -9,8 +9,8 @@ Client client = new Client(context) Databases databases = new Databases(client); databases.listDocuments( - "{$example}", // databaseId - "{$example}", // collectionId + "", // databaseId + "", // collectionId listOf(), // queries (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/databases/update-document.md b/docs/examples/java/databases/update-document.md index 3831c2d..ccfb498 100644 --- a/docs/examples/java/databases/update-document.md +++ b/docs/examples/java/databases/update-document.md @@ -9,9 +9,9 @@ Client client = new Client(context) Databases databases = new Databases(client); databases.updateDocument( - "{$example}", // databaseId - "{$example}", // collectionId - "{$example}", // documentId + "", // databaseId + "", // collectionId + "", // documentId mapOf( "a" to "b" ), // data (optional) listOf("read("any")"), // permissions (optional) new CoroutineCallback<>((result, error) -> { diff --git a/docs/examples/java/functions/create-execution.md b/docs/examples/java/functions/create-execution.md index 89bf4c1..845f02e 100644 --- a/docs/examples/java/functions/create-execution.md +++ b/docs/examples/java/functions/create-execution.md @@ -9,10 +9,10 @@ Client client = new Client(context) Functions functions = new Functions(client); functions.createExecution( - "{$example}", // functionId - Payload.fromJson(mapOf("x" to "y" as Any)), // body (optional) + "", // functionId + "", // body (optional) false, // async (optional) - "{$example}", // path (optional) + "", // path (optional) ExecutionMethod.GET, // method (optional) mapOf( "a" to "b" ), // headers (optional) "", // scheduledAt (optional) diff --git a/docs/examples/java/functions/get-execution.md b/docs/examples/java/functions/get-execution.md index feabf8f..c53ef0e 100644 --- a/docs/examples/java/functions/get-execution.md +++ b/docs/examples/java/functions/get-execution.md @@ -9,8 +9,8 @@ Client client = new Client(context) Functions functions = new Functions(client); functions.getExecution( - "{$example}", // functionId - "{$example}", // executionId + "", // functionId + "", // executionId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/functions/list-executions.md b/docs/examples/java/functions/list-executions.md index 1efd982..b796dc9 100644 --- a/docs/examples/java/functions/list-executions.md +++ b/docs/examples/java/functions/list-executions.md @@ -9,9 +9,9 @@ Client client = new Client(context) Functions functions = new Functions(client); functions.listExecutions( - "{$example}", // functionId + "", // functionId listOf(), // queries (optional) - "{$example}", // search (optional) + "", // search (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/messaging/create-subscriber.md b/docs/examples/java/messaging/create-subscriber.md index 1ce5d6d..e8fa79f 100644 --- a/docs/examples/java/messaging/create-subscriber.md +++ b/docs/examples/java/messaging/create-subscriber.md @@ -9,9 +9,9 @@ Client client = new Client(context) Messaging messaging = new Messaging(client); messaging.createSubscriber( - "{$example}", // topicId - "{$example}", // subscriberId - "{$example}", // targetId + "", // topicId + "", // subscriberId + "", // targetId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/messaging/delete-subscriber.md b/docs/examples/java/messaging/delete-subscriber.md index 07fbd2f..7e5b3d2 100644 --- a/docs/examples/java/messaging/delete-subscriber.md +++ b/docs/examples/java/messaging/delete-subscriber.md @@ -9,8 +9,8 @@ Client client = new Client(context) Messaging messaging = new Messaging(client); messaging.deleteSubscriber( - "{$example}", // topicId - "{$example}", // subscriberId + "", // topicId + "", // subscriberId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/create-file.md b/docs/examples/java/storage/create-file.md index 6da1bf5..bc9ebed 100644 --- a/docs/examples/java/storage/create-file.md +++ b/docs/examples/java/storage/create-file.md @@ -1,6 +1,6 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.models.Payload; +import io.appwrite.models.InputFile; import io.appwrite.services.Storage; Client client = new Client(context) @@ -10,9 +10,9 @@ Client client = new Client(context) Storage storage = new Storage(client); storage.createFile( - "{$example}", // bucketId - "{$example}", // fileId - Payload.fromFile("/path/to/file.png"), // file + "", // bucketId + "", // fileId + InputFile.fromPath("file.png"), // file listOf("read("any")"), // permissions (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/storage/delete-file.md b/docs/examples/java/storage/delete-file.md index 1defa04..eaeb47b 100644 --- a/docs/examples/java/storage/delete-file.md +++ b/docs/examples/java/storage/delete-file.md @@ -9,8 +9,8 @@ Client client = new Client(context) Storage storage = new Storage(client); storage.deleteFile( - "{$example}", // bucketId - "{$example}", // fileId + "", // bucketId + "", // fileId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/get-file-download.md b/docs/examples/java/storage/get-file-download.md index 611b5c7..d0fdc41 100644 --- a/docs/examples/java/storage/get-file-download.md +++ b/docs/examples/java/storage/get-file-download.md @@ -9,8 +9,8 @@ Client client = new Client(context) Storage storage = new Storage(client); storage.getFileDownload( - "{$example}", // bucketId - "{$example}", // fileId + "", // bucketId + "", // fileId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/get-file-preview.md b/docs/examples/java/storage/get-file-preview.md index c29be40..c935e6f 100644 --- a/docs/examples/java/storage/get-file-preview.md +++ b/docs/examples/java/storage/get-file-preview.md @@ -9,8 +9,8 @@ Client client = new Client(context) Storage storage = new Storage(client); storage.getFilePreview( - "{$example}", // bucketId - "{$example}", // fileId + "", // bucketId + "", // fileId 0, // width (optional) 0, // height (optional) ImageGravity.CENTER, // gravity (optional) diff --git a/docs/examples/java/storage/get-file-view.md b/docs/examples/java/storage/get-file-view.md index 5cac2ce..bbfd04d 100644 --- a/docs/examples/java/storage/get-file-view.md +++ b/docs/examples/java/storage/get-file-view.md @@ -9,8 +9,8 @@ Client client = new Client(context) Storage storage = new Storage(client); storage.getFileView( - "{$example}", // bucketId - "{$example}", // fileId + "", // bucketId + "", // fileId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/get-file.md b/docs/examples/java/storage/get-file.md index 54dd453..a63122f 100644 --- a/docs/examples/java/storage/get-file.md +++ b/docs/examples/java/storage/get-file.md @@ -9,8 +9,8 @@ Client client = new Client(context) Storage storage = new Storage(client); storage.getFile( - "{$example}", // bucketId - "{$example}", // fileId + "", // bucketId + "", // fileId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/list-files.md b/docs/examples/java/storage/list-files.md index 56ec1a8..dc327fc 100644 --- a/docs/examples/java/storage/list-files.md +++ b/docs/examples/java/storage/list-files.md @@ -9,9 +9,9 @@ Client client = new Client(context) Storage storage = new Storage(client); storage.listFiles( - "{$example}", // bucketId + "", // bucketId listOf(), // queries (optional) - "{$example}", // search (optional) + "", // search (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/update-file.md b/docs/examples/java/storage/update-file.md index 563a413..ed81821 100644 --- a/docs/examples/java/storage/update-file.md +++ b/docs/examples/java/storage/update-file.md @@ -9,9 +9,9 @@ Client client = new Client(context) Storage storage = new Storage(client); storage.updateFile( - "{$example}", // bucketId - "{$example}", // fileId - "{$example}", // name (optional) + "", // bucketId + "", // fileId + "", // name (optional) listOf("read("any")"), // permissions (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/teams/create-membership.md b/docs/examples/java/teams/create-membership.md index 60461af..b30f176 100644 --- a/docs/examples/java/teams/create-membership.md +++ b/docs/examples/java/teams/create-membership.md @@ -9,13 +9,13 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.createMembership( - "{$example}", // teamId + "", // teamId listOf(), // roles - "{$example}", // email (optional) - "{$example}", // userId (optional) - "{$example}", // phone (optional) - "{$example}", // url (optional) - "{$example}", // name (optional) + "email@example.com", // email (optional) + "", // userId (optional) + "+12065550100", // phone (optional) + "https://example.com", // url (optional) + "", // name (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/create.md b/docs/examples/java/teams/create.md index 00f691b..a0d4f07 100644 --- a/docs/examples/java/teams/create.md +++ b/docs/examples/java/teams/create.md @@ -9,8 +9,8 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.create( - "{$example}", // teamId - "{$example}", // name + "", // teamId + "", // name listOf(), // roles (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/teams/delete-membership.md b/docs/examples/java/teams/delete-membership.md index bf6c877..7f9189f 100644 --- a/docs/examples/java/teams/delete-membership.md +++ b/docs/examples/java/teams/delete-membership.md @@ -9,8 +9,8 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.deleteMembership( - "{$example}", // teamId - "{$example}", // membershipId + "", // teamId + "", // membershipId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/delete.md b/docs/examples/java/teams/delete.md index aa8bfac..2f4e861 100644 --- a/docs/examples/java/teams/delete.md +++ b/docs/examples/java/teams/delete.md @@ -9,7 +9,7 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.delete( - "{$example}", // teamId + "", // teamId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/get-membership.md b/docs/examples/java/teams/get-membership.md index 6da129e..529feb2 100644 --- a/docs/examples/java/teams/get-membership.md +++ b/docs/examples/java/teams/get-membership.md @@ -9,8 +9,8 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.getMembership( - "{$example}", // teamId - "{$example}", // membershipId + "", // teamId + "", // membershipId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/get-prefs.md b/docs/examples/java/teams/get-prefs.md index 81f344b..61da757 100644 --- a/docs/examples/java/teams/get-prefs.md +++ b/docs/examples/java/teams/get-prefs.md @@ -9,7 +9,7 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.getPrefs( - "{$example}", // teamId + "", // teamId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/get.md b/docs/examples/java/teams/get.md index c53aeba..39fe4d4 100644 --- a/docs/examples/java/teams/get.md +++ b/docs/examples/java/teams/get.md @@ -9,7 +9,7 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.get( - "{$example}", // teamId + "", // teamId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/list-memberships.md b/docs/examples/java/teams/list-memberships.md index 137ee2a..58430f0 100644 --- a/docs/examples/java/teams/list-memberships.md +++ b/docs/examples/java/teams/list-memberships.md @@ -9,9 +9,9 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.listMemberships( - "{$example}", // teamId + "", // teamId listOf(), // queries (optional) - "{$example}", // search (optional) + "", // search (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/list.md b/docs/examples/java/teams/list.md index e918ac8..914509f 100644 --- a/docs/examples/java/teams/list.md +++ b/docs/examples/java/teams/list.md @@ -10,7 +10,7 @@ Teams teams = new Teams(client); teams.list( listOf(), // queries (optional) - "{$example}", // search (optional) + "", // search (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/update-membership-status.md b/docs/examples/java/teams/update-membership-status.md index 80bfe17..5134613 100644 --- a/docs/examples/java/teams/update-membership-status.md +++ b/docs/examples/java/teams/update-membership-status.md @@ -9,10 +9,10 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.updateMembershipStatus( - "{$example}", // teamId - "{$example}", // membershipId - "{$example}", // userId - "{$example}", // secret + "", // teamId + "", // membershipId + "", // userId + "", // secret new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/update-membership.md b/docs/examples/java/teams/update-membership.md index 69c99b6..a60c2a0 100644 --- a/docs/examples/java/teams/update-membership.md +++ b/docs/examples/java/teams/update-membership.md @@ -9,8 +9,8 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.updateMembership( - "{$example}", // teamId - "{$example}", // membershipId + "", // teamId + "", // membershipId listOf(), // roles new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/teams/update-name.md b/docs/examples/java/teams/update-name.md index 7d9d96d..54f218e 100644 --- a/docs/examples/java/teams/update-name.md +++ b/docs/examples/java/teams/update-name.md @@ -9,8 +9,8 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.updateName( - "{$example}", // teamId - "{$example}", // name + "", // teamId + "", // name new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/teams/update-prefs.md b/docs/examples/java/teams/update-prefs.md index 334fd6d..eaa161e 100644 --- a/docs/examples/java/teams/update-prefs.md +++ b/docs/examples/java/teams/update-prefs.md @@ -9,7 +9,7 @@ Client client = new Client(context) Teams teams = new Teams(client); teams.updatePrefs( - "{$example}", // teamId + "", // teamId mapOf( "a" to "b" ), // prefs new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/kotlin/account/create-email-password-session.md b/docs/examples/kotlin/account/create-email-password-session.md index 6b69b3a..8c44759 100644 --- a/docs/examples/kotlin/account/create-email-password-session.md +++ b/docs/examples/kotlin/account/create-email-password-session.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val result = account.createEmailPasswordSession( - email = "{$example}", - password = "{$example}", + email = "email@example.com", + password = "password", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-email-token.md b/docs/examples/kotlin/account/create-email-token.md index 46e6926..219e793 100644 --- a/docs/examples/kotlin/account/create-email-token.md +++ b/docs/examples/kotlin/account/create-email-token.md @@ -9,7 +9,7 @@ val client = Client(context) val account = Account(client) val result = account.createEmailToken( - userId = "{$example}", - email = "{$example}", + userId = "", + email = "email@example.com", phrase = false, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-magic-u-r-l-token.md b/docs/examples/kotlin/account/create-magic-u-r-l-token.md index 9851dab..905e942 100644 --- a/docs/examples/kotlin/account/create-magic-u-r-l-token.md +++ b/docs/examples/kotlin/account/create-magic-u-r-l-token.md @@ -9,8 +9,8 @@ val client = Client(context) val account = Account(client) val result = account.createMagicURLToken( - userId = "{$example}", - email = "{$example}", - url = "{$example}", // (optional) + userId = "", + email = "email@example.com", + url = "https://example.com", // (optional) phrase = false, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-o-auth2session.md b/docs/examples/kotlin/account/create-o-auth2session.md index 7f63375..fc9d822 100644 --- a/docs/examples/kotlin/account/create-o-auth2session.md +++ b/docs/examples/kotlin/account/create-o-auth2session.md @@ -11,7 +11,7 @@ val account = Account(client) account.createOAuth2Session( provider = OAuthProvider.AMAZON, - success = "{$example}", // (optional) - failure = "{$example}", // (optional) + success = "https://example.com", // (optional) + failure = "https://example.com", // (optional) scopes = listOf(), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-o-auth2token.md b/docs/examples/kotlin/account/create-o-auth2token.md index 7607380..11a814b 100644 --- a/docs/examples/kotlin/account/create-o-auth2token.md +++ b/docs/examples/kotlin/account/create-o-auth2token.md @@ -11,7 +11,7 @@ val account = Account(client) account.createOAuth2Token( provider = OAuthProvider.AMAZON, - success = "{$example}", // (optional) - failure = "{$example}", // (optional) + success = "https://example.com", // (optional) + failure = "https://example.com", // (optional) scopes = listOf(), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-phone-token.md b/docs/examples/kotlin/account/create-phone-token.md index acea79b..56b53c2 100644 --- a/docs/examples/kotlin/account/create-phone-token.md +++ b/docs/examples/kotlin/account/create-phone-token.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val result = account.createPhoneToken( - userId = "{$example}", - phone = "{$example}", + userId = "", + phone = "+12065550100", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-push-target.md b/docs/examples/kotlin/account/create-push-target.md index df6d9fe..7dd2101 100644 --- a/docs/examples/kotlin/account/create-push-target.md +++ b/docs/examples/kotlin/account/create-push-target.md @@ -9,7 +9,7 @@ val client = Client(context) val account = Account(client) val result = account.createPushTarget( - targetId = "{$example}", - identifier = "{$example}", - providerId = "{$example}", // (optional) + targetId = "", + identifier = "", + providerId = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-recovery.md b/docs/examples/kotlin/account/create-recovery.md index 13e8fbc..d03bd32 100644 --- a/docs/examples/kotlin/account/create-recovery.md +++ b/docs/examples/kotlin/account/create-recovery.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val result = account.createRecovery( - email = "{$example}", - url = "{$example}", + email = "email@example.com", + url = "https://example.com", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-session.md b/docs/examples/kotlin/account/create-session.md index 000ddb8..2b3da6d 100644 --- a/docs/examples/kotlin/account/create-session.md +++ b/docs/examples/kotlin/account/create-session.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val result = account.createSession( - userId = "{$example}", - secret = "{$example}", + userId = "", + secret = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-verification.md b/docs/examples/kotlin/account/create-verification.md index e0a6b38..54174be 100644 --- a/docs/examples/kotlin/account/create-verification.md +++ b/docs/examples/kotlin/account/create-verification.md @@ -9,5 +9,5 @@ val client = Client(context) val account = Account(client) val result = account.createVerification( - url = "{$example}", + url = "https://example.com", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create.md b/docs/examples/kotlin/account/create.md index 38fbca9..2ee3ae4 100644 --- a/docs/examples/kotlin/account/create.md +++ b/docs/examples/kotlin/account/create.md @@ -9,8 +9,8 @@ val client = Client(context) val account = Account(client) val result = account.create( - userId = "{$example}", - email = "{$example}", + userId = "", + email = "email@example.com", password = "", - name = "{$example}", // (optional) + name = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-identity.md b/docs/examples/kotlin/account/delete-identity.md index 78bdc8d..1e5d206 100644 --- a/docs/examples/kotlin/account/delete-identity.md +++ b/docs/examples/kotlin/account/delete-identity.md @@ -9,5 +9,5 @@ val client = Client(context) val account = Account(client) val result = account.deleteIdentity( - identityId = "{$example}", + identityId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-push-target.md b/docs/examples/kotlin/account/delete-push-target.md index 257bd3e..e67b180 100644 --- a/docs/examples/kotlin/account/delete-push-target.md +++ b/docs/examples/kotlin/account/delete-push-target.md @@ -9,5 +9,5 @@ val client = Client(context) val account = Account(client) val result = account.deletePushTarget( - targetId = "{$example}", + targetId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-session.md b/docs/examples/kotlin/account/delete-session.md index 53db6d4..0990989 100644 --- a/docs/examples/kotlin/account/delete-session.md +++ b/docs/examples/kotlin/account/delete-session.md @@ -9,5 +9,5 @@ val client = Client(context) val account = Account(client) val result = account.deleteSession( - sessionId = "{$example}", + sessionId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/get-session.md b/docs/examples/kotlin/account/get-session.md index bb39027..42e61fd 100644 --- a/docs/examples/kotlin/account/get-session.md +++ b/docs/examples/kotlin/account/get-session.md @@ -9,5 +9,5 @@ val client = Client(context) val account = Account(client) val result = account.getSession( - sessionId = "{$example}", + sessionId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-email.md b/docs/examples/kotlin/account/update-email.md index b2d749a..072d6db 100644 --- a/docs/examples/kotlin/account/update-email.md +++ b/docs/examples/kotlin/account/update-email.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val result = account.updateEmail( - email = "{$example}", - password = "{$example}", + email = "email@example.com", + password = "password", ) \ No newline at end of file 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 d4f2043..52d0ad7 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 @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val result = account.updateMagicURLSession( - userId = "{$example}", - secret = "{$example}", + userId = "", + secret = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-mfa-authenticator.md b/docs/examples/kotlin/account/update-mfa-authenticator.md index 3959917..321f25b 100644 --- a/docs/examples/kotlin/account/update-mfa-authenticator.md +++ b/docs/examples/kotlin/account/update-mfa-authenticator.md @@ -11,5 +11,5 @@ val account = Account(client) val result = account.updateMfaAuthenticator( type = AuthenticatorType.TOTP, - otp = "{$example}", + otp = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-mfa-challenge.md b/docs/examples/kotlin/account/update-mfa-challenge.md index 40fa58e..021f515 100644 --- a/docs/examples/kotlin/account/update-mfa-challenge.md +++ b/docs/examples/kotlin/account/update-mfa-challenge.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val result = account.updateMfaChallenge( - challengeId = "{$example}", - otp = "{$example}", + challengeId = "", + otp = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-name.md b/docs/examples/kotlin/account/update-name.md index 0a52615..374f84f 100644 --- a/docs/examples/kotlin/account/update-name.md +++ b/docs/examples/kotlin/account/update-name.md @@ -9,5 +9,5 @@ val client = Client(context) val account = Account(client) val result = account.updateName( - name = "{$example}", + name = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-password.md b/docs/examples/kotlin/account/update-password.md index 75c57f4..edf5117 100644 --- a/docs/examples/kotlin/account/update-password.md +++ b/docs/examples/kotlin/account/update-password.md @@ -10,5 +10,5 @@ val account = Account(client) val result = account.updatePassword( password = "", - oldPassword = "{$example}", // (optional) + oldPassword = "password", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-phone-session.md b/docs/examples/kotlin/account/update-phone-session.md index 31ccdef..93e080d 100644 --- a/docs/examples/kotlin/account/update-phone-session.md +++ b/docs/examples/kotlin/account/update-phone-session.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val result = account.updatePhoneSession( - userId = "{$example}", - secret = "{$example}", + userId = "", + secret = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-phone-verification.md b/docs/examples/kotlin/account/update-phone-verification.md index 9636ecd..226b21d 100644 --- a/docs/examples/kotlin/account/update-phone-verification.md +++ b/docs/examples/kotlin/account/update-phone-verification.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val result = account.updatePhoneVerification( - userId = "{$example}", - secret = "{$example}", + userId = "", + secret = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-phone.md b/docs/examples/kotlin/account/update-phone.md index 3f882b2..772c099 100644 --- a/docs/examples/kotlin/account/update-phone.md +++ b/docs/examples/kotlin/account/update-phone.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val result = account.updatePhone( - phone = "{$example}", - password = "{$example}", + phone = "+12065550100", + password = "password", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-push-target.md b/docs/examples/kotlin/account/update-push-target.md index 315d770..c6e6f21 100644 --- a/docs/examples/kotlin/account/update-push-target.md +++ b/docs/examples/kotlin/account/update-push-target.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val result = account.updatePushTarget( - targetId = "{$example}", - identifier = "{$example}", + targetId = "", + identifier = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-recovery.md b/docs/examples/kotlin/account/update-recovery.md index 5e9866d..b448114 100644 --- a/docs/examples/kotlin/account/update-recovery.md +++ b/docs/examples/kotlin/account/update-recovery.md @@ -9,7 +9,7 @@ val client = Client(context) val account = Account(client) val result = account.updateRecovery( - userId = "{$example}", - secret = "{$example}", + userId = "", + secret = "", password = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-session.md b/docs/examples/kotlin/account/update-session.md index e4b85a8..43d84e1 100644 --- a/docs/examples/kotlin/account/update-session.md +++ b/docs/examples/kotlin/account/update-session.md @@ -9,5 +9,5 @@ val client = Client(context) val account = Account(client) val result = account.updateSession( - sessionId = "{$example}", + sessionId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-verification.md b/docs/examples/kotlin/account/update-verification.md index 7a58116..3c9c465 100644 --- a/docs/examples/kotlin/account/update-verification.md +++ b/docs/examples/kotlin/account/update-verification.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) val result = account.updateVerification( - userId = "{$example}", - secret = "{$example}", + userId = "", + secret = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-favicon.md b/docs/examples/kotlin/avatars/get-favicon.md index b95f9c8..5f83bdd 100644 --- a/docs/examples/kotlin/avatars/get-favicon.md +++ b/docs/examples/kotlin/avatars/get-favicon.md @@ -9,5 +9,5 @@ val client = Client(context) val avatars = Avatars(client) val result = avatars.getFavicon( - url = "{$example}", + url = "https://example.com", ) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-image.md b/docs/examples/kotlin/avatars/get-image.md index 64d8619..a9a7c2a 100644 --- a/docs/examples/kotlin/avatars/get-image.md +++ b/docs/examples/kotlin/avatars/get-image.md @@ -9,7 +9,7 @@ val client = Client(context) val avatars = Avatars(client) val result = avatars.getImage( - url = "{$example}", + url = "https://example.com", width = 0, // (optional) height = 0, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-initials.md b/docs/examples/kotlin/avatars/get-initials.md index c7388b0..bd2ae1b 100644 --- a/docs/examples/kotlin/avatars/get-initials.md +++ b/docs/examples/kotlin/avatars/get-initials.md @@ -9,7 +9,7 @@ val client = Client(context) val avatars = Avatars(client) val result = avatars.getInitials( - name = "{$example}", // (optional) + name = "", // (optional) width = 0, // (optional) height = 0, // (optional) background = "", // (optional) diff --git a/docs/examples/kotlin/avatars/get-q-r.md b/docs/examples/kotlin/avatars/get-q-r.md index 1157d95..9e02a0c 100644 --- a/docs/examples/kotlin/avatars/get-q-r.md +++ b/docs/examples/kotlin/avatars/get-q-r.md @@ -9,7 +9,7 @@ val client = Client(context) val avatars = Avatars(client) val result = avatars.getQR( - text = "{$example}", + text = "", size = 1, // (optional) margin = 0, // (optional) download = false, // (optional) diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index ef2a268..2b77405 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -9,9 +9,9 @@ val client = Client(context) val databases = Databases(client) val result = databases.createDocument( - databaseId = "{$example}", - collectionId = "{$example}", - documentId = "{$example}", + databaseId = "", + collectionId = "", + documentId = "", data = mapOf( "a" to "b" ), permissions = listOf("read("any")"), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/delete-document.md b/docs/examples/kotlin/databases/delete-document.md index 240e308..e3e6de3 100644 --- a/docs/examples/kotlin/databases/delete-document.md +++ b/docs/examples/kotlin/databases/delete-document.md @@ -9,7 +9,7 @@ val client = Client(context) val databases = Databases(client) val result = databases.deleteDocument( - databaseId = "{$example}", - collectionId = "{$example}", - documentId = "{$example}", + databaseId = "", + collectionId = "", + documentId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/get-document.md b/docs/examples/kotlin/databases/get-document.md index fb13fb1..6ed6c8b 100644 --- a/docs/examples/kotlin/databases/get-document.md +++ b/docs/examples/kotlin/databases/get-document.md @@ -9,8 +9,8 @@ val client = Client(context) val databases = Databases(client) val result = databases.getDocument( - databaseId = "{$example}", - collectionId = "{$example}", - documentId = "{$example}", + databaseId = "", + collectionId = "", + documentId = "", queries = listOf(), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/list-documents.md b/docs/examples/kotlin/databases/list-documents.md index 2f4c8ae..ff419c4 100644 --- a/docs/examples/kotlin/databases/list-documents.md +++ b/docs/examples/kotlin/databases/list-documents.md @@ -9,7 +9,7 @@ val client = Client(context) val databases = Databases(client) val result = databases.listDocuments( - databaseId = "{$example}", - collectionId = "{$example}", + databaseId = "", + collectionId = "", queries = listOf(), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/update-document.md b/docs/examples/kotlin/databases/update-document.md index fb9b17c..630e2b6 100644 --- a/docs/examples/kotlin/databases/update-document.md +++ b/docs/examples/kotlin/databases/update-document.md @@ -9,9 +9,9 @@ val client = Client(context) val databases = Databases(client) val result = databases.updateDocument( - databaseId = "{$example}", - collectionId = "{$example}", - documentId = "{$example}", + databaseId = "", + collectionId = "", + documentId = "", data = mapOf( "a" to "b" ), // (optional) permissions = listOf("read("any")"), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/create-execution.md b/docs/examples/kotlin/functions/create-execution.md index d6ca800..937bb4f 100644 --- a/docs/examples/kotlin/functions/create-execution.md +++ b/docs/examples/kotlin/functions/create-execution.md @@ -9,10 +9,10 @@ val client = Client(context) val functions = Functions(client) val result = functions.createExecution( - functionId = "{$example}", - body = Payload.fromJson(mapOf("x" to "y" as Any)), // (optional) + functionId = "", + body = "", // (optional) async = false, // (optional) - path = "{$example}", // (optional) + path = "", // (optional) method = ExecutionMethod.GET, // (optional) headers = mapOf( "a" to "b" ), // (optional) scheduledAt = "", // (optional) diff --git a/docs/examples/kotlin/functions/get-execution.md b/docs/examples/kotlin/functions/get-execution.md index 2e2c54e..60b2e0f 100644 --- a/docs/examples/kotlin/functions/get-execution.md +++ b/docs/examples/kotlin/functions/get-execution.md @@ -9,6 +9,6 @@ val client = Client(context) val functions = Functions(client) val result = functions.getExecution( - functionId = "{$example}", - executionId = "{$example}", + functionId = "", + executionId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/list-executions.md b/docs/examples/kotlin/functions/list-executions.md index f916c9d..90b2bf6 100644 --- a/docs/examples/kotlin/functions/list-executions.md +++ b/docs/examples/kotlin/functions/list-executions.md @@ -9,7 +9,7 @@ val client = Client(context) val functions = Functions(client) val result = functions.listExecutions( - functionId = "{$example}", + functionId = "", queries = listOf(), // (optional) - search = "{$example}", // (optional) + search = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/messaging/create-subscriber.md b/docs/examples/kotlin/messaging/create-subscriber.md index 4292dec..db23342 100644 --- a/docs/examples/kotlin/messaging/create-subscriber.md +++ b/docs/examples/kotlin/messaging/create-subscriber.md @@ -9,7 +9,7 @@ val client = Client(context) val messaging = Messaging(client) val result = messaging.createSubscriber( - topicId = "{$example}", - subscriberId = "{$example}", - targetId = "{$example}", + topicId = "", + subscriberId = "", + targetId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/messaging/delete-subscriber.md b/docs/examples/kotlin/messaging/delete-subscriber.md index 0617824..ab0d479 100644 --- a/docs/examples/kotlin/messaging/delete-subscriber.md +++ b/docs/examples/kotlin/messaging/delete-subscriber.md @@ -9,6 +9,6 @@ val client = Client(context) val messaging = Messaging(client) val result = messaging.deleteSubscriber( - topicId = "{$example}", - subscriberId = "{$example}", + topicId = "", + subscriberId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/create-file.md b/docs/examples/kotlin/storage/create-file.md index 816ece1..d327e72 100644 --- a/docs/examples/kotlin/storage/create-file.md +++ b/docs/examples/kotlin/storage/create-file.md @@ -1,6 +1,6 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.models.Payload +import io.appwrite.models.InputFile import io.appwrite.services.Storage val client = Client(context) @@ -10,8 +10,8 @@ val client = Client(context) val storage = Storage(client) val result = storage.createFile( - bucketId = "{$example}", - fileId = "{$example}", - file = Payload.fromFile("/path/to/file.png"), + bucketId = "", + fileId = "", + file = InputFile.fromPath("file.png"), permissions = listOf("read("any")"), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/delete-file.md b/docs/examples/kotlin/storage/delete-file.md index d4f802b..60df78e 100644 --- a/docs/examples/kotlin/storage/delete-file.md +++ b/docs/examples/kotlin/storage/delete-file.md @@ -9,6 +9,6 @@ val client = Client(context) val storage = Storage(client) val result = storage.deleteFile( - bucketId = "{$example}", - fileId = "{$example}", + bucketId = "", + fileId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file-download.md b/docs/examples/kotlin/storage/get-file-download.md index 3ae382e..bb97541 100644 --- a/docs/examples/kotlin/storage/get-file-download.md +++ b/docs/examples/kotlin/storage/get-file-download.md @@ -9,6 +9,6 @@ val client = Client(context) val storage = Storage(client) val result = storage.getFileDownload( - bucketId = "{$example}", - fileId = "{$example}", + bucketId = "", + fileId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file-preview.md b/docs/examples/kotlin/storage/get-file-preview.md index cc6911a..904f3ec 100644 --- a/docs/examples/kotlin/storage/get-file-preview.md +++ b/docs/examples/kotlin/storage/get-file-preview.md @@ -9,8 +9,8 @@ val client = Client(context) val storage = Storage(client) val result = storage.getFilePreview( - bucketId = "{$example}", - fileId = "{$example}", + bucketId = "", + fileId = "", width = 0, // (optional) height = 0, // (optional) gravity = ImageGravity.CENTER, // (optional) diff --git a/docs/examples/kotlin/storage/get-file-view.md b/docs/examples/kotlin/storage/get-file-view.md index bf50695..898c1ee 100644 --- a/docs/examples/kotlin/storage/get-file-view.md +++ b/docs/examples/kotlin/storage/get-file-view.md @@ -9,6 +9,6 @@ val client = Client(context) val storage = Storage(client) val result = storage.getFileView( - bucketId = "{$example}", - fileId = "{$example}", + bucketId = "", + fileId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file.md b/docs/examples/kotlin/storage/get-file.md index 040559b..a07095d 100644 --- a/docs/examples/kotlin/storage/get-file.md +++ b/docs/examples/kotlin/storage/get-file.md @@ -9,6 +9,6 @@ val client = Client(context) val storage = Storage(client) val result = storage.getFile( - bucketId = "{$example}", - fileId = "{$example}", + bucketId = "", + fileId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/list-files.md b/docs/examples/kotlin/storage/list-files.md index e7f09a2..640b705 100644 --- a/docs/examples/kotlin/storage/list-files.md +++ b/docs/examples/kotlin/storage/list-files.md @@ -9,7 +9,7 @@ val client = Client(context) val storage = Storage(client) val result = storage.listFiles( - bucketId = "{$example}", + bucketId = "", queries = listOf(), // (optional) - search = "{$example}", // (optional) + search = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/update-file.md b/docs/examples/kotlin/storage/update-file.md index 325fc44..f7a20f0 100644 --- a/docs/examples/kotlin/storage/update-file.md +++ b/docs/examples/kotlin/storage/update-file.md @@ -9,8 +9,8 @@ val client = Client(context) val storage = Storage(client) val result = storage.updateFile( - bucketId = "{$example}", - fileId = "{$example}", - name = "{$example}", // (optional) + bucketId = "", + fileId = "", + name = "", // (optional) permissions = listOf("read("any")"), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/create-membership.md b/docs/examples/kotlin/teams/create-membership.md index 6b4b6f1..63f3c67 100644 --- a/docs/examples/kotlin/teams/create-membership.md +++ b/docs/examples/kotlin/teams/create-membership.md @@ -9,11 +9,11 @@ val client = Client(context) val teams = Teams(client) val result = teams.createMembership( - teamId = "{$example}", + teamId = "", roles = listOf(), - email = "{$example}", // (optional) - userId = "{$example}", // (optional) - phone = "{$example}", // (optional) - url = "{$example}", // (optional) - name = "{$example}", // (optional) + email = "email@example.com", // (optional) + userId = "", // (optional) + phone = "+12065550100", // (optional) + url = "https://example.com", // (optional) + name = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/create.md b/docs/examples/kotlin/teams/create.md index 93ef2c6..f214a37 100644 --- a/docs/examples/kotlin/teams/create.md +++ b/docs/examples/kotlin/teams/create.md @@ -9,7 +9,7 @@ val client = Client(context) val teams = Teams(client) val result = teams.create( - teamId = "{$example}", - name = "{$example}", + teamId = "", + name = "", roles = listOf(), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/delete-membership.md b/docs/examples/kotlin/teams/delete-membership.md index 97cf4d5..f3a54b3 100644 --- a/docs/examples/kotlin/teams/delete-membership.md +++ b/docs/examples/kotlin/teams/delete-membership.md @@ -9,6 +9,6 @@ val client = Client(context) val teams = Teams(client) val result = teams.deleteMembership( - teamId = "{$example}", - membershipId = "{$example}", + teamId = "", + membershipId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/delete.md b/docs/examples/kotlin/teams/delete.md index 9ffc6db..bc8e8d0 100644 --- a/docs/examples/kotlin/teams/delete.md +++ b/docs/examples/kotlin/teams/delete.md @@ -9,5 +9,5 @@ val client = Client(context) val teams = Teams(client) val result = teams.delete( - teamId = "{$example}", + teamId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/get-membership.md b/docs/examples/kotlin/teams/get-membership.md index 3277431..e5a589e 100644 --- a/docs/examples/kotlin/teams/get-membership.md +++ b/docs/examples/kotlin/teams/get-membership.md @@ -9,6 +9,6 @@ val client = Client(context) val teams = Teams(client) val result = teams.getMembership( - teamId = "{$example}", - membershipId = "{$example}", + teamId = "", + membershipId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/get-prefs.md b/docs/examples/kotlin/teams/get-prefs.md index 2791cda..af7503a 100644 --- a/docs/examples/kotlin/teams/get-prefs.md +++ b/docs/examples/kotlin/teams/get-prefs.md @@ -9,5 +9,5 @@ val client = Client(context) val teams = Teams(client) val result = teams.getPrefs( - teamId = "{$example}", + teamId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/get.md b/docs/examples/kotlin/teams/get.md index 9278e43..70759bc 100644 --- a/docs/examples/kotlin/teams/get.md +++ b/docs/examples/kotlin/teams/get.md @@ -9,5 +9,5 @@ val client = Client(context) val teams = Teams(client) val result = teams.get( - teamId = "{$example}", + teamId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/list-memberships.md b/docs/examples/kotlin/teams/list-memberships.md index 789a810..abb140e 100644 --- a/docs/examples/kotlin/teams/list-memberships.md +++ b/docs/examples/kotlin/teams/list-memberships.md @@ -9,7 +9,7 @@ val client = Client(context) val teams = Teams(client) val result = teams.listMemberships( - teamId = "{$example}", + teamId = "", queries = listOf(), // (optional) - search = "{$example}", // (optional) + search = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/list.md b/docs/examples/kotlin/teams/list.md index 0cffc22..5d80873 100644 --- a/docs/examples/kotlin/teams/list.md +++ b/docs/examples/kotlin/teams/list.md @@ -10,5 +10,5 @@ val teams = Teams(client) val result = teams.list( queries = listOf(), // (optional) - search = "{$example}", // (optional) + search = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-membership-status.md b/docs/examples/kotlin/teams/update-membership-status.md index d9454eb..9ecf417 100644 --- a/docs/examples/kotlin/teams/update-membership-status.md +++ b/docs/examples/kotlin/teams/update-membership-status.md @@ -9,8 +9,8 @@ val client = Client(context) val teams = Teams(client) val result = teams.updateMembershipStatus( - teamId = "{$example}", - membershipId = "{$example}", - userId = "{$example}", - secret = "{$example}", + teamId = "", + membershipId = "", + userId = "", + secret = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-membership.md b/docs/examples/kotlin/teams/update-membership.md index 5fbec70..15b2ac0 100644 --- a/docs/examples/kotlin/teams/update-membership.md +++ b/docs/examples/kotlin/teams/update-membership.md @@ -9,7 +9,7 @@ val client = Client(context) val teams = Teams(client) val result = teams.updateMembership( - teamId = "{$example}", - membershipId = "{$example}", + teamId = "", + membershipId = "", roles = listOf(), ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-name.md b/docs/examples/kotlin/teams/update-name.md index aec0dcb..0040737 100644 --- a/docs/examples/kotlin/teams/update-name.md +++ b/docs/examples/kotlin/teams/update-name.md @@ -9,6 +9,6 @@ val client = Client(context) val teams = Teams(client) val result = teams.updateName( - teamId = "{$example}", - name = "{$example}", + teamId = "", + name = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/teams/update-prefs.md b/docs/examples/kotlin/teams/update-prefs.md index a292333..f70a5eb 100644 --- a/docs/examples/kotlin/teams/update-prefs.md +++ b/docs/examples/kotlin/teams/update-prefs.md @@ -9,6 +9,6 @@ val client = Client(context) val teams = Teams(client) val result = teams.updatePrefs( - teamId = "{$example}", + teamId = "", prefs = mapOf( "a" to "b" ), ) \ 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 f53113d..4302327 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 @@ -81,8 +81,8 @@ class AccountsViewModel : ViewModel() { account.createOAuth2Session( activity, OAuthProvider.FACEBOOK, - "appwrite-callback-6070749e6acd4://demo.appwrite.io/auth/oauth2/success", - "appwrite-callback-6070749e6acd4://demo.appwrite.io/auth/oauth2/failure" + "appwrite-callback-6070749e6acd4://cloud.appwrite.io/auth/oauth2/success", + "appwrite-callback-6070749e6acd4://cloud.appwrite.io/auth/oauth2/failure" ) } catch (e: Exception) { _error.postValue(Event(e)) diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 635a902..93a3e06 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -7,9 +7,8 @@ import io.appwrite.cookies.ListenableCookieJar import io.appwrite.cookies.stores.SharedPreferencesCookieStore import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.fromJson -import io.appwrite.extensions.fromMultiPart import io.appwrite.extensions.toJson -import io.appwrite.models.Payload +import io.appwrite.models.InputFile import io.appwrite.models.UploadProgress import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -61,7 +60,7 @@ class Client @JvmOverloads constructor( internal lateinit var http: OkHttpClient internal val headers: MutableMap - + val config: MutableMap internal val cookieJar = ListenableCookieJar(CookieManager( @@ -87,11 +86,11 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "6.0.0", + "x-sdk-version" to "6.0.0", "x-appwrite-response-format" to "1.6.0" ) config = mutableMapOf() - + setSelfSigned(selfSigned) } @@ -155,10 +154,10 @@ class Client @JvmOverloads constructor( /** * Set self Signed - * + * * @param status * - * @return this + * @return this */ fun setSelfSigned(status: Boolean): Client { selfSigned = status @@ -207,10 +206,10 @@ class Client @JvmOverloads constructor( /** * Set endpoint and realtime endpoint. - * + * * @param endpoint * - * @return this + * @return this */ fun setEndpoint(endpoint: String): Client { this.endpoint = endpoint @@ -236,11 +235,11 @@ class Client @JvmOverloads constructor( /** * Add Header - * + * * @param key * @param value * - * @return this + * @return this */ fun addHeader(key: String, value: String): Client { headers[key] = value @@ -249,19 +248,19 @@ class Client @JvmOverloads constructor( /** * Send the HTTP request - * + * * @param method * @param path * @param headers * @param params * - * @return [T] + * @return [T] */ @Throws(AppwriteException::class) suspend fun call( - method: String, - path: String, - headers: Map = mapOf(), + method: String, + path: String, + headers: Map = mapOf(), params: Map = mapOf(), responseType: Class, converter: ((Any) -> T)? = null @@ -320,14 +319,6 @@ class Client @JvmOverloads constructor( ) } } - it.value is Payload -> { - val payload = it.value as Payload - if (payload.sourceType == "path") { - builder.addFormDataPart(it.key, payload.filename, File(payload.path).asRequestBody()) - } else { - builder.addFormDataPart(it.key, payload.toString()) - } - } else -> { builder.addFormDataPart(it.key, it.value.toString()) } @@ -370,14 +361,14 @@ class Client @JvmOverloads constructor( onProgress: ((UploadProgress) -> Unit)? = null, ): T { var file: RandomAccessFile? = null - val input = params[paramName] as Payload + val input = params[paramName] as InputFile val size: Long = when(input.sourceType) { "path", "file" -> { file = RandomAccessFile(input.path, "r") file.length() } "bytes" -> { - input.toBinary().size.toLong() + (input.data as ByteArray).size.toLong() } else -> throw UnsupportedOperationException() } @@ -385,7 +376,7 @@ class Client @JvmOverloads constructor( if (size < CHUNK_SIZE) { val data = when(input.sourceType) { "file", "path" -> File(input.path).asRequestBody() - "bytes" -> input.toBinary().toRequestBody(input.mimeType?.toMediaType()) + "bytes" -> (input.data as ByteArray).toRequestBody(input.mimeType.toMediaType()) else -> throw UnsupportedOperationException() } params[paramName] = MultipartBody.Part.createFormData( @@ -432,7 +423,7 @@ class Client @JvmOverloads constructor( } else { size - 1 } - input.toBinary().copyInto( + (input.data as ByteArray).copyInto( buffer, startIndex = offset.toInt(), endIndex = end.toInt() @@ -504,14 +495,14 @@ class Client @JvmOverloads constructor( .charStream() .buffered() .use(BufferedReader::readText) - + val error = if (response.headers["content-type"]?.contains("application/json") == true) { val map = body.fromJson>() AppwriteException( - map["message"] as? String ?: "", + map["message"] as? String ?: "", (map["code"] as Number).toInt(), - map["type"] as? String ?: "", + map["type"] as? String ?: "", body ) } else { @@ -546,14 +537,6 @@ class Client @JvmOverloads constructor( return } } - if (response.headers["content-type"]?.contains("multipart/form-data") == true) { - val binaryBody = response.body!!.bytes() - val body = String(binaryBody) - val map = body.fromMultiPart(binaryBody) - it.resume(converter?.invoke(map) ?: map as T) - return - } - val body = response.body!! .charStream() .buffered() @@ -571,4 +554,4 @@ class Client @JvmOverloads constructor( } }) } -} +} \ 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 index ad26379..e699a54 100644 --- a/library/src/main/java/io/appwrite/extensions/TypeExtensions.kt +++ b/library/src/main/java/io/appwrite/extensions/TypeExtensions.kt @@ -1,104 +1,9 @@ package io.appwrite.extensions -import io.appwrite.models.Payload import kotlin.reflect.KClass import kotlin.reflect.typeOf inline fun classOf(): Class { - @Suppress("UNCHECKED_CAST") return (typeOf().classifier!! as KClass).java -} - -fun String.fromMultiPart(binaryBody: ByteArray): Map { - val match = Regex("(-+\\w+)--").find(this) ?: return emptyMap() - // For kotlin - - val boundary = match.groupValues[1] - - var map = - mutableMapOf( - "\$id" to "", - "\$createdAt" to "", - "\$updatedAt" to "", - "\$permissions" to emptyList(), - "functionId" to "", - "trigger" to "", - "status" to "", - "requestMethod" to "", - "requestPath" to "", - "requestHeaders" to emptyList>(), - "responseStatusCode" to 0, - "responseBody" to Payload.fromBinary(ByteArray(0)), - "responseHeaders" to emptyList>(), - "logs" to "", - "errors" to "", - "duration" to 0.0, - "scheduledAt" to "", - ) - val parts = this.split(boundary) - for (part in parts) { - var lines = part.split("\r\n") - - val name = Regex("name=\"?(\\w+)").find(part) ?: continue - - lines = - lines - .dropWhile { it.isEmpty() } - .drop(1) - .dropWhile { it.isEmpty() } - .dropLastWhile { it.isEmpty() } - val key = name.groupValues[1] - - if (lines.isEmpty()) { - continue - } - - if (key == "responseBody") { - val needle = "name=\"responseBody\"\r\n\r\n" - val indexOf = this.indexOf(needle) + needle.length - val endBytes = "\r\n-------".toByteArray() - val list = ByteArray(binaryBody.size - indexOf) - val multipart = binaryBody.drop(indexOf) - var weHitTheEnd = false - var j = 0 - for (i in multipart) { - if (multipart.size > j + endBytes.size) { - var jj = 0 - for (byte in endBytes) { - if (byte != multipart[j + jj]) break - jj++ - if (jj != endBytes.size - 1) continue - weHitTheEnd = true - } - } - if (weHitTheEnd) { - break - } - - list[j] = multipart[j] - j++ - } - - map["responseBody"] = - Payload.fromBinary(list.dropLastWhile { it == 0.toByte() }.toByteArray()) - continue - } - - if (lines[0] == "Content-Type: application/json") { - lines = lines.drop(1).dropWhile { it.isEmpty() } - val list = lines.joinToString("\r\n").fromJson>() - map[key] = list - continue - } - - val value = lines.joinToString("\r\n") - - map[key] = - when (key) { - "responseStatusCode" -> value.toInt() - "duration" -> value.toFloat() - else -> value - } - } - - return map -} + @Suppress("UNCHECKED_CAST") + return (typeOf().classifier!! as KClass).java +} \ 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 5a7d371..01204de 100644 --- a/library/src/main/java/io/appwrite/models/Document.kt +++ b/library/src/main/java/io/appwrite/models/Document.kt @@ -41,7 +41,7 @@ data class Document( * Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). */ @SerializedName("\$permissions") - val permissions: List, + val permissions: List, /** * Additional properties @@ -66,7 +66,7 @@ data class Document( databaseId: String, createdAt: String, updatedAt: String, - permissions: List, + permissions: List, data: Map ) = Document>( id, @@ -88,7 +88,7 @@ data class Document( databaseId = map["\$databaseId"] as String, createdAt = map["\$createdAt"] as String, updatedAt = map["\$updatedAt"] as String, - permissions = map["\$permissions"] as List, + permissions = map["\$permissions"] as List, data = map.jsonCast(to = nestedType) ) } diff --git a/library/src/main/java/io/appwrite/models/Execution.kt b/library/src/main/java/io/appwrite/models/Execution.kt index c16659a..1b6226a 100644 --- a/library/src/main/java/io/appwrite/models/Execution.kt +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -29,7 +29,7 @@ data class Execution( * Execution roles. */ @SerializedName("\$permissions") - val permissions: List, + val permissions: List, /** * Function ID. @@ -77,7 +77,7 @@ data class Execution( * HTTP response body. This will return empty unless execution is created as synchronous. */ @SerializedName("responseBody") - val responseBody: Payload, + val responseBody: String, /** * HTTP response headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. @@ -139,7 +139,7 @@ data class Execution( id = map["\$id"] as String, createdAt = map["\$createdAt"] as String, updatedAt = map["\$updatedAt"] as String, - permissions = map["\$permissions"] as List, + permissions = map["\$permissions"] as List, functionId = map["functionId"] as String, trigger = map["trigger"] as String, status = map["status"] as String, @@ -147,7 +147,7 @@ data class Execution( requestPath = map["requestPath"] as String, requestHeaders = (map["requestHeaders"] as List>).map { Headers.from(map = it) }, responseStatusCode = (map["responseStatusCode"] as Number).toLong(), - responseBody = map["responseBody"] as Payload, + responseBody = map["responseBody"] as String, responseHeaders = (map["responseHeaders"] as List>).map { Headers.from(map = it) }, logs = map["logs"] as String, errors = map["errors"] as String, diff --git a/library/src/main/java/io/appwrite/models/File.kt b/library/src/main/java/io/appwrite/models/File.kt index 5c2b731..897fc4a 100644 --- a/library/src/main/java/io/appwrite/models/File.kt +++ b/library/src/main/java/io/appwrite/models/File.kt @@ -35,7 +35,7 @@ data class File( * File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). */ @SerializedName("\$permissions") - val permissions: List, + val permissions: List, /** * File name. @@ -98,7 +98,7 @@ data class File( bucketId = map["bucketId"] as String, createdAt = map["\$createdAt"] as String, updatedAt = map["\$updatedAt"] as String, - permissions = map["\$permissions"] as List, + permissions = map["\$permissions"] as List, name = map["name"] as String, signature = map["signature"] as String, mimeType = map["mimeType"] as String, diff --git a/library/src/main/java/io/appwrite/models/InputFile.kt b/library/src/main/java/io/appwrite/models/InputFile.kt new file mode 100644 index 0000000..afbb2e9 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/InputFile.kt @@ -0,0 +1,37 @@ +package io.appwrite.models + +import java.io.File +import java.net.URLConnection +import java.nio.file.Files +import java.nio.file.Paths + +class InputFile private constructor() { + + lateinit var path: String + lateinit var filename: String + lateinit var mimeType: String + lateinit var sourceType: String + lateinit var data: Any + + companion object { + fun fromFile(file: File) = InputFile().apply { + path = file.canonicalPath + filename = file.name + mimeType = Files.probeContentType(Paths.get(file.canonicalPath)) + ?: URLConnection.guessContentTypeFromName(filename) + ?: "" + sourceType = "file" + } + + fun fromPath(path: String): InputFile = fromFile(File(path)).apply { + sourceType = "path" + } + + fun fromBytes(bytes: ByteArray, filename: String = "", mimeType: String = "") = InputFile().apply { + this.filename = filename + this.mimeType = mimeType + data = bytes + sourceType = "bytes" + } + } +} \ 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 17ab303..1f20394 100644 --- a/library/src/main/java/io/appwrite/models/Membership.kt +++ b/library/src/main/java/io/appwrite/models/Membership.kt @@ -83,7 +83,7 @@ data class Membership( * User list of roles */ @SerializedName("roles") - val roles: List, + val roles: List, ) { fun toMap(): Map = mapOf( @@ -120,7 +120,7 @@ data class Membership( joined = map["joined"] as String, confirm = map["confirm"] as Boolean, mfa = map["mfa"] as Boolean, - roles = map["roles"] as List, + roles = map["roles"] as List, ) } } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/MfaRecoveryCodes.kt b/library/src/main/java/io/appwrite/models/MfaRecoveryCodes.kt index ad8bc45..3fab41a 100644 --- a/library/src/main/java/io/appwrite/models/MfaRecoveryCodes.kt +++ b/library/src/main/java/io/appwrite/models/MfaRecoveryCodes.kt @@ -11,7 +11,7 @@ data class MfaRecoveryCodes( * Recovery codes. */ @SerializedName("recoveryCodes") - val recoveryCodes: List, + val recoveryCodes: List, ) { fun toMap(): Map = mapOf( @@ -24,7 +24,7 @@ data class MfaRecoveryCodes( fun from( map: Map, ) = MfaRecoveryCodes( - recoveryCodes = map["recoveryCodes"] as List, + recoveryCodes = map["recoveryCodes"] as List, ) } } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Payload.kt b/library/src/main/java/io/appwrite/models/Payload.kt deleted file mode 100644 index 5c9ff7f..0000000 --- a/library/src/main/java/io/appwrite/models/Payload.kt +++ /dev/null @@ -1,73 +0,0 @@ -package io.appwrite.models - -import io.appwrite.extensions.gson -import java.io.File -import java.net.URLConnection -import java.nio.file.Files -import java.nio.file.Paths - -class Payload private constructor() { - - lateinit var path: String - lateinit var filename: String - lateinit var sourceType: String - lateinit var data: Any - var mimeType: String? = null - - override fun toString(): String { - if (sourceType != "bytes") { - throw IllegalArgumentException("source type is not supported: $sourceType") - } - - return String(data as ByteArray) - } - - fun toBinary(): ByteArray { - if (sourceType != "bytes") { - throw IllegalArgumentException("source type is not supported: $sourceType") - } - - return data as ByteArray - } - - fun toJson(): MutableMap { - if (sourceType != "bytes") { - throw IllegalArgumentException("source type is not supported: $sourceType") - } - - return gson.fromJson(toString(), MutableMap::class.java) as MutableMap - } - - fun toFile(path: String): File { - Files.createDirectories(Paths.get(path).parent); - - val file = File(path) - file.appendBytes(toBinary()) - return file - } - - companion object { - fun fromFile(path: String,filename: String = ""): Payload = fromFileObject(File(path), filename).apply { - sourceType = "path" - } - - fun fromBinary(bytes: ByteArray, filename: String = "") = Payload().apply { - this.filename = filename - data = bytes - sourceType = "bytes" - } - - fun fromString(string: String) = fromBinary(string.toByteArray()) - - fun fromJson(data: Any) = fromString(gson.toJson(data)) - - fun fromFileObject(file: File, name: String = "") = Payload().apply { - path = file.canonicalPath - filename = if (name != "") name else file.name - mimeType = Files.probeContentType(Paths.get(file.canonicalPath)) - ?: URLConnection.guessContentTypeFromName(filename) - ?: "" - sourceType = "file" - } - } -} diff --git a/library/src/main/java/io/appwrite/models/Session.kt b/library/src/main/java/io/appwrite/models/Session.kt index 1c6a7b2..02dbb28 100644 --- a/library/src/main/java/io/appwrite/models/Session.kt +++ b/library/src/main/java/io/appwrite/models/Session.kt @@ -167,7 +167,7 @@ data class Session( * Returns a list of active session factors. */ @SerializedName("factors") - val factors: List, + val factors: List, /** * Secret used to authenticate the user. Only included if the request was made with an API key @@ -246,7 +246,7 @@ data class Session( countryCode = map["countryCode"] as String, countryName = map["countryName"] as String, current = map["current"] as Boolean, - factors = map["factors"] as List, + factors = map["factors"] as List, secret = map["secret"] as String, mfaUpdatedAt = map["mfaUpdatedAt"] as String, ) diff --git a/library/src/main/java/io/appwrite/models/User.kt b/library/src/main/java/io/appwrite/models/User.kt index 095467a..fd03fc2 100644 --- a/library/src/main/java/io/appwrite/models/User.kt +++ b/library/src/main/java/io/appwrite/models/User.kt @@ -65,7 +65,7 @@ data class User( * Labels for the user. */ @SerializedName("labels") - val labels: List, + val labels: List, /** * Password update time in ISO 8601 format. @@ -155,7 +155,7 @@ data class User( hashOptions: Any?, registration: String, status: Boolean, - labels: List, + labels: List, passwordUpdate: String, email: String, phone: String, @@ -201,7 +201,7 @@ data class User( hashOptions = map["hashOptions"] as? Any?, registration = map["registration"] as String, status = map["status"] as Boolean, - labels = map["labels"] as List, + labels = map["labels"] as List, passwordUpdate = map["passwordUpdate"] as String, email = map["email"] as String, phone = map["phone"] as String, diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 25c71e3..6f4cbd8 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -28,19 +28,19 @@ class Account(client: Client) : Service(client) { */ suspend fun get( nestedType: Class, - ): io.appwrite.models.User { + ): io.appwrite.models.User { val apiPath = "/account" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -59,9 +59,9 @@ class Account(client: Client) : Service(client) { */ @Throws(AppwriteException::class) suspend fun get( - ): io.appwrite.models.User> = get( + ): io.appwrite.models.User> = get( nestedType = classOf(), - ) + ) /** * Create account @@ -81,23 +81,23 @@ class Account(client: Client) : Service(client) { password: String, name: String? = null, nestedType: Class, - ): io.appwrite.models.User { + ): io.appwrite.models.User { val apiPath = "/account" val apiParams = mutableMapOf( - "userId" to userId, - "email" to email, - "password" to password, - "name" to name, + "userId" to userId, + "email" to email, + "password" to password, + "name" to name, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -125,13 +125,13 @@ class Account(client: Client) : Service(client) { email: String, password: String, name: String? = null, - ): io.appwrite.models.User> = create( + ): io.appwrite.models.User> = create( userId, email, password, name, nestedType = classOf(), - ) + ) /** * Update email @@ -146,21 +146,21 @@ class Account(client: Client) : Service(client) { email: String, password: String, nestedType: Class, - ): io.appwrite.models.User { + ): io.appwrite.models.User { val apiPath = "/account/email" val apiParams = mutableMapOf( - "email" to email, - "password" to password, + "email" to email, + "password" to password, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } - return client.call( + return client.call( "PATCH", apiPath, apiHeaders, @@ -183,11 +183,11 @@ class Account(client: Client) : Service(client) { suspend fun updateEmail( email: String, password: String, - ): io.appwrite.models.User> = updateEmail( + ): io.appwrite.models.User> = updateEmail( email, password, nestedType = classOf(), - ) + ) /** * List identities @@ -200,20 +200,20 @@ class Account(client: Client) : Service(client) { @JvmOverloads suspend fun listIdentities( queries: List? = null, - ): io.appwrite.models.IdentityList { + ): io.appwrite.models.IdentityList { val apiPath = "/account/identities" val apiParams = mutableMapOf( - "queries" to queries, + "queries" to queries, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.IdentityList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.IdentityList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -234,16 +234,16 @@ class Account(client: Client) : Service(client) { */ suspend fun deleteIdentity( identityId: String, - ): Any { + ): Any { val apiPath = "/account/identities/{identityId}" .replace("{identityId}", identityId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - return client.call( + return client.call( "DELETE", apiPath, apiHeaders, @@ -261,19 +261,19 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.Jwt] */ suspend fun createJWT( - ): io.appwrite.models.Jwt { + ): io.appwrite.models.Jwt { val apiPath = "/account/jwts" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Jwt = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Jwt.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -295,20 +295,20 @@ class Account(client: Client) : Service(client) { @JvmOverloads suspend fun listLogs( queries: List? = null, - ): io.appwrite.models.LogList { + ): io.appwrite.models.LogList { val apiPath = "/account/logs" val apiParams = mutableMapOf( - "queries" to queries, + "queries" to queries, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LogList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.LogList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -330,20 +330,20 @@ class Account(client: Client) : Service(client) { suspend fun updateMFA( mfa: Boolean, nestedType: Class, - ): io.appwrite.models.User { + ): io.appwrite.models.User { val apiPath = "/account/mfa" val apiParams = mutableMapOf( - "mfa" to mfa, + "mfa" to mfa, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } - return client.call( + return client.call( "PATCH", apiPath, apiHeaders, @@ -364,10 +364,10 @@ class Account(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun updateMFA( mfa: Boolean, - ): io.appwrite.models.User> = updateMFA( + ): io.appwrite.models.User> = updateMFA( mfa, nestedType = classOf(), - ) + ) /** * Create authenticator @@ -379,20 +379,20 @@ class Account(client: Client) : Service(client) { */ suspend fun createMfaAuthenticator( type: io.appwrite.enums.AuthenticatorType, - ): io.appwrite.models.MfaType { + ): io.appwrite.models.MfaType { val apiPath = "/account/mfa/authenticators/{type}" .replace("{type}", type.value) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MfaType = { @Suppress("UNCHECKED_CAST") io.appwrite.models.MfaType.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -416,21 +416,21 @@ class Account(client: Client) : Service(client) { type: io.appwrite.enums.AuthenticatorType, otp: String, nestedType: Class, - ): io.appwrite.models.User { + ): io.appwrite.models.User { val apiPath = "/account/mfa/authenticators/{type}" .replace("{type}", type.value) val apiParams = mutableMapOf( - "otp" to otp, + "otp" to otp, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } - return client.call( + return client.call( "PUT", apiPath, apiHeaders, @@ -453,11 +453,11 @@ class Account(client: Client) : Service(client) { suspend fun updateMfaAuthenticator( type: io.appwrite.enums.AuthenticatorType, otp: String, - ): io.appwrite.models.User> = updateMfaAuthenticator( + ): io.appwrite.models.User> = updateMfaAuthenticator( type, otp, nestedType = classOf(), - ) + ) /** * Delete authenticator @@ -469,16 +469,16 @@ class Account(client: Client) : Service(client) { */ suspend fun deleteMfaAuthenticator( type: io.appwrite.enums.AuthenticatorType, - ): Any { + ): Any { val apiPath = "/account/mfa/authenticators/{type}" .replace("{type}", type.value) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - return client.call( + return client.call( "DELETE", apiPath, apiHeaders, @@ -498,20 +498,20 @@ class Account(client: Client) : Service(client) { */ suspend fun createMfaChallenge( factor: io.appwrite.enums.AuthenticationFactor, - ): io.appwrite.models.MfaChallenge { + ): io.appwrite.models.MfaChallenge { val apiPath = "/account/mfa/challenge" val apiParams = mutableMapOf( - "factor" to factor, + "factor" to factor, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MfaChallenge = { @Suppress("UNCHECKED_CAST") io.appwrite.models.MfaChallenge.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -534,17 +534,17 @@ class Account(client: Client) : Service(client) { suspend fun updateMfaChallenge( challengeId: String, otp: String, - ): Any { + ): Any { val apiPath = "/account/mfa/challenge" val apiParams = mutableMapOf( - "challengeId" to challengeId, - "otp" to otp, + "challengeId" to challengeId, + "otp" to otp, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - return client.call( + return client.call( "PUT", apiPath, apiHeaders, @@ -562,19 +562,19 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.MfaFactors] */ suspend fun listMfaFactors( - ): io.appwrite.models.MfaFactors { + ): io.appwrite.models.MfaFactors { val apiPath = "/account/mfa/factors" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MfaFactors = { @Suppress("UNCHECKED_CAST") io.appwrite.models.MfaFactors.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -593,19 +593,19 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.MfaRecoveryCodes] */ suspend fun getMfaRecoveryCodes( - ): io.appwrite.models.MfaRecoveryCodes { + ): io.appwrite.models.MfaRecoveryCodes { val apiPath = "/account/mfa/recovery-codes" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MfaRecoveryCodes = { @Suppress("UNCHECKED_CAST") io.appwrite.models.MfaRecoveryCodes.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -624,19 +624,19 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.MfaRecoveryCodes] */ suspend fun createMfaRecoveryCodes( - ): io.appwrite.models.MfaRecoveryCodes { + ): io.appwrite.models.MfaRecoveryCodes { val apiPath = "/account/mfa/recovery-codes" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MfaRecoveryCodes = { @Suppress("UNCHECKED_CAST") io.appwrite.models.MfaRecoveryCodes.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -655,19 +655,19 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.MfaRecoveryCodes] */ suspend fun updateMfaRecoveryCodes( - ): io.appwrite.models.MfaRecoveryCodes { + ): io.appwrite.models.MfaRecoveryCodes { val apiPath = "/account/mfa/recovery-codes" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MfaRecoveryCodes = { @Suppress("UNCHECKED_CAST") io.appwrite.models.MfaRecoveryCodes.from(map = it as Map) } - return client.call( + return client.call( "PATCH", apiPath, apiHeaders, @@ -689,20 +689,20 @@ class Account(client: Client) : Service(client) { suspend fun updateName( name: String, nestedType: Class, - ): io.appwrite.models.User { + ): io.appwrite.models.User { val apiPath = "/account/name" val apiParams = mutableMapOf( - "name" to name, + "name" to name, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } - return client.call( + return client.call( "PATCH", apiPath, apiHeaders, @@ -723,10 +723,10 @@ class Account(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun updateName( name: String, - ): io.appwrite.models.User> = updateName( + ): io.appwrite.models.User> = updateName( name, nestedType = classOf(), - ) + ) /** * Update password @@ -742,21 +742,21 @@ class Account(client: Client) : Service(client) { password: String, oldPassword: String? = null, nestedType: Class, - ): io.appwrite.models.User { + ): io.appwrite.models.User { val apiPath = "/account/password" val apiParams = mutableMapOf( - "password" to password, - "oldPassword" to oldPassword, + "password" to password, + "oldPassword" to oldPassword, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } - return client.call( + return client.call( "PATCH", apiPath, apiHeaders, @@ -780,11 +780,11 @@ class Account(client: Client) : Service(client) { suspend fun updatePassword( password: String, oldPassword: String? = null, - ): io.appwrite.models.User> = updatePassword( + ): io.appwrite.models.User> = updatePassword( password, oldPassword, nestedType = classOf(), - ) + ) /** * Update phone @@ -799,21 +799,21 @@ class Account(client: Client) : Service(client) { phone: String, password: String, nestedType: Class, - ): io.appwrite.models.User { + ): io.appwrite.models.User { val apiPath = "/account/phone" val apiParams = mutableMapOf( - "phone" to phone, - "password" to password, + "phone" to phone, + "password" to password, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } - return client.call( + return client.call( "PATCH", apiPath, apiHeaders, @@ -836,11 +836,11 @@ class Account(client: Client) : Service(client) { suspend fun updatePhone( phone: String, password: String, - ): io.appwrite.models.User> = updatePhone( + ): io.appwrite.models.User> = updatePhone( phone, password, nestedType = classOf(), - ) + ) /** * Get account preferences @@ -851,19 +851,19 @@ class Account(client: Client) : Service(client) { */ suspend fun getPrefs( nestedType: Class, - ): io.appwrite.models.Preferences { + ): io.appwrite.models.Preferences { val apiPath = "/account/prefs" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Preferences.from(map = it as Map, nestedType) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -882,9 +882,9 @@ class Account(client: Client) : Service(client) { */ @Throws(AppwriteException::class) suspend fun getPrefs( - ): io.appwrite.models.Preferences> = getPrefs( + ): io.appwrite.models.Preferences> = getPrefs( nestedType = classOf(), - ) + ) /** * Update preferences @@ -897,20 +897,20 @@ class Account(client: Client) : Service(client) { suspend fun updatePrefs( prefs: Any, nestedType: Class, - ): io.appwrite.models.User { + ): io.appwrite.models.User { val apiPath = "/account/prefs" val apiParams = mutableMapOf( - "prefs" to prefs, + "prefs" to prefs, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } - return client.call( + return client.call( "PATCH", apiPath, apiHeaders, @@ -931,10 +931,10 @@ class Account(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun updatePrefs( prefs: Any, - ): io.appwrite.models.User> = updatePrefs( + ): io.appwrite.models.User> = updatePrefs( prefs, nestedType = classOf(), - ) + ) /** * Create password recovery @@ -948,21 +948,21 @@ class Account(client: Client) : Service(client) { suspend fun createRecovery( email: String, url: String, - ): io.appwrite.models.Token { + ): io.appwrite.models.Token { val apiPath = "/account/recovery" val apiParams = mutableMapOf( - "email" to email, - "url" to url, + "email" to email, + "url" to url, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -987,22 +987,22 @@ class Account(client: Client) : Service(client) { userId: String, secret: String, password: String, - ): io.appwrite.models.Token { + ): io.appwrite.models.Token { val apiPath = "/account/recovery" val apiParams = mutableMapOf( - "userId" to userId, - "secret" to secret, - "password" to password, + "userId" to userId, + "secret" to secret, + "password" to password, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } - return client.call( + return client.call( "PUT", apiPath, apiHeaders, @@ -1021,19 +1021,19 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.SessionList] */ suspend fun listSessions( - ): io.appwrite.models.SessionList { + ): io.appwrite.models.SessionList { val apiPath = "/account/sessions" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.SessionList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.SessionList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -1052,15 +1052,15 @@ class Account(client: Client) : Service(client) { * @return [Any] */ suspend fun deleteSessions( - ): Any { + ): Any { val apiPath = "/account/sessions" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - return client.call( + return client.call( "DELETE", apiPath, apiHeaders, @@ -1078,19 +1078,19 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.Session] */ suspend fun createAnonymousSession( - ): io.appwrite.models.Session { + ): io.appwrite.models.Session { val apiPath = "/account/sessions/anonymous" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -1113,21 +1113,21 @@ class Account(client: Client) : Service(client) { suspend fun createEmailPasswordSession( email: String, password: String, - ): io.appwrite.models.Session { + ): io.appwrite.models.Session { val apiPath = "/account/sessions/email" val apiParams = mutableMapOf( - "email" to email, - "password" to password, + "email" to email, + "password" to password, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -1150,21 +1150,21 @@ class Account(client: Client) : Service(client) { suspend fun updateMagicURLSession( userId: String, secret: String, - ): io.appwrite.models.Session { + ): io.appwrite.models.Session { val apiPath = "/account/sessions/magic-url" val apiParams = mutableMapOf( - "userId" to userId, - "secret" to secret, + "userId" to userId, + "secret" to secret, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } - return client.call( + return client.call( "PUT", apiPath, apiHeaders, @@ -1192,14 +1192,14 @@ class Account(client: Client) : Service(client) { success: String? = null, failure: String? = null, scopes: List? = null, - ) { + ) { val apiPath = "/account/sessions/oauth2/{provider}" .replace("{provider}", provider.value) val apiParams = mutableMapOf( - "success" to success, - "failure" to failure, - "scopes" to scopes, + "success" to success, + "failure" to failure, + "scopes" to scopes, "project" to client.config["project"], ) val apiQuery = mutableListOf() @@ -1240,7 +1240,7 @@ class Account(client: Client) : Service(client) { .domain(Uri.parse(client.endpoint).host!!) .httpOnly() .build() - + client.http.cookieJar.saveFromResponse( client.endpoint.toHttpUrl(), listOf(cookie) @@ -1261,21 +1261,21 @@ class Account(client: Client) : Service(client) { suspend fun updatePhoneSession( userId: String, secret: String, - ): io.appwrite.models.Session { + ): io.appwrite.models.Session { val apiPath = "/account/sessions/phone" val apiParams = mutableMapOf( - "userId" to userId, - "secret" to secret, + "userId" to userId, + "secret" to secret, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } - return client.call( + return client.call( "PUT", apiPath, apiHeaders, @@ -1298,21 +1298,21 @@ class Account(client: Client) : Service(client) { suspend fun createSession( userId: String, secret: String, - ): io.appwrite.models.Session { + ): io.appwrite.models.Session { val apiPath = "/account/sessions/token" val apiParams = mutableMapOf( - "userId" to userId, - "secret" to secret, + "userId" to userId, + "secret" to secret, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -1333,20 +1333,20 @@ class Account(client: Client) : Service(client) { */ suspend fun getSession( sessionId: String, - ): io.appwrite.models.Session { + ): io.appwrite.models.Session { val apiPath = "/account/sessions/{sessionId}" .replace("{sessionId}", sessionId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -1367,20 +1367,20 @@ class Account(client: Client) : Service(client) { */ suspend fun updateSession( sessionId: String, - ): io.appwrite.models.Session { + ): io.appwrite.models.Session { val apiPath = "/account/sessions/{sessionId}" .replace("{sessionId}", sessionId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Session.from(map = it as Map) } - return client.call( + return client.call( "PATCH", apiPath, apiHeaders, @@ -1401,16 +1401,16 @@ class Account(client: Client) : Service(client) { */ suspend fun deleteSession( sessionId: String, - ): Any { + ): Any { val apiPath = "/account/sessions/{sessionId}" .replace("{sessionId}", sessionId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - return client.call( + return client.call( "DELETE", apiPath, apiHeaders, @@ -1429,19 +1429,19 @@ class Account(client: Client) : Service(client) { */ suspend fun updateStatus( nestedType: Class, - ): io.appwrite.models.User { + ): io.appwrite.models.User { val apiPath = "/account/status" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @Suppress("UNCHECKED_CAST") io.appwrite.models.User.from(map = it as Map, nestedType) } - return client.call( + return client.call( "PATCH", apiPath, apiHeaders, @@ -1460,9 +1460,9 @@ class Account(client: Client) : Service(client) { */ @Throws(AppwriteException::class) suspend fun updateStatus( - ): io.appwrite.models.User> = updateStatus( + ): io.appwrite.models.User> = updateStatus( nestedType = classOf(), - ) + ) /** * Create push target @@ -1479,22 +1479,22 @@ class Account(client: Client) : Service(client) { targetId: String, identifier: String, providerId: String? = null, - ): io.appwrite.models.Target { + ): io.appwrite.models.Target { val apiPath = "/account/targets/push" val apiParams = mutableMapOf( - "targetId" to targetId, - "identifier" to identifier, - "providerId" to providerId, + "targetId" to targetId, + "identifier" to identifier, + "providerId" to providerId, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Target = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Target.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -1517,21 +1517,21 @@ class Account(client: Client) : Service(client) { suspend fun updatePushTarget( targetId: String, identifier: String, - ): io.appwrite.models.Target { + ): io.appwrite.models.Target { val apiPath = "/account/targets/{targetId}/push" .replace("{targetId}", targetId) val apiParams = mutableMapOf( - "identifier" to identifier, + "identifier" to identifier, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Target = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Target.from(map = it as Map) } - return client.call( + return client.call( "PUT", apiPath, apiHeaders, @@ -1552,16 +1552,16 @@ class Account(client: Client) : Service(client) { */ suspend fun deletePushTarget( targetId: String, - ): Any { + ): Any { val apiPath = "/account/targets/{targetId}/push" .replace("{targetId}", targetId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - return client.call( + return client.call( "DELETE", apiPath, apiHeaders, @@ -1586,22 +1586,22 @@ class Account(client: Client) : Service(client) { userId: String, email: String, phrase: Boolean? = null, - ): io.appwrite.models.Token { + ): io.appwrite.models.Token { val apiPath = "/account/tokens/email" val apiParams = mutableMapOf( - "userId" to userId, - "email" to email, - "phrase" to phrase, + "userId" to userId, + "email" to email, + "phrase" to phrase, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -1629,23 +1629,23 @@ class Account(client: Client) : Service(client) { email: String, url: String? = null, phrase: Boolean? = null, - ): io.appwrite.models.Token { + ): io.appwrite.models.Token { val apiPath = "/account/tokens/magic-url" val apiParams = mutableMapOf( - "userId" to userId, - "email" to email, - "url" to url, - "phrase" to phrase, + "userId" to userId, + "email" to email, + "url" to url, + "phrase" to phrase, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -1673,14 +1673,14 @@ class Account(client: Client) : Service(client) { success: String? = null, failure: String? = null, scopes: List? = null, - ) { + ) { val apiPath = "/account/tokens/oauth2/{provider}" .replace("{provider}", provider.value) val apiParams = mutableMapOf( - "success" to success, - "failure" to failure, - "scopes" to scopes, + "success" to success, + "failure" to failure, + "scopes" to scopes, "project" to client.config["project"], ) val apiQuery = mutableListOf() @@ -1721,7 +1721,7 @@ class Account(client: Client) : Service(client) { .domain(Uri.parse(client.endpoint).host!!) .httpOnly() .build() - + client.http.cookieJar.saveFromResponse( client.endpoint.toHttpUrl(), listOf(cookie) @@ -1742,21 +1742,21 @@ class Account(client: Client) : Service(client) { suspend fun createPhoneToken( userId: String, phone: String, - ): io.appwrite.models.Token { + ): io.appwrite.models.Token { val apiPath = "/account/tokens/phone" val apiParams = mutableMapOf( - "userId" to userId, - "phone" to phone, + "userId" to userId, + "phone" to phone, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -1777,20 +1777,20 @@ class Account(client: Client) : Service(client) { */ suspend fun createVerification( url: String, - ): io.appwrite.models.Token { + ): io.appwrite.models.Token { val apiPath = "/account/verification" val apiParams = mutableMapOf( - "url" to url, + "url" to url, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -1813,21 +1813,21 @@ class Account(client: Client) : Service(client) { suspend fun updateVerification( userId: String, secret: String, - ): io.appwrite.models.Token { + ): io.appwrite.models.Token { val apiPath = "/account/verification" val apiParams = mutableMapOf( - "userId" to userId, - "secret" to secret, + "userId" to userId, + "secret" to secret, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } - return client.call( + return client.call( "PUT", apiPath, apiHeaders, @@ -1846,19 +1846,19 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.Token] */ suspend fun createPhoneVerification( - ): io.appwrite.models.Token { + ): io.appwrite.models.Token { val apiPath = "/account/verification/phone" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -1881,21 +1881,21 @@ class Account(client: Client) : Service(client) { suspend fun updatePhoneVerification( userId: String, secret: String, - ): io.appwrite.models.Token { + ): io.appwrite.models.Token { val apiPath = "/account/verification/phone" val apiParams = mutableMapOf( - "userId" to userId, - "secret" to secret, + "userId" to userId, + "secret" to secret, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Token.from(map = it as Map) } - return client.call( + return client.call( "PUT", apiPath, apiHeaders, @@ -1906,4 +1906,4 @@ class Account(client: Client) : Service(client) { } -} +} \ 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 fb926f0..9913edc 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -34,14 +34,14 @@ class Avatars(client: Client) : Service(client) { width: Long? = null, height: Long? = null, quality: Long? = null, - ): ByteArray { + ): ByteArray { val apiPath = "/avatars/browsers/{code}" .replace("{code}", code.value) val apiParams = mutableMapOf( - "width" to width, - "height" to height, - "quality" to quality, + "width" to width, + "height" to height, + "quality" to quality, "project" to client.config["project"], ) return client.call( @@ -70,14 +70,14 @@ class Avatars(client: Client) : Service(client) { width: Long? = null, height: Long? = null, quality: Long? = null, - ): ByteArray { + ): ByteArray { val apiPath = "/avatars/credit-cards/{code}" .replace("{code}", code.value) val apiParams = mutableMapOf( - "width" to width, - "height" to height, - "quality" to quality, + "width" to width, + "height" to height, + "quality" to quality, "project" to client.config["project"], ) return client.call( @@ -99,11 +99,11 @@ class Avatars(client: Client) : Service(client) { */ suspend fun getFavicon( url: String, - ): ByteArray { + ): ByteArray { val apiPath = "/avatars/favicon" val apiParams = mutableMapOf( - "url" to url, + "url" to url, "project" to client.config["project"], ) return client.call( @@ -132,14 +132,14 @@ class Avatars(client: Client) : Service(client) { width: Long? = null, height: Long? = null, quality: Long? = null, - ): ByteArray { + ): ByteArray { val apiPath = "/avatars/flags/{code}" .replace("{code}", code.value) val apiParams = mutableMapOf( - "width" to width, - "height" to height, - "quality" to quality, + "width" to width, + "height" to height, + "quality" to quality, "project" to client.config["project"], ) return client.call( @@ -166,13 +166,13 @@ class Avatars(client: Client) : Service(client) { url: String, width: Long? = null, height: Long? = null, - ): ByteArray { + ): ByteArray { val apiPath = "/avatars/image" val apiParams = mutableMapOf( - "url" to url, - "width" to width, - "height" to height, + "url" to url, + "width" to width, + "height" to height, "project" to client.config["project"], ) return client.call( @@ -201,14 +201,14 @@ class Avatars(client: Client) : Service(client) { width: Long? = null, height: Long? = null, background: String? = null, - ): ByteArray { + ): ByteArray { val apiPath = "/avatars/initials" val apiParams = mutableMapOf( - "name" to name, - "width" to width, - "height" to height, - "background" to background, + "name" to name, + "width" to width, + "height" to height, + "background" to background, "project" to client.config["project"], ) return client.call( @@ -237,14 +237,14 @@ class Avatars(client: Client) : Service(client) { size: Long? = null, margin: Long? = null, download: Boolean? = null, - ): ByteArray { + ): ByteArray { val apiPath = "/avatars/qr" val apiParams = mutableMapOf( - "text" to text, - "size" to size, - "margin" to margin, - "download" to download, + "text" to text, + "size" to size, + "margin" to margin, + "download" to download, "project" to client.config["project"], ) return client.call( @@ -256,4 +256,4 @@ class Avatars(client: Client) : Service(client) { } -} +} \ 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 22d5375..70ecf23 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -31,22 +31,22 @@ class Databases(client: Client) : Service(client) { collectionId: String, queries: List? = null, nestedType: Class, - ): io.appwrite.models.DocumentList { + ): io.appwrite.models.DocumentList { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) val apiParams = mutableMapOf( - "queries" to queries, + "queries" to queries, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.DocumentList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.DocumentList.from(map = it as Map, nestedType) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -72,12 +72,12 @@ class Databases(client: Client) : Service(client) { databaseId: String, collectionId: String, queries: List? = null, - ): io.appwrite.models.DocumentList> = listDocuments( + ): io.appwrite.models.DocumentList> = listDocuments( databaseId, collectionId, queries, nestedType = classOf(), - ) + ) /** * Create document @@ -99,24 +99,24 @@ class Databases(client: Client) : Service(client) { data: Any, permissions: List? = null, nestedType: Class, - ): io.appwrite.models.Document { + ): io.appwrite.models.Document { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) val apiParams = mutableMapOf( - "documentId" to documentId, - "data" to data, - "permissions" to permissions, + "documentId" to documentId, + "data" to data, + "permissions" to permissions, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Document.from(map = it as Map, nestedType) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -146,14 +146,14 @@ class Databases(client: Client) : Service(client) { documentId: String, data: Any, permissions: List? = null, - ): io.appwrite.models.Document> = createDocument( + ): io.appwrite.models.Document> = createDocument( databaseId, collectionId, documentId, data, permissions, nestedType = classOf(), - ) + ) /** * Get document @@ -173,23 +173,23 @@ class Databases(client: Client) : Service(client) { documentId: String, queries: List? = null, nestedType: Class, - ): io.appwrite.models.Document { + ): io.appwrite.models.Document { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) .replace("{documentId}", documentId) val apiParams = mutableMapOf( - "queries" to queries, + "queries" to queries, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Document.from(map = it as Map, nestedType) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -217,13 +217,13 @@ class Databases(client: Client) : Service(client) { collectionId: String, documentId: String, queries: List? = null, - ): io.appwrite.models.Document> = getDocument( + ): io.appwrite.models.Document> = getDocument( databaseId, collectionId, documentId, queries, nestedType = classOf(), - ) + ) /** * Update document @@ -245,24 +245,24 @@ class Databases(client: Client) : Service(client) { data: Any? = null, permissions: List? = null, nestedType: Class, - ): io.appwrite.models.Document { + ): io.appwrite.models.Document { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) .replace("{documentId}", documentId) val apiParams = mutableMapOf( - "data" to data, - "permissions" to permissions, + "data" to data, + "permissions" to permissions, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Document.from(map = it as Map, nestedType) } - return client.call( + return client.call( "PATCH", apiPath, apiHeaders, @@ -292,14 +292,14 @@ class Databases(client: Client) : Service(client) { documentId: String, data: Any? = null, permissions: List? = null, - ): io.appwrite.models.Document> = updateDocument( + ): io.appwrite.models.Document> = updateDocument( databaseId, collectionId, documentId, data, permissions, nestedType = classOf(), - ) + ) /** * Delete document @@ -315,7 +315,7 @@ class Databases(client: Client) : Service(client) { databaseId: String, collectionId: String, documentId: String, - ): Any { + ): Any { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) @@ -323,10 +323,10 @@ class Databases(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - return client.call( + return client.call( "DELETE", apiPath, apiHeaders, @@ -336,4 +336,4 @@ class Databases(client: Client) : Service(client) { } -} +} \ 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 59809dc..d31e853 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -30,22 +30,22 @@ class Functions(client: Client) : Service(client) { functionId: String, queries: List? = null, search: String? = null, - ): io.appwrite.models.ExecutionList { + ): io.appwrite.models.ExecutionList { val apiPath = "/functions/{functionId}/executions" .replace("{functionId}", functionId) val apiParams = mutableMapOf( - "queries" to queries, - "search" to search, + "queries" to queries, + "search" to search, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.ExecutionList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.ExecutionList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -73,33 +73,32 @@ class Functions(client: Client) : Service(client) { @JvmOverloads suspend fun createExecution( functionId: String, - body: Payload? = null, + body: String? = null, async: Boolean? = null, path: String? = null, method: io.appwrite.enums.ExecutionMethod? = null, headers: Any? = null, scheduledAt: String? = null, - ): io.appwrite.models.Execution { + ): io.appwrite.models.Execution { val apiPath = "/functions/{functionId}/executions" .replace("{functionId}", functionId) val apiParams = mutableMapOf( - "body" to (body?.toBinary() ?: ""), - "async" to async, - "path" to path, - "method" to method, - "headers" to headers, - "scheduledAt" to scheduledAt, + "body" to body, + "async" to async, + "path" to path, + "method" to method, + "headers" to headers, + "scheduledAt" to scheduledAt, ) - val apiHeaders = mutableMapOf( - "content-type" to "multipart/form-data", - "accept" to "multipart/form-data", + val apiHeaders = mutableMapOf( + "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Execution = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Execution.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -122,21 +121,21 @@ class Functions(client: Client) : Service(client) { suspend fun getExecution( functionId: String, executionId: String, - ): io.appwrite.models.Execution { + ): io.appwrite.models.Execution { val apiPath = "/functions/{functionId}/executions/{executionId}" .replace("{functionId}", functionId) .replace("{executionId}", executionId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Execution = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Execution.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -147,4 +146,4 @@ class Functions(client: Client) : Service(client) { } -} +} \ 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 index 1052e67..6c977a2 100644 --- a/library/src/main/java/io/appwrite/services/Graphql.kt +++ b/library/src/main/java/io/appwrite/services/Graphql.kt @@ -25,20 +25,20 @@ class Graphql(client: Client) : Service(client) { */ suspend fun query( query: Any, - ): Any { + ): Any { val apiPath = "/graphql" val apiParams = mutableMapOf( - "query" to query, + "query" to query, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "x-sdk-graphql" to "true", "content-type" to "application/json", ) val converter: (Any) -> Any = { it } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -59,20 +59,20 @@ class Graphql(client: Client) : Service(client) { */ suspend fun mutation( query: Any, - ): Any { + ): Any { val apiPath = "/graphql/mutation" val apiParams = mutableMapOf( - "query" to query, + "query" to query, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "x-sdk-graphql" to "true", "content-type" to "application/json", ) val converter: (Any) -> Any = { it } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -83,4 +83,4 @@ class Graphql(client: Client) : Service(client) { } -} +} \ 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 097e1f7..01b3017 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -23,19 +23,19 @@ class Locale(client: Client) : Service(client) { * @return [io.appwrite.models.Locale] */ suspend fun get( - ): io.appwrite.models.Locale { + ): io.appwrite.models.Locale { val apiPath = "/locale" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Locale = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Locale.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -54,19 +54,19 @@ class Locale(client: Client) : Service(client) { * @return [io.appwrite.models.LocaleCodeList] */ suspend fun listCodes( - ): io.appwrite.models.LocaleCodeList { + ): io.appwrite.models.LocaleCodeList { val apiPath = "/locale/codes" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LocaleCodeList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.LocaleCodeList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -85,19 +85,19 @@ class Locale(client: Client) : Service(client) { * @return [io.appwrite.models.ContinentList] */ suspend fun listContinents( - ): io.appwrite.models.ContinentList { + ): io.appwrite.models.ContinentList { val apiPath = "/locale/continents" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.ContinentList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.ContinentList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -116,19 +116,19 @@ class Locale(client: Client) : Service(client) { * @return [io.appwrite.models.CountryList] */ suspend fun listCountries( - ): io.appwrite.models.CountryList { + ): io.appwrite.models.CountryList { val apiPath = "/locale/countries" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CountryList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.CountryList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -147,19 +147,19 @@ class Locale(client: Client) : Service(client) { * @return [io.appwrite.models.CountryList] */ suspend fun listCountriesEU( - ): io.appwrite.models.CountryList { + ): io.appwrite.models.CountryList { val apiPath = "/locale/countries/eu" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CountryList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.CountryList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -178,19 +178,19 @@ class Locale(client: Client) : Service(client) { * @return [io.appwrite.models.PhoneList] */ suspend fun listCountriesPhones( - ): io.appwrite.models.PhoneList { + ): io.appwrite.models.PhoneList { val apiPath = "/locale/countries/phones" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.PhoneList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.PhoneList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -209,19 +209,19 @@ class Locale(client: Client) : Service(client) { * @return [io.appwrite.models.CurrencyList] */ suspend fun listCurrencies( - ): io.appwrite.models.CurrencyList { + ): io.appwrite.models.CurrencyList { val apiPath = "/locale/currencies" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CurrencyList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.CurrencyList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -240,19 +240,19 @@ class Locale(client: Client) : Service(client) { * @return [io.appwrite.models.LanguageList] */ suspend fun listLanguages( - ): io.appwrite.models.LanguageList { + ): io.appwrite.models.LanguageList { val apiPath = "/locale/languages" val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LanguageList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.LanguageList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -263,4 +263,4 @@ class Locale(client: Client) : Service(client) { } -} +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Messaging.kt b/library/src/main/java/io/appwrite/services/Messaging.kt index 5c6504f..baca2c4 100644 --- a/library/src/main/java/io/appwrite/services/Messaging.kt +++ b/library/src/main/java/io/appwrite/services/Messaging.kt @@ -29,22 +29,22 @@ class Messaging(client: Client) : Service(client) { topicId: String, subscriberId: String, targetId: String, - ): io.appwrite.models.Subscriber { + ): io.appwrite.models.Subscriber { val apiPath = "/messaging/topics/{topicId}/subscribers" .replace("{topicId}", topicId) val apiParams = mutableMapOf( - "subscriberId" to subscriberId, - "targetId" to targetId, + "subscriberId" to subscriberId, + "targetId" to targetId, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Subscriber = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Subscriber.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -67,17 +67,17 @@ class Messaging(client: Client) : Service(client) { suspend fun deleteSubscriber( topicId: String, subscriberId: String, - ): Any { + ): Any { val apiPath = "/messaging/topics/{topicId}/subscribers/{subscriberId}" .replace("{topicId}", topicId) .replace("{subscriberId}", subscriberId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - return client.call( + return client.call( "DELETE", apiPath, apiHeaders, @@ -87,4 +87,4 @@ class Messaging(client: Client) : Service(client) { } -} +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Realtime.kt b/library/src/main/java/io/appwrite/services/Realtime.kt index 1bffd3a..605be89 100644 --- a/library/src/main/java/io/appwrite/services/Realtime.kt +++ b/library/src/main/java/io/appwrite/services/Realtime.kt @@ -29,6 +29,8 @@ class Realtime(client: Client) : Service(client), CoroutineScope { private companion object { private const val TYPE_ERROR = "error" private const val TYPE_EVENT = "event" + private const val TYPE_PONG = "pong" + private const val HEARTBEAT_INTERVAL = 20_000L // 20 seconds private const val DEBOUNCE_MILLIS = 1L @@ -40,6 +42,7 @@ class Realtime(client: Client) : Service(client), CoroutineScope { private var reconnectAttempts = 0 private var subscriptionsCounter = 0 private var reconnect = true + private var heartbeatJob: Job? = null } private fun createSocket() { @@ -80,9 +83,25 @@ class Realtime(client: Client) : Service(client), CoroutineScope { } private fun closeSocket() { + stopHeartbeat() socket?.close(RealtimeCode.POLICY_VIOLATION.value, null) } + private fun startHeartbeat() { + stopHeartbeat() + heartbeatJob = launch { + while (isActive) { + delay(HEARTBEAT_INTERVAL) + socket?.send("""{"type":"ping"}""") + } + } + } + + private fun stopHeartbeat() { + heartbeatJob?.cancel() + heartbeatJob = null + } + private fun getTimeout() = when { reconnectAttempts < 5 -> 1000L reconnectAttempts < 15 -> 5000L @@ -145,6 +164,7 @@ class Realtime(client: Client) : Service(client), CoroutineScope { override fun onOpen(webSocket: WebSocket, response: Response) { super.onOpen(webSocket, response) reconnectAttempts = 0 + startHeartbeat() } override fun onMessage(webSocket: WebSocket, text: String) { @@ -181,6 +201,7 @@ class Realtime(client: Client) : Service(client), CoroutineScope { override fun onClosing(webSocket: WebSocket, code: Int, reason: String) { super.onClosing(webSocket, code, reason) + stopHeartbeat() if (!reconnect || code == RealtimeCode.POLICY_VIOLATION.value) { reconnect = true return @@ -203,6 +224,7 @@ class Realtime(client: Client) : Service(client), CoroutineScope { override fun onFailure(webSocket: WebSocket, t: Throwable, response: Response?) { super.onFailure(webSocket, t, response) + stopHeartbeat() t.printStackTrace() } } diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index c30d37c..1f990c2 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -32,22 +32,22 @@ class Storage(client: Client) : Service(client) { bucketId: String, queries: List? = null, search: String? = null, - ): io.appwrite.models.FileList { + ): io.appwrite.models.FileList { val apiPath = "/storage/buckets/{bucketId}/files" .replace("{bucketId}", bucketId) val apiParams = mutableMapOf( - "queries" to queries, - "search" to search, + "queries" to queries, + "search" to search, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.FileList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.FileList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -73,26 +73,26 @@ class Storage(client: Client) : Service(client) { suspend fun createFile( bucketId: String, fileId: String, - file: Payload, + file: InputFile, permissions: List? = null, - onProgress: ((UploadProgress) -> Unit)? = null + onProgress: ((UploadProgress) -> Unit)? = null ): io.appwrite.models.File { val apiPath = "/storage/buckets/{bucketId}/files" .replace("{bucketId}", bucketId) val apiParams = mutableMapOf( - "fileId" to fileId, - "file" to file, - "permissions" to permissions, + "fileId" to fileId, + "file" to file, + "permissions" to permissions, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "multipart/form-data", ) val converter: (Any) -> io.appwrite.models.File = { @Suppress("UNCHECKED_CAST") io.appwrite.models.File.from(map = it as Map) } - val idParamName: String? = "fileId" + val idParamName: String? = "fileId" val paramName = "file" return client.chunkedUpload( apiPath, @@ -119,21 +119,21 @@ class Storage(client: Client) : Service(client) { suspend fun getFile( bucketId: String, fileId: String, - ): io.appwrite.models.File { + ): io.appwrite.models.File { val apiPath = "/storage/buckets/{bucketId}/files/{fileId}" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.File = { @Suppress("UNCHECKED_CAST") io.appwrite.models.File.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -161,23 +161,23 @@ class Storage(client: Client) : Service(client) { fileId: String, name: String? = null, permissions: List? = null, - ): io.appwrite.models.File { + ): io.appwrite.models.File { val apiPath = "/storage/buckets/{bucketId}/files/{fileId}" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) val apiParams = mutableMapOf( - "name" to name, - "permissions" to permissions, + "name" to name, + "permissions" to permissions, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.File = { @Suppress("UNCHECKED_CAST") io.appwrite.models.File.from(map = it as Map) } - return client.call( + return client.call( "PUT", apiPath, apiHeaders, @@ -200,17 +200,17 @@ class Storage(client: Client) : Service(client) { suspend fun deleteFile( bucketId: String, fileId: String, - ): Any { + ): Any { val apiPath = "/storage/buckets/{bucketId}/files/{fileId}" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - return client.call( + return client.call( "DELETE", apiPath, apiHeaders, @@ -232,7 +232,7 @@ class Storage(client: Client) : Service(client) { suspend fun getFileDownload( bucketId: String, fileId: String, - ): ByteArray { + ): ByteArray { val apiPath = "/storage/buckets/{bucketId}/files/{fileId}/download" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) @@ -284,23 +284,23 @@ class Storage(client: Client) : Service(client) { rotation: Long? = null, background: String? = null, output: io.appwrite.enums.ImageFormat? = null, - ): ByteArray { + ): ByteArray { val apiPath = "/storage/buckets/{bucketId}/files/{fileId}/preview" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) val apiParams = mutableMapOf( - "width" to width, - "height" to height, - "gravity" to gravity, - "quality" to quality, - "borderWidth" to borderWidth, - "borderColor" to borderColor, - "borderRadius" to borderRadius, - "opacity" to opacity, - "rotation" to rotation, - "background" to background, - "output" to output, + "width" to width, + "height" to height, + "gravity" to gravity, + "quality" to quality, + "borderWidth" to borderWidth, + "borderColor" to borderColor, + "borderRadius" to borderRadius, + "opacity" to opacity, + "rotation" to rotation, + "background" to background, + "output" to output, "project" to client.config["project"], ) return client.call( @@ -324,7 +324,7 @@ class Storage(client: Client) : Service(client) { suspend fun getFileView( bucketId: String, fileId: String, - ): ByteArray { + ): ByteArray { val apiPath = "/storage/buckets/{bucketId}/files/{fileId}/view" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) @@ -341,4 +341,4 @@ class Storage(client: Client) : Service(client) { } -} +} \ 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 cf611ba..fd0ae92 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -29,21 +29,21 @@ class Teams(client: Client) : Service(client) { queries: List? = null, search: String? = null, nestedType: Class, - ): io.appwrite.models.TeamList { + ): io.appwrite.models.TeamList { val apiPath = "/teams" val apiParams = mutableMapOf( - "queries" to queries, - "search" to search, + "queries" to queries, + "search" to search, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.TeamList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.TeamList.from(map = it as Map, nestedType) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -67,11 +67,11 @@ class Teams(client: Client) : Service(client) { suspend fun list( queries: List? = null, search: String? = null, - ): io.appwrite.models.TeamList> = list( + ): io.appwrite.models.TeamList> = list( queries, search, nestedType = classOf(), - ) + ) /** * Create team @@ -89,22 +89,22 @@ class Teams(client: Client) : Service(client) { name: String, roles: List? = null, nestedType: Class, - ): io.appwrite.models.Team { + ): io.appwrite.models.Team { val apiPath = "/teams" val apiParams = mutableMapOf( - "teamId" to teamId, - "name" to name, - "roles" to roles, + "teamId" to teamId, + "name" to name, + "roles" to roles, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Team = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Team.from(map = it as Map, nestedType) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -130,12 +130,12 @@ class Teams(client: Client) : Service(client) { teamId: String, name: String, roles: List? = null, - ): io.appwrite.models.Team> = create( + ): io.appwrite.models.Team> = create( teamId, name, roles, nestedType = classOf(), - ) + ) /** * Get team @@ -148,20 +148,20 @@ class Teams(client: Client) : Service(client) { suspend fun get( teamId: String, nestedType: Class, - ): io.appwrite.models.Team { + ): io.appwrite.models.Team { val apiPath = "/teams/{teamId}" .replace("{teamId}", teamId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Team = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Team.from(map = it as Map, nestedType) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -182,10 +182,10 @@ class Teams(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun get( teamId: String, - ): io.appwrite.models.Team> = get( + ): io.appwrite.models.Team> = get( teamId, nestedType = classOf(), - ) + ) /** * Update name @@ -200,21 +200,21 @@ class Teams(client: Client) : Service(client) { teamId: String, name: String, nestedType: Class, - ): io.appwrite.models.Team { + ): io.appwrite.models.Team { val apiPath = "/teams/{teamId}" .replace("{teamId}", teamId) val apiParams = mutableMapOf( - "name" to name, + "name" to name, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Team = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Team.from(map = it as Map, nestedType) } - return client.call( + return client.call( "PUT", apiPath, apiHeaders, @@ -237,11 +237,11 @@ class Teams(client: Client) : Service(client) { suspend fun updateName( teamId: String, name: String, - ): io.appwrite.models.Team> = updateName( + ): io.appwrite.models.Team> = updateName( teamId, name, nestedType = classOf(), - ) + ) /** * Delete team @@ -253,16 +253,16 @@ class Teams(client: Client) : Service(client) { */ suspend fun delete( teamId: String, - ): Any { + ): Any { val apiPath = "/teams/{teamId}" .replace("{teamId}", teamId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - return client.call( + return client.call( "DELETE", apiPath, apiHeaders, @@ -287,22 +287,22 @@ class Teams(client: Client) : Service(client) { teamId: String, queries: List? = null, search: String? = null, - ): io.appwrite.models.MembershipList { + ): io.appwrite.models.MembershipList { val apiPath = "/teams/{teamId}/memberships" .replace("{teamId}", teamId) val apiParams = mutableMapOf( - "queries" to queries, - "search" to search, + "queries" to queries, + "search" to search, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MembershipList = { @Suppress("UNCHECKED_CAST") io.appwrite.models.MembershipList.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -336,26 +336,26 @@ class Teams(client: Client) : Service(client) { phone: String? = null, url: String? = null, name: String? = null, - ): io.appwrite.models.Membership { + ): io.appwrite.models.Membership { val apiPath = "/teams/{teamId}/memberships" .replace("{teamId}", teamId) val apiParams = mutableMapOf( - "email" to email, - "userId" to userId, - "phone" to phone, - "roles" to roles, - "url" to url, - "name" to name, - ) - val apiHeaders = mutableMapOf( + "email" to email, + "userId" to userId, + "phone" to phone, + "roles" to roles, + "url" to url, + "name" to name, + ) + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Membership.from(map = it as Map) } - return client.call( + return client.call( "POST", apiPath, apiHeaders, @@ -378,21 +378,21 @@ class Teams(client: Client) : Service(client) { suspend fun getMembership( teamId: String, membershipId: String, - ): io.appwrite.models.Membership { + ): io.appwrite.models.Membership { val apiPath = "/teams/{teamId}/memberships/{membershipId}" .replace("{teamId}", teamId) .replace("{membershipId}", membershipId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Membership.from(map = it as Map) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -417,22 +417,22 @@ class Teams(client: Client) : Service(client) { teamId: String, membershipId: String, roles: List, - ): io.appwrite.models.Membership { + ): io.appwrite.models.Membership { val apiPath = "/teams/{teamId}/memberships/{membershipId}" .replace("{teamId}", teamId) .replace("{membershipId}", membershipId) val apiParams = mutableMapOf( - "roles" to roles, + "roles" to roles, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Membership.from(map = it as Map) } - return client.call( + return client.call( "PATCH", apiPath, apiHeaders, @@ -455,17 +455,17 @@ class Teams(client: Client) : Service(client) { suspend fun deleteMembership( teamId: String, membershipId: String, - ): Any { + ): Any { val apiPath = "/teams/{teamId}/memberships/{membershipId}" .replace("{teamId}", teamId) .replace("{membershipId}", membershipId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - return client.call( + return client.call( "DELETE", apiPath, apiHeaders, @@ -491,23 +491,23 @@ class Teams(client: Client) : Service(client) { membershipId: String, userId: String, secret: String, - ): io.appwrite.models.Membership { + ): io.appwrite.models.Membership { val apiPath = "/teams/{teamId}/memberships/{membershipId}/status" .replace("{teamId}", teamId) .replace("{membershipId}", membershipId) val apiParams = mutableMapOf( - "userId" to userId, - "secret" to secret, + "userId" to userId, + "secret" to secret, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Membership.from(map = it as Map) } - return client.call( + return client.call( "PATCH", apiPath, apiHeaders, @@ -529,20 +529,20 @@ class Teams(client: Client) : Service(client) { suspend fun getPrefs( teamId: String, nestedType: Class, - ): io.appwrite.models.Preferences { + ): io.appwrite.models.Preferences { val apiPath = "/teams/{teamId}/prefs" .replace("{teamId}", teamId) val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Preferences.from(map = it as Map, nestedType) } - return client.call( + return client.call( "GET", apiPath, apiHeaders, @@ -563,10 +563,10 @@ class Teams(client: Client) : Service(client) { @Throws(AppwriteException::class) suspend fun getPrefs( teamId: String, - ): io.appwrite.models.Preferences> = getPrefs( + ): io.appwrite.models.Preferences> = getPrefs( teamId, nestedType = classOf(), - ) + ) /** * Update preferences @@ -581,21 +581,21 @@ class Teams(client: Client) : Service(client) { teamId: String, prefs: Any, nestedType: Class, - ): io.appwrite.models.Preferences { + ): io.appwrite.models.Preferences { val apiPath = "/teams/{teamId}/prefs" .replace("{teamId}", teamId) val apiParams = mutableMapOf( - "prefs" to prefs, + "prefs" to prefs, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Preferences.from(map = it as Map, nestedType) } - return client.call( + return client.call( "PUT", apiPath, apiHeaders, @@ -618,10 +618,10 @@ class Teams(client: Client) : Service(client) { suspend fun updatePrefs( teamId: String, prefs: Any, - ): io.appwrite.models.Preferences> = updatePrefs( + ): io.appwrite.models.Preferences> = updatePrefs( teamId, prefs, nestedType = classOf(), - ) + ) -} +} \ No newline at end of file From 0a2e764cae754b8fb6087dd886b24fc81b00ee21 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 13 Dec 2024 13:23:34 +0000 Subject: [PATCH 089/118] feat: 1.6.x --- library/src/main/java/io/appwrite/models/Membership.kt | 6 +++--- library/src/main/java/io/appwrite/models/Target.kt | 8 ++++++++ library/src/main/java/io/appwrite/services/Teams.kt | 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/library/src/main/java/io/appwrite/models/Membership.kt b/library/src/main/java/io/appwrite/models/Membership.kt index 1f20394..4a899ee 100644 --- a/library/src/main/java/io/appwrite/models/Membership.kt +++ b/library/src/main/java/io/appwrite/models/Membership.kt @@ -32,13 +32,13 @@ data class Membership( val userId: String, /** - * User name. + * User name. Hide this attribute by toggling membership privacy in the Console. */ @SerializedName("userName") val userName: String, /** - * User email address. + * User email address. Hide this attribute by toggling membership privacy in the Console. */ @SerializedName("userEmail") val userEmail: String, @@ -74,7 +74,7 @@ data class Membership( val confirm: Boolean, /** - * Multi factor authentication status, true if the user has MFA enabled or false otherwise. + * Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. */ @SerializedName("mfa") val mfa: Boolean, diff --git a/library/src/main/java/io/appwrite/models/Target.kt b/library/src/main/java/io/appwrite/models/Target.kt index bd4d207..54b4694 100644 --- a/library/src/main/java/io/appwrite/models/Target.kt +++ b/library/src/main/java/io/appwrite/models/Target.kt @@ -55,6 +55,12 @@ data class Target( @SerializedName("identifier") val identifier: String, + /** + * Is the target expired. + */ + @SerializedName("expired") + val expired: Boolean, + ) { fun toMap(): Map = mapOf( "\$id" to id as Any, @@ -65,6 +71,7 @@ data class Target( "providerId" to providerId as Any, "providerType" to providerType as Any, "identifier" to identifier as Any, + "expired" to expired as Any, ) companion object { @@ -81,6 +88,7 @@ data class Target( providerId = map["providerId"] as? String?, providerType = map["providerType"] as String, identifier = map["identifier"] as String, + expired = map["expired"] as Boolean, ) } } \ 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 fd0ae92..b586f11 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -275,7 +275,7 @@ class Teams(client: Client) : Service(client) { /** * 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. Hide sensitive attributes from the response by toggling membership privacy in the Console. * * @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/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm @@ -369,7 +369,7 @@ class Teams(client: Client) : Service(client) { /** * 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. Hide sensitive attributes from the response by toggling membership privacy in the Console. * * @param teamId Team ID. * @param membershipId Membership ID. From 90441670b3534ba78fc96f23ada5d13a6eb2170d Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Tue, 17 Dec 2024 11:54:48 +0000 Subject: [PATCH 090/118] chore: regen --- README.md | 4 ++-- library/src/main/java/io/appwrite/Client.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f8dab1a..338b53e 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:6.0.0") +implementation("io.appwrite:sdk-for-android:6.1.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 6.0.0 + 6.1.0 ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 93a3e06..e2a48bb 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -86,7 +86,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "6.0.0", + "x-sdk-version" to "6.1.0", "x-appwrite-response-format" to "1.6.0" ) config = mutableMapOf() From bd4045aa22ab9ce65dc11589cc50722d5e9101f3 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Tue, 28 Jan 2025 16:46:44 +0000 Subject: [PATCH 091/118] fix: chunked upload, pong error --- LICENSE.md | 2 +- README.md | 6 +- library/src/main/java/io/appwrite/Client.kt | 65 +++++++++++++------ .../java/io/appwrite/enums/ImageFormat.kt | 2 + .../java/io/appwrite/models/RealtimeModels.kt | 2 +- .../main/java/io/appwrite/services/Account.kt | 19 ++++-- .../java/io/appwrite/services/Realtime.kt | 5 +- 7 files changed, 68 insertions(+), 33 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index 5479bb8..c1602fc 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2024 Appwrite (https://appwrite.io) and individual contributors. +Copyright (c) 2025 Appwrite (https://appwrite.io) and individual contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/README.md b/README.md index 338b53e..957018d 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![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.6.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.6.1-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) @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:6.1.0") +implementation("io.appwrite:sdk-for-android:6.1.1") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 6.1.0 + 6.1.1 ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index e2a48bb..b7d698e 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -60,7 +60,7 @@ class Client @JvmOverloads constructor( internal lateinit var http: OkHttpClient internal val headers: MutableMap - + val config: MutableMap internal val cookieJar = ListenableCookieJar(CookieManager( @@ -86,11 +86,11 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "6.1.0", + "x-sdk-version" to "6.1.1", "x-appwrite-response-format" to "1.6.0" ) config = mutableMapOf() - + setSelfSigned(selfSigned) } @@ -154,10 +154,10 @@ class Client @JvmOverloads constructor( /** * Set self Signed - * + * * @param status * - * @return this + * @return this */ fun setSelfSigned(status: Boolean): Client { selfSigned = status @@ -206,10 +206,10 @@ class Client @JvmOverloads constructor( /** * Set endpoint and realtime endpoint. - * + * * @param endpoint * - * @return this + * @return this */ fun setEndpoint(endpoint: String): Client { this.endpoint = endpoint @@ -235,32 +235,51 @@ class Client @JvmOverloads constructor( /** * Add Header - * + * * @param key * @param value * - * @return this + * @return this */ fun addHeader(key: String, value: String): Client { headers[key] = value return this } + /** + * Sends a "ping" request to Appwrite to verify connectivity. + * + * @return String + */ + suspend fun ping(): String { + val apiPath = "/ping" + val apiParams = mutableMapOf() + val apiHeaders = mutableMapOf("content-type" to "application/json") + + return call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = String::class.java + ) + } + /** * Send the HTTP request - * + * * @param method * @param path * @param headers * @param params * - * @return [T] + * @return [T] */ @Throws(AppwriteException::class) suspend fun call( - method: String, - path: String, - headers: Map = mapOf(), + method: String, + path: String, + headers: Map = mapOf(), params: Map = mapOf(), responseType: Class, converter: ((Any) -> T)? = null @@ -398,7 +417,7 @@ class Client @JvmOverloads constructor( var offset = 0L var result: Map<*, *>? = null - if (idParamName?.isNotEmpty() == true && params[idParamName] != "unique()") { + if (idParamName?.isNotEmpty() == true) { // Make a request to check if a file already exists val current = call( method = "GET", @@ -495,14 +514,14 @@ class Client @JvmOverloads constructor( .charStream() .buffered() .use(BufferedReader::readText) - + val error = if (response.headers["content-type"]?.contains("application/json") == true) { val map = body.fromJson>() AppwriteException( - map["message"] as? String ?: "", + map["message"] as? String ?: "", (map["code"] as Number).toInt(), - map["type"] as? String ?: "", + map["type"] as? String ?: "", body ) } else { @@ -524,6 +543,14 @@ class Client @JvmOverloads constructor( it.resume(true as T) return } + responseType == String::class.java -> { + val body = response.body!! + .charStream() + .buffered() + .use(BufferedReader::readText) + it.resume(body as T) + return + } responseType == ByteArray::class.java -> { it.resume(response.body!! .byteStream() @@ -554,4 +581,4 @@ class Client @JvmOverloads constructor( } }) } -} \ No newline at end of file +} diff --git a/library/src/main/java/io/appwrite/enums/ImageFormat.kt b/library/src/main/java/io/appwrite/enums/ImageFormat.kt index 25eea90..7249f2a 100644 --- a/library/src/main/java/io/appwrite/enums/ImageFormat.kt +++ b/library/src/main/java/io/appwrite/enums/ImageFormat.kt @@ -13,6 +13,8 @@ enum class ImageFormat(val value: String) { PNG("png"), @SerializedName("webp") WEBP("webp"), + @SerializedName("heic") + HEIC("heic"), @SerializedName("avif") AVIF("avif"); diff --git a/library/src/main/java/io/appwrite/models/RealtimeModels.kt b/library/src/main/java/io/appwrite/models/RealtimeModels.kt index bdd8752..cc1af63 100644 --- a/library/src/main/java/io/appwrite/models/RealtimeModels.kt +++ b/library/src/main/java/io/appwrite/models/RealtimeModels.kt @@ -17,7 +17,7 @@ data class RealtimeCallback( open class RealtimeResponse( val type: String, - val data: Any + val data: Any? ) data class RealtimeResponseEvent( diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 6f4cbd8..cb22b33 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -529,12 +529,12 @@ class Account(client: Client) : Service(client) { * * @param challengeId ID of the challenge. * @param otp Valid verification token. - * @return [Any] + * @return [io.appwrite.models.Session] */ suspend fun updateMfaChallenge( challengeId: String, otp: String, - ): Any { + ): io.appwrite.models.Session { val apiPath = "/account/mfa/challenge" val apiParams = mutableMapOf( @@ -544,12 +544,17 @@ class Account(client: Client) : Service(client) { val apiHeaders = mutableMapOf( "content-type" to "application/json", ) + val converter: (Any) -> io.appwrite.models.Session = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Session.from(map = it as Map) + } return client.call( "PUT", apiPath, apiHeaders, apiParams, - responseType = Any::class.java, + responseType = io.appwrite.models.Session::class.java, + converter, ) } @@ -1467,7 +1472,7 @@ class Account(client: Client) : Service(client) { /** * Create push target * - * + * Use this endpoint to register a device for push notifications. Provide a target ID (custom or generated using ID.unique()), a device identifier (usually a device token), and optionally specify which provider should send notifications to this target. The target is automatically linked to the current session and includes device information like brand and model. * * @param targetId Target ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 identifier The target identifier (token, email, phone etc.) @@ -1508,7 +1513,7 @@ class Account(client: Client) : Service(client) { /** * Update push target * - * + * Update the currently logged in user's push notification target. You can modify the target's identifier (device token) and provider ID (token, email, phone etc.). The target must exist and belong to the current user. If you change the provider ID, notifications will be sent through the new messaging provider instead. * * @param targetId Target ID. * @param identifier The target identifier (token, email, phone etc.) @@ -1545,7 +1550,7 @@ class Account(client: Client) : Service(client) { /** * Delete push target * - * + * Delete a push notification target for the currently logged in user. After deletion, the device will no longer receive push notifications. The target must exist and belong to the current user. * * @param targetId Target ID. * @return [Any] @@ -1615,7 +1620,7 @@ class Account(client: Client) : Service(client) { /** * Create magic URL token * - * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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. diff --git a/library/src/main/java/io/appwrite/services/Realtime.kt b/library/src/main/java/io/appwrite/services/Realtime.kt index 605be89..b06eacf 100644 --- a/library/src/main/java/io/appwrite/services/Realtime.kt +++ b/library/src/main/java/io/appwrite/services/Realtime.kt @@ -175,16 +175,17 @@ class Realtime(client: Client) : Service(client), CoroutineScope { when (message.type) { TYPE_ERROR -> handleResponseError(message) TYPE_EVENT -> handleResponseEvent(message) + TYPE_PONG -> {} } } } private fun handleResponseError(message: RealtimeResponse) { - throw message.data.jsonCast() + throw message.data?.jsonCast() ?: RuntimeException("Data is not present") } private suspend fun handleResponseEvent(message: RealtimeResponse) { - val event = message.data.jsonCast>() + val event = message.data?.jsonCast>() ?: return if (event.channels.isEmpty()) { return } From 645f2a22009f5810da0b3fa9129b19435aa68469 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Wed, 29 Jan 2025 08:02:12 +0000 Subject: [PATCH 092/118] chore: version bump --- README.md | 4 ++-- library/src/main/java/io/appwrite/Client.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 957018d..0698a2c 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:6.1.1") +implementation("io.appwrite:sdk-for-android:7.0.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 6.1.1 + 7.0.0 ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index b7d698e..409dc92 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -86,7 +86,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "6.1.1", + "x-sdk-version" to "7.0.0", "x-appwrite-response-format" to "1.6.0" ) config = mutableMapOf() From b23d6bd1c2fe77e66a7eef81c22bb2e6c25df08a Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Thu, 17 Apr 2025 19:46:56 +0100 Subject: [PATCH 093/118] fix: remove content-type from GET requests --- README.md | 6 +- library/src/main/java/io/appwrite/Client.kt | 32 +++-- .../main/java/io/appwrite/enums/CreditCard.kt | 4 +- .../java/io/appwrite/enums/OAuthProvider.kt | 2 + .../main/java/io/appwrite/services/Account.kt | 128 +----------------- .../main/java/io/appwrite/services/Avatars.kt | 16 +-- .../java/io/appwrite/services/Databases.kt | 20 --- .../java/io/appwrite/services/Functions.kt | 8 -- .../main/java/io/appwrite/services/Graphql.kt | 4 - .../main/java/io/appwrite/services/Locale.kt | 24 ---- .../java/io/appwrite/services/Messaging.kt | 4 - .../main/java/io/appwrite/services/Storage.kt | 18 --- .../main/java/io/appwrite/services/Teams.kt | 43 ------ 13 files changed, 31 insertions(+), 278 deletions(-) diff --git a/README.md b/README.md index 0698a2c..9edac18 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![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.6.1-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.6.2-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) @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:7.0.0") +implementation("io.appwrite:sdk-for-android:7.0.1") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 7.0.0 + 7.0.1 ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 409dc92..909e62f 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -25,6 +25,7 @@ import java.io.BufferedReader import java.io.File import java.io.RandomAccessFile import java.io.IOException +import java.lang.IllegalArgumentException import java.net.CookieManager import java.net.CookiePolicy import java.security.SecureRandom @@ -86,7 +87,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "7.0.0", + "x-sdk-version" to "7.0.1", "x-appwrite-response-format" to "1.6.0" ) config = mutableMapOf() @@ -211,24 +212,31 @@ class Client @JvmOverloads constructor( * * @return this */ + @Throws(IllegalArgumentException::class) fun setEndpoint(endpoint: String): Client { - this.endpoint = endpoint - - if (this.endpointRealtime == null && endpoint.startsWith("http")) { - this.endpointRealtime = endpoint.replaceFirst("http", "ws") + require(endpoint.startsWith("http://") || endpoint.startsWith("https://")) { + "Invalid endpoint URL: $endpoint" } + this.endpoint = endpoint + this.endpointRealtime = endpoint.replaceFirst("http", "ws") + return this } /** - * Set realtime endpoint - * - * @param endpoint - * - * @return this - */ + * Set realtime endpoint + * + * @param endpoint + * + * @return this + */ + @Throws(IllegalArgumentException::class) fun setEndpointRealtime(endpoint: String): Client { + require(endpoint.startsWith("ws://") || endpoint.startsWith("wss://")) { + "Invalid realtime endpoint URL: $endpoint" + } + this.endpointRealtime = endpoint return this } @@ -525,7 +533,7 @@ class Client @JvmOverloads constructor( body ) } else { - AppwriteException(body, response.code) + AppwriteException(body, response.code, "", body) } it.cancel(error) return diff --git a/library/src/main/java/io/appwrite/enums/CreditCard.kt b/library/src/main/java/io/appwrite/enums/CreditCard.kt index 063de61..1826304 100644 --- a/library/src/main/java/io/appwrite/enums/CreditCard.kt +++ b/library/src/main/java/io/appwrite/enums/CreditCard.kt @@ -34,7 +34,9 @@ enum class CreditCard(val value: String) { @SerializedName("mir") MIR("mir"), @SerializedName("maestro") - MAESTRO("maestro"); + MAESTRO("maestro"), + @SerializedName("rupay") + RUPAY("rupay"); override fun toString() = value } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/enums/OAuthProvider.kt b/library/src/main/java/io/appwrite/enums/OAuthProvider.kt index dc1b9b3..b0cff85 100644 --- a/library/src/main/java/io/appwrite/enums/OAuthProvider.kt +++ b/library/src/main/java/io/appwrite/enums/OAuthProvider.kt @@ -31,6 +31,8 @@ enum class OAuthProvider(val value: String) { ETSY("etsy"), @SerializedName("facebook") FACEBOOK("facebook"), + @SerializedName("figma") + FIGMA("figma"), @SerializedName("github") GITHUB("github"), @SerializedName("gitlab") diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index cb22b33..13f5757 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -20,8 +20,6 @@ import java.io.File class Account(client: Client) : Service(client) { /** - * Get account - * * Get the currently logged in user. * * @return [io.appwrite.models.User] @@ -34,7 +32,6 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @Suppress("UNCHECKED_CAST") @@ -51,8 +48,6 @@ class Account(client: Client) : Service(client) { } /** - * Get account - * * Get the currently logged in user. * * @return [io.appwrite.models.User] @@ -64,8 +59,6 @@ class Account(client: Client) : Service(client) { ) /** - * Create account - * * Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). * * @param userId User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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. @@ -108,8 +101,6 @@ class Account(client: Client) : Service(client) { } /** - * Create account - * * Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). * * @param userId User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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. @@ -134,8 +125,6 @@ class Account(client: Client) : Service(client) { ) /** - * 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. @@ -171,8 +160,6 @@ class Account(client: Client) : Service(client) { } /** - * 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. @@ -190,8 +177,6 @@ class Account(client: Client) : Service(client) { ) /** - * List identities - * * Get the list of identities for the currently logged in user. * * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry @@ -207,7 +192,6 @@ class Account(client: Client) : Service(client) { "queries" to queries, ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.IdentityList = { @Suppress("UNCHECKED_CAST") @@ -225,8 +209,6 @@ class Account(client: Client) : Service(client) { /** - * Delete identity - * * Delete an identity by its unique ID. * * @param identityId Identity ID. @@ -254,8 +236,6 @@ class Account(client: Client) : Service(client) { /** - * 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] @@ -285,8 +265,6 @@ class Account(client: Client) : Service(client) { /** - * List logs - * * Get the list of latest security activity logs for the currently logged in user. 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/queries). Only supported methods are limit and offset @@ -302,7 +280,6 @@ class Account(client: Client) : Service(client) { "queries" to queries, ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LogList = { @Suppress("UNCHECKED_CAST") @@ -320,8 +297,6 @@ class Account(client: Client) : Service(client) { /** - * Update MFA - * * Enable or disable MFA on an account. * * @param mfa Enable or disable MFA. @@ -354,8 +329,6 @@ class Account(client: Client) : Service(client) { } /** - * Update MFA - * * Enable or disable MFA on an account. * * @param mfa Enable or disable MFA. @@ -370,8 +343,6 @@ class Account(client: Client) : Service(client) { ) /** - * Create authenticator - * * Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. * * @param type Type of authenticator. Must be `totp` @@ -404,8 +375,6 @@ class Account(client: Client) : Service(client) { /** - * Verify authenticator - * * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. * * @param type Type of authenticator. @@ -441,8 +410,6 @@ class Account(client: Client) : Service(client) { } /** - * Verify authenticator - * * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. * * @param type Type of authenticator. @@ -460,8 +427,6 @@ class Account(client: Client) : Service(client) { ) /** - * Delete authenticator - * * Delete an authenticator for a user by ID. * * @param type Type of authenticator. @@ -489,8 +454,6 @@ class Account(client: Client) : Service(client) { /** - * Create MFA challenge - * * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. * * @param factor Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`. @@ -523,8 +486,6 @@ class Account(client: Client) : Service(client) { /** - * Create MFA challenge (confirmation) - * * Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. * * @param challengeId ID of the challenge. @@ -560,8 +521,6 @@ class Account(client: Client) : Service(client) { /** - * List factors - * * List the factors available on the account to be used as a MFA challange. * * @return [io.appwrite.models.MfaFactors] @@ -573,7 +532,6 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MfaFactors = { @Suppress("UNCHECKED_CAST") @@ -591,8 +549,6 @@ class Account(client: Client) : Service(client) { /** - * Get MFA recovery codes - * * Get recovery codes that can be used as backup for MFA flow. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to read recovery codes. * * @return [io.appwrite.models.MfaRecoveryCodes] @@ -604,7 +560,6 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MfaRecoveryCodes = { @Suppress("UNCHECKED_CAST") @@ -622,8 +577,6 @@ class Account(client: Client) : Service(client) { /** - * Create MFA recovery codes - * * Generate recovery codes as backup for MFA flow. It's recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. * * @return [io.appwrite.models.MfaRecoveryCodes] @@ -653,8 +606,6 @@ class Account(client: Client) : Service(client) { /** - * Regenerate MFA recovery codes - * * Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes. * * @return [io.appwrite.models.MfaRecoveryCodes] @@ -684,8 +635,6 @@ class Account(client: Client) : Service(client) { /** - * Update name - * * Update currently logged in user account name. * * @param name User name. Max length: 128 chars. @@ -718,8 +667,6 @@ class Account(client: Client) : Service(client) { } /** - * Update name - * * Update currently logged in user account name. * * @param name User name. Max length: 128 chars. @@ -734,8 +681,6 @@ class Account(client: Client) : Service(client) { ) /** - * 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. @@ -772,8 +717,6 @@ class Account(client: Client) : Service(client) { } /** - * 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. @@ -792,8 +735,6 @@ class Account(client: Client) : Service(client) { ) /** - * 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](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) endpoint to send a confirmation SMS. * * @param phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. @@ -829,8 +770,6 @@ class Account(client: Client) : Service(client) { } /** - * 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](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) endpoint to send a confirmation SMS. * * @param phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. @@ -848,8 +787,6 @@ class Account(client: Client) : Service(client) { ) /** - * Get account preferences - * * Get the preferences as a key-value object for the currently logged in user. * * @return [io.appwrite.models.Preferences] @@ -862,7 +799,6 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { @Suppress("UNCHECKED_CAST") @@ -879,8 +815,6 @@ class Account(client: Client) : Service(client) { } /** - * Get account preferences - * * Get the preferences as a key-value object for the currently logged in user. * * @return [io.appwrite.models.Preferences] @@ -892,8 +826,6 @@ class Account(client: Client) : Service(client) { ) /** - * 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. @@ -926,8 +858,6 @@ class Account(client: Client) : Service(client) { } /** - * 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. @@ -942,8 +872,6 @@ class Account(client: Client) : Service(client) { ) /** - * 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](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) endpoint to complete the process. The verification link sent to the user's email address is valid for 1 hour. * * @param email User email. @@ -979,8 +907,6 @@ class Account(client: Client) : Service(client) { /** - * 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](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) 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. @@ -1019,8 +945,6 @@ class Account(client: Client) : Service(client) { /** - * List sessions - * * Get the list of active sessions across different devices for the currently logged in user. * * @return [io.appwrite.models.SessionList] @@ -1032,7 +956,6 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.SessionList = { @Suppress("UNCHECKED_CAST") @@ -1050,8 +973,6 @@ class Account(client: Client) : Service(client) { /** - * Delete sessions - * * Delete all sessions from the user account and remove any sessions cookies from the end client. * * @return [Any] @@ -1076,8 +997,6 @@ class Account(client: Client) : Service(client) { /** - * Create anonymous session - * * Use this endpoint to allow a new user to register an anonymous account in your project. This route will also create a new session for the user. To allow the new user to convert an anonymous account to a normal account, you need to update its [email and password](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail) or create an [OAuth2 session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session). * * @return [io.appwrite.models.Session] @@ -1107,8 +1026,6 @@ class Account(client: Client) : Service(client) { /** - * Create email password session - * * Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * @param email User email. @@ -1144,8 +1061,6 @@ class Account(client: Client) : Service(client) { /** - * Update magic URL session - * * Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. * * @param userId User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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. @@ -1181,11 +1096,9 @@ class Account(client: Client) : Service(client) { /** - * 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](https://appwrite.io/docs/authentication-security#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, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom. + * @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom. * @param success URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's 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's 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. @@ -1255,8 +1168,6 @@ class Account(client: Client) : Service(client) { /** - * Update phone session - * * Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. * * @param userId User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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. @@ -1292,8 +1203,6 @@ class Account(client: Client) : Service(client) { /** - * Create session - * * Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. * * @param userId User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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. @@ -1329,8 +1238,6 @@ class Account(client: Client) : Service(client) { /** - * 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. * * @param sessionId Session ID. Use the string 'current' to get the current device session. @@ -1345,7 +1252,6 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @Suppress("UNCHECKED_CAST") @@ -1363,8 +1269,6 @@ class Account(client: Client) : Service(client) { /** - * Update session - * * Use this endpoint to extend a session's length. Extending a session is useful when session expiry is short. If the session was created using an OAuth provider, this endpoint refreshes the access token from the provider. * * @param sessionId Session ID. Use the string 'current' to update the current device session. @@ -1397,8 +1301,6 @@ class Account(client: Client) : Service(client) { /** - * Delete session - * * Logout the user. Use 'current' as the session ID to logout on this device, use a session ID to logout on another device. If you're looking to logout the user on all devices, use [Delete Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) instead. * * @param sessionId Session ID. Use the string 'current' to delete the current device session. @@ -1426,8 +1328,6 @@ class Account(client: Client) : Service(client) { /** - * 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.User] @@ -1457,8 +1357,6 @@ class Account(client: Client) : Service(client) { } /** - * 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.User] @@ -1470,8 +1368,6 @@ class Account(client: Client) : Service(client) { ) /** - * Create push target - * * Use this endpoint to register a device for push notifications. Provide a target ID (custom or generated using ID.unique()), a device identifier (usually a device token), and optionally specify which provider should send notifications to this target. The target is automatically linked to the current session and includes device information like brand and model. * * @param targetId Target ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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. @@ -1511,8 +1407,6 @@ class Account(client: Client) : Service(client) { /** - * Update push target - * * Update the currently logged in user's push notification target. You can modify the target's identifier (device token) and provider ID (token, email, phone etc.). The target must exist and belong to the current user. If you change the provider ID, notifications will be sent through the new messaging provider instead. * * @param targetId Target ID. @@ -1548,8 +1442,6 @@ class Account(client: Client) : Service(client) { /** - * Delete push target - * * Delete a push notification target for the currently logged in user. After deletion, the device will no longer receive push notifications. The target must exist and belong to the current user. * * @param targetId Target ID. @@ -1577,8 +1469,6 @@ class Account(client: Client) : Service(client) { /** - * Create email token (OTP) - * * Sends the user an email with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's email is valid for 15 minutes.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * @param userId User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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. @@ -1618,8 +1508,6 @@ class Account(client: Client) : Service(client) { /** - * Create magic URL token - * * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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. @@ -1662,11 +1550,9 @@ class Account(client: Client) : Service(client) { /** - * Create OAuth2 token - * * Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * - * @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, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom. + * @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom. * @param success URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's 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's 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. @@ -1736,8 +1622,6 @@ class Account(client: Client) : Service(client) { /** - * Create phone token - * * Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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. @@ -1773,8 +1657,6 @@ class Account(client: Client) : Service(client) { /** - * 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](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). 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. @@ -1807,8 +1689,6 @@ class Account(client: Client) : Service(client) { /** - * 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. * * @param userId User ID. @@ -1844,8 +1724,6 @@ class Account(client: Client) : Service(client) { /** - * 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](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone) endpoint. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification). The verification code sent to the user's phone number is valid for 15 minutes. * * @return [io.appwrite.models.Token] @@ -1875,8 +1753,6 @@ class Account(client: Client) : Service(client) { /** - * Update 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. * * @param userId User ID. diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt index 9913edc..2900bf4 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -18,8 +18,6 @@ import java.io.File class Avatars(client: Client) : Service(client) { /** - * 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](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) 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. @@ -54,11 +52,9 @@ class Avatars(client: Client) : Service(client) { /** - * 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. * - * @param code Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro. + * @param code Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro, rupay. * @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. @@ -90,8 +86,6 @@ class Avatars(client: Client) : Service(client) { /** - * Get favicon - * * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote website URL.This endpoint does not follow HTTP redirects. * * @param url Website URL which you want to fetch the favicon from. @@ -116,8 +110,6 @@ class Avatars(client: Client) : Service(client) { /** - * 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](https://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. @@ -152,8 +144,6 @@ class Avatars(client: Client) : Service(client) { /** - * 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.This endpoint does not follow HTTP redirects. * * @param url Image URL which you want to crop. @@ -185,8 +175,6 @@ class Avatars(client: Client) : Service(client) { /** - * 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. * * @param name Full Name. When empty, current user name or email will be used. Max length: 128 chars. @@ -221,8 +209,6 @@ class Avatars(client: Client) : Service(client) { /** - * 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. * * @param text Plain text to be converted to QR code image. diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index 70ecf23..94fb69a 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -16,8 +16,6 @@ import java.io.File class Databases(client: Client) : Service(client) { /** - * 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. @@ -40,7 +38,6 @@ class Databases(client: Client) : Service(client) { "queries" to queries, ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.DocumentList = { @Suppress("UNCHECKED_CAST") @@ -57,8 +54,6 @@ class Databases(client: Client) : Service(client) { } /** - * 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. @@ -80,8 +75,6 @@ class Databases(client: Client) : Service(client) { ) /** - * Create document - * * Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. * * @param databaseId Database ID. @@ -127,8 +120,6 @@ class Databases(client: Client) : Service(client) { } /** - * Create document - * * Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. * * @param databaseId Database ID. @@ -156,8 +147,6 @@ class Databases(client: Client) : Service(client) { ) /** - * Get document - * * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. * * @param databaseId Database ID. @@ -183,7 +172,6 @@ class Databases(client: Client) : Service(client) { "queries" to queries, ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { @Suppress("UNCHECKED_CAST") @@ -200,8 +188,6 @@ class Databases(client: Client) : Service(client) { } /** - * Get document - * * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. * * @param databaseId Database ID. @@ -226,8 +212,6 @@ class Databases(client: Client) : Service(client) { ) /** - * 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. @@ -273,8 +257,6 @@ class Databases(client: Client) : Service(client) { } /** - * 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. @@ -302,8 +284,6 @@ class Databases(client: Client) : Service(client) { ) /** - * Delete document - * * Delete a document by its unique ID. * * @param databaseId Database ID. diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index d31e853..473188f 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -16,8 +16,6 @@ import java.io.File class Functions(client: Client) : Service(client) { /** - * List executions - * * 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. @@ -39,7 +37,6 @@ class Functions(client: Client) : Service(client) { "search" to search, ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.ExecutionList = { @Suppress("UNCHECKED_CAST") @@ -57,8 +54,6 @@ class Functions(client: Client) : Service(client) { /** - * 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. * * @param functionId Function ID. @@ -110,8 +105,6 @@ class Functions(client: Client) : Service(client) { /** - * Get execution - * * Get a function execution log by its unique ID. * * @param functionId Function ID. @@ -129,7 +122,6 @@ class Functions(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Execution = { @Suppress("UNCHECKED_CAST") diff --git a/library/src/main/java/io/appwrite/services/Graphql.kt b/library/src/main/java/io/appwrite/services/Graphql.kt index 6c977a2..d066c7b 100644 --- a/library/src/main/java/io/appwrite/services/Graphql.kt +++ b/library/src/main/java/io/appwrite/services/Graphql.kt @@ -16,8 +16,6 @@ import java.io.File class Graphql(client: Client) : Service(client) { /** - * GraphQL endpoint - * * Execute a GraphQL mutation. * * @param query The query or queries to execute. @@ -50,8 +48,6 @@ class Graphql(client: Client) : Service(client) { /** - * GraphQL endpoint - * * Execute a GraphQL mutation. * * @param query The query or queries to execute. diff --git a/library/src/main/java/io/appwrite/services/Locale.kt b/library/src/main/java/io/appwrite/services/Locale.kt index 01b3017..6257381 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -16,8 +16,6 @@ import java.io.File class Locale(client: Client) : Service(client) { /** - * 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)) * * @return [io.appwrite.models.Locale] @@ -29,7 +27,6 @@ class Locale(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Locale = { @Suppress("UNCHECKED_CAST") @@ -47,8 +44,6 @@ class Locale(client: Client) : Service(client) { /** - * List locale codes - * * List of all locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). * * @return [io.appwrite.models.LocaleCodeList] @@ -60,7 +55,6 @@ class Locale(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LocaleCodeList = { @Suppress("UNCHECKED_CAST") @@ -78,8 +72,6 @@ class Locale(client: Client) : Service(client) { /** - * List continents - * * List of all continents. You can use the locale header to get the data in a supported language. * * @return [io.appwrite.models.ContinentList] @@ -91,7 +83,6 @@ class Locale(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.ContinentList = { @Suppress("UNCHECKED_CAST") @@ -109,8 +100,6 @@ class Locale(client: Client) : Service(client) { /** - * List countries - * * List of all countries. You can use the locale header to get the data in a supported language. * * @return [io.appwrite.models.CountryList] @@ -122,7 +111,6 @@ class Locale(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CountryList = { @Suppress("UNCHECKED_CAST") @@ -140,8 +128,6 @@ class Locale(client: Client) : Service(client) { /** - * 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. * * @return [io.appwrite.models.CountryList] @@ -153,7 +139,6 @@ class Locale(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CountryList = { @Suppress("UNCHECKED_CAST") @@ -171,8 +156,6 @@ class Locale(client: Client) : Service(client) { /** - * List countries phone codes - * * 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] @@ -184,7 +167,6 @@ class Locale(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.PhoneList = { @Suppress("UNCHECKED_CAST") @@ -202,8 +184,6 @@ class Locale(client: Client) : Service(client) { /** - * 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. * * @return [io.appwrite.models.CurrencyList] @@ -215,7 +195,6 @@ class Locale(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.CurrencyList = { @Suppress("UNCHECKED_CAST") @@ -233,8 +212,6 @@ class Locale(client: Client) : Service(client) { /** - * List languages - * * 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] @@ -246,7 +223,6 @@ class Locale(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.LanguageList = { @Suppress("UNCHECKED_CAST") diff --git a/library/src/main/java/io/appwrite/services/Messaging.kt b/library/src/main/java/io/appwrite/services/Messaging.kt index baca2c4..d0679bb 100644 --- a/library/src/main/java/io/appwrite/services/Messaging.kt +++ b/library/src/main/java/io/appwrite/services/Messaging.kt @@ -16,8 +16,6 @@ import java.io.File class Messaging(client: Client) : Service(client) { /** - * Create subscriber - * * Create a new subscriber. * * @param topicId Topic ID. The topic ID to subscribe to. @@ -56,8 +54,6 @@ class Messaging(client: Client) : Service(client) { /** - * Delete subscriber - * * Delete a subscriber by its unique ID. * * @param topicId Topic ID. The topic ID subscribed to. diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index 1f990c2..0facb1d 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -18,8 +18,6 @@ import java.io.File class Storage(client: Client) : Service(client) { /** - * List files - * * 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](https://appwrite.io/docs/server/storage#createBucket). @@ -41,7 +39,6 @@ class Storage(client: Client) : Service(client) { "search" to search, ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.FileList = { @Suppress("UNCHECKED_CAST") @@ -59,8 +56,6 @@ class Storage(client: Client) : Service(client) { /** - * Create file - * * Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](https://appwrite.io/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](https://appwrite.io/docs/server/storage#createBucket). @@ -108,8 +103,6 @@ class Storage(client: Client) : Service(client) { /** - * Get file - * * 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](https://appwrite.io/docs/server/storage#createBucket). @@ -127,7 +120,6 @@ class Storage(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.File = { @Suppress("UNCHECKED_CAST") @@ -145,8 +137,6 @@ class Storage(client: Client) : Service(client) { /** - * Update file - * * 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](https://appwrite.io/docs/server/storage#createBucket). @@ -189,8 +179,6 @@ class Storage(client: Client) : Service(client) { /** - * Delete file - * * 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](https://appwrite.io/docs/server/storage#createBucket). @@ -221,8 +209,6 @@ class Storage(client: Client) : Service(client) { /** - * 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. * * @param bucketId Storage bucket ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). @@ -250,8 +236,6 @@ class Storage(client: Client) : Service(client) { /** - * 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. * * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). @@ -313,8 +297,6 @@ class Storage(client: Client) : Service(client) { /** - * 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. * * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index b586f11..7e35403 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -16,8 +16,6 @@ import java.io.File class Teams(client: Client) : Service(client) { /** - * 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. * * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total, billingPlan @@ -37,7 +35,6 @@ class Teams(client: Client) : Service(client) { "search" to search, ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.TeamList = { @Suppress("UNCHECKED_CAST") @@ -54,8 +51,6 @@ class Teams(client: Client) : Service(client) { } /** - * 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. * * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total, billingPlan @@ -74,8 +69,6 @@ class Teams(client: Client) : Service(client) { ) /** - * 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. * * @param teamId Team ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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. @@ -115,8 +108,6 @@ class Teams(client: Client) : Service(client) { } /** - * 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. * * @param teamId Team ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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. @@ -138,8 +129,6 @@ class Teams(client: Client) : Service(client) { ) /** - * Get team - * * Get a team by its ID. All team members have read access for this resource. * * @param teamId Team ID. @@ -155,7 +144,6 @@ class Teams(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Team = { @Suppress("UNCHECKED_CAST") @@ -172,8 +160,6 @@ class Teams(client: Client) : Service(client) { } /** - * Get team - * * Get a team by its ID. All team members have read access for this resource. * * @param teamId Team ID. @@ -188,8 +174,6 @@ class Teams(client: Client) : Service(client) { ) /** - * Update name - * * Update the team's name by its unique ID. * * @param teamId Team ID. @@ -225,8 +209,6 @@ class Teams(client: Client) : Service(client) { } /** - * Update name - * * Update the team's name by its unique ID. * * @param teamId Team ID. @@ -244,8 +226,6 @@ class Teams(client: Client) : Service(client) { ) /** - * Delete team - * * Delete a team using its ID. Only team members with the owner role can delete the team. * * @param teamId Team ID. @@ -273,8 +253,6 @@ class Teams(client: Client) : Service(client) { /** - * 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. Hide sensitive attributes from the response by toggling membership privacy in the Console. * * @param teamId Team ID. @@ -296,7 +274,6 @@ class Teams(client: Client) : Service(client) { "search" to search, ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MembershipList = { @Suppress("UNCHECKED_CAST") @@ -314,8 +291,6 @@ class Teams(client: Client) : Service(client) { /** - * Create team membership - * * Invite a new member to join your team. Provide an ID for existing users, or invite unregistered users using an email or phone number. If initiated from a Client SDK, Appwrite will send an email or sms with a link to join the team to the invited user, and an account will be created for them if one doesn't exist. If initiated from a Server SDK, the new member will be added automatically to the team.You only need to provide one of a user ID, email, or phone number. Appwrite will prioritize accepting the user ID > email > phone number if you provide more than one of these parameters.Use the `url` parameter to redirect the user from the invitation email to your app. After the user is redirected, use the [Update Team Membership Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) 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) Appwrite will accept the only redirect URLs under the domains you have added as a platform on the Appwrite Console. * * @param teamId Team ID. @@ -367,8 +342,6 @@ class Teams(client: Client) : Service(client) { /** - * Get team membership - * * Get a team member by the membership unique id. All team members have read access for this resource. Hide sensitive attributes from the response by toggling membership privacy in the Console. * * @param teamId Team ID. @@ -386,7 +359,6 @@ class Teams(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { @Suppress("UNCHECKED_CAST") @@ -404,8 +376,6 @@ class Teams(client: Client) : Service(client) { /** - * Update membership - * * 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](https://appwrite.io/docs/permissions). * * @param teamId Team ID. @@ -444,8 +414,6 @@ class Teams(client: Client) : Service(client) { /** - * 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. * * @param teamId Team ID. @@ -476,8 +444,6 @@ class Teams(client: Client) : Service(client) { /** - * 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. * * @param teamId Team ID. @@ -519,8 +485,6 @@ class Teams(client: Client) : Service(client) { /** - * Get team preferences - * * Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in [user preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). * * @param teamId Team ID. @@ -536,7 +500,6 @@ class Teams(client: Client) : Service(client) { val apiParams = mutableMapOf( ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { @Suppress("UNCHECKED_CAST") @@ -553,8 +516,6 @@ class Teams(client: Client) : Service(client) { } /** - * Get team preferences - * * Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in [user preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). * * @param teamId Team ID. @@ -569,8 +530,6 @@ class Teams(client: Client) : Service(client) { ) /** - * Update preferences - * * Update the team's preferences by its unique ID. The object you pass is stored as is and replaces any previous value. The maximum allowed prefs size is 64kB and throws an error if exceeded. * * @param teamId Team ID. @@ -606,8 +565,6 @@ class Teams(client: Client) : Service(client) { } /** - * Update preferences - * * Update the team's preferences by its unique ID. The object you pass is stored as is and replaces any previous value. The maximum allowed prefs size is 64kB and throws an error if exceeded. * * @param teamId Team ID. From e35c1f3e0ebd5cc8e8dbf7e26a8493c017fb191e Mon Sep 17 00:00:00 2001 From: root Date: Wed, 23 Apr 2025 13:10:02 +0000 Subject: [PATCH 094/118] fix: build error --- library/src/main/java/io/appwrite/Client.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 909e62f..4a51694 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -39,7 +39,7 @@ import kotlin.coroutines.resume class Client @JvmOverloads constructor( context: Context, - var endpoint: String = "https://cloud.appwrite.io/v1", + var endpoint: String = "https://<REGION>.cloud.appwrite.io/v1", var endpointRealtime: String? = null, private var selfSigned: Boolean = false ) : CoroutineScope { From feaab4737a175f6f603d4ab5288c7af0c47d2ddf Mon Sep 17 00:00:00 2001 From: root Date: Wed, 23 Apr 2025 13:13:22 +0000 Subject: [PATCH 095/118] chore: regenerate sdk --- .../main/java/io/appwrite/services/Account.kt | 90 +++++++++---------- .../java/io/appwrite/services/Databases.kt | 10 +-- .../java/io/appwrite/services/Functions.kt | 6 +- .../main/java/io/appwrite/services/Graphql.kt | 4 +- .../main/java/io/appwrite/services/Locale.kt | 16 ++-- .../java/io/appwrite/services/Messaging.kt | 4 +- .../main/java/io/appwrite/services/Storage.kt | 10 +-- .../main/java/io/appwrite/services/Teams.kt | 26 +++--- 8 files changed, 83 insertions(+), 83 deletions(-) diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 13f5757..f50f074 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -31,7 +31,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.User = { @Suppress("UNCHECKED_CAST") @@ -83,7 +83,7 @@ class Account(client: Client) : Service(client) { "password" to password, "name" to name, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @@ -142,7 +142,7 @@ class Account(client: Client) : Service(client) { "email" to email, "password" to password, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @@ -191,7 +191,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( "queries" to queries, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.IdentityList = { @Suppress("UNCHECKED_CAST") @@ -222,7 +222,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) return client.call( @@ -246,7 +246,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Jwt = { @@ -279,7 +279,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( "queries" to queries, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.LogList = { @Suppress("UNCHECKED_CAST") @@ -311,7 +311,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( "mfa" to mfa, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @@ -356,7 +356,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MfaType = { @@ -392,7 +392,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( "otp" to otp, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @@ -440,7 +440,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) return client.call( @@ -467,7 +467,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( "factor" to factor, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MfaChallenge = { @@ -502,7 +502,7 @@ class Account(client: Client) : Service(client) { "challengeId" to challengeId, "otp" to otp, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @@ -531,7 +531,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.MfaFactors = { @Suppress("UNCHECKED_CAST") @@ -559,7 +559,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.MfaRecoveryCodes = { @Suppress("UNCHECKED_CAST") @@ -587,7 +587,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MfaRecoveryCodes = { @@ -616,7 +616,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.MfaRecoveryCodes = { @@ -649,7 +649,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( "name" to name, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @@ -699,7 +699,7 @@ class Account(client: Client) : Service(client) { "password" to password, "oldPassword" to oldPassword, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @@ -752,7 +752,7 @@ class Account(client: Client) : Service(client) { "phone" to phone, "password" to password, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @@ -798,7 +798,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.Preferences = { @Suppress("UNCHECKED_CAST") @@ -840,7 +840,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( "prefs" to prefs, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @@ -888,7 +888,7 @@ class Account(client: Client) : Service(client) { "email" to email, "url" to url, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @@ -926,7 +926,7 @@ class Account(client: Client) : Service(client) { "secret" to secret, "password" to password, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @@ -955,7 +955,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.SessionList = { @Suppress("UNCHECKED_CAST") @@ -983,7 +983,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) return client.call( @@ -1007,7 +1007,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @@ -1042,7 +1042,7 @@ class Account(client: Client) : Service(client) { "email" to email, "password" to password, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @@ -1077,7 +1077,7 @@ class Account(client: Client) : Service(client) { "userId" to userId, "secret" to secret, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @@ -1184,7 +1184,7 @@ class Account(client: Client) : Service(client) { "userId" to userId, "secret" to secret, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @@ -1219,7 +1219,7 @@ class Account(client: Client) : Service(client) { "userId" to userId, "secret" to secret, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @@ -1251,7 +1251,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.Session = { @Suppress("UNCHECKED_CAST") @@ -1282,7 +1282,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Session = { @@ -1314,7 +1314,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) return client.call( @@ -1339,7 +1339,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.User = { @@ -1388,7 +1388,7 @@ class Account(client: Client) : Service(client) { "identifier" to identifier, "providerId" to providerId, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Target = { @@ -1423,7 +1423,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( "identifier" to identifier, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Target = { @@ -1455,7 +1455,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) return client.call( @@ -1489,7 +1489,7 @@ class Account(client: Client) : Service(client) { "email" to email, "phrase" to phrase, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @@ -1531,7 +1531,7 @@ class Account(client: Client) : Service(client) { "url" to url, "phrase" to phrase, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @@ -1638,7 +1638,7 @@ class Account(client: Client) : Service(client) { "userId" to userId, "phone" to phone, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @@ -1670,7 +1670,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( "url" to url, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @@ -1705,7 +1705,7 @@ class Account(client: Client) : Service(client) { "userId" to userId, "secret" to secret, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @@ -1734,7 +1734,7 @@ class Account(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { @@ -1769,7 +1769,7 @@ class Account(client: Client) : Service(client) { "userId" to userId, "secret" to secret, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Token = { diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index 94fb69a..b6559a9 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -37,7 +37,7 @@ class Databases(client: Client) : Service(client) { val apiParams = mutableMapOf( "queries" to queries, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.DocumentList = { @Suppress("UNCHECKED_CAST") @@ -102,7 +102,7 @@ class Databases(client: Client) : Service(client) { "data" to data, "permissions" to permissions, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { @@ -171,7 +171,7 @@ class Databases(client: Client) : Service(client) { val apiParams = mutableMapOf( "queries" to queries, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.Document = { @Suppress("UNCHECKED_CAST") @@ -239,7 +239,7 @@ class Databases(client: Client) : Service(client) { "data" to data, "permissions" to permissions, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { @@ -303,7 +303,7 @@ class Databases(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) return client.call( diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index 473188f..a3644f2 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -36,7 +36,7 @@ class Functions(client: Client) : Service(client) { "queries" to queries, "search" to search, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.ExecutionList = { @Suppress("UNCHECKED_CAST") @@ -86,7 +86,7 @@ class Functions(client: Client) : Service(client) { "headers" to headers, "scheduledAt" to scheduledAt, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Execution = { @@ -121,7 +121,7 @@ class Functions(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.Execution = { @Suppress("UNCHECKED_CAST") diff --git a/library/src/main/java/io/appwrite/services/Graphql.kt b/library/src/main/java/io/appwrite/services/Graphql.kt index d066c7b..fbb4f7d 100644 --- a/library/src/main/java/io/appwrite/services/Graphql.kt +++ b/library/src/main/java/io/appwrite/services/Graphql.kt @@ -29,7 +29,7 @@ class Graphql(client: Client) : Service(client) { val apiParams = mutableMapOf( "query" to query, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "x-sdk-graphql" to "true", "content-type" to "application/json", ) @@ -61,7 +61,7 @@ class Graphql(client: Client) : Service(client) { val apiParams = mutableMapOf( "query" to query, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "x-sdk-graphql" to "true", "content-type" to "application/json", ) diff --git a/library/src/main/java/io/appwrite/services/Locale.kt b/library/src/main/java/io/appwrite/services/Locale.kt index 6257381..a6319b6 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -26,7 +26,7 @@ class Locale(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.Locale = { @Suppress("UNCHECKED_CAST") @@ -54,7 +54,7 @@ class Locale(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.LocaleCodeList = { @Suppress("UNCHECKED_CAST") @@ -82,7 +82,7 @@ class Locale(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.ContinentList = { @Suppress("UNCHECKED_CAST") @@ -110,7 +110,7 @@ class Locale(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.CountryList = { @Suppress("UNCHECKED_CAST") @@ -138,7 +138,7 @@ class Locale(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.CountryList = { @Suppress("UNCHECKED_CAST") @@ -166,7 +166,7 @@ class Locale(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.PhoneList = { @Suppress("UNCHECKED_CAST") @@ -194,7 +194,7 @@ class Locale(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.CurrencyList = { @Suppress("UNCHECKED_CAST") @@ -222,7 +222,7 @@ class Locale(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.LanguageList = { @Suppress("UNCHECKED_CAST") diff --git a/library/src/main/java/io/appwrite/services/Messaging.kt b/library/src/main/java/io/appwrite/services/Messaging.kt index d0679bb..8efd1a4 100644 --- a/library/src/main/java/io/appwrite/services/Messaging.kt +++ b/library/src/main/java/io/appwrite/services/Messaging.kt @@ -35,7 +35,7 @@ class Messaging(client: Client) : Service(client) { "subscriberId" to subscriberId, "targetId" to targetId, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Subscriber = { @@ -70,7 +70,7 @@ class Messaging(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) return client.call( diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index 0facb1d..391dedb 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -38,7 +38,7 @@ class Storage(client: Client) : Service(client) { "queries" to queries, "search" to search, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.FileList = { @Suppress("UNCHECKED_CAST") @@ -80,7 +80,7 @@ class Storage(client: Client) : Service(client) { "file" to file, "permissions" to permissions, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "multipart/form-data", ) val converter: (Any) -> io.appwrite.models.File = { @@ -119,7 +119,7 @@ class Storage(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.File = { @Suppress("UNCHECKED_CAST") @@ -160,7 +160,7 @@ class Storage(client: Client) : Service(client) { "name" to name, "permissions" to permissions, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.File = { @@ -195,7 +195,7 @@ class Storage(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) return client.call( diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 7e35403..6810ce1 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -34,7 +34,7 @@ class Teams(client: Client) : Service(client) { "queries" to queries, "search" to search, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.TeamList = { @Suppress("UNCHECKED_CAST") @@ -90,7 +90,7 @@ class Teams(client: Client) : Service(client) { "name" to name, "roles" to roles, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Team = { @@ -143,7 +143,7 @@ class Teams(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.Team = { @Suppress("UNCHECKED_CAST") @@ -191,7 +191,7 @@ class Teams(client: Client) : Service(client) { val apiParams = mutableMapOf( "name" to name, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Team = { @@ -239,7 +239,7 @@ class Teams(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) return client.call( @@ -273,7 +273,7 @@ class Teams(client: Client) : Service(client) { "queries" to queries, "search" to search, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.MembershipList = { @Suppress("UNCHECKED_CAST") @@ -323,7 +323,7 @@ class Teams(client: Client) : Service(client) { "url" to url, "name" to name, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { @@ -358,7 +358,7 @@ class Teams(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.Membership = { @Suppress("UNCHECKED_CAST") @@ -395,7 +395,7 @@ class Teams(client: Client) : Service(client) { val apiParams = mutableMapOf( "roles" to roles, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { @@ -430,7 +430,7 @@ class Teams(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) return client.call( @@ -466,7 +466,7 @@ class Teams(client: Client) : Service(client) { "userId" to userId, "secret" to secret, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Membership = { @@ -499,7 +499,7 @@ class Teams(client: Client) : Service(client) { val apiParams = mutableMapOf( ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( ) val converter: (Any) -> io.appwrite.models.Preferences = { @Suppress("UNCHECKED_CAST") @@ -547,7 +547,7 @@ class Teams(client: Client) : Service(client) { val apiParams = mutableMapOf( "prefs" to prefs, ) - val apiHeaders = mutableMapOf( + val apiHeaders = mutableMapOf( "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Preferences = { From 7f1491f828a70d4198e08bf28fc4744d28b658e9 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 24 Apr 2025 16:15:51 +0000 Subject: [PATCH 096/118] chore: regenerate sdk --- docs/examples/java/account/create-anonymous-session.md | 2 +- docs/examples/java/account/create-email-password-session.md | 2 +- docs/examples/java/account/create-email-token.md | 2 +- docs/examples/java/account/create-j-w-t.md | 2 +- docs/examples/java/account/create-magic-u-r-l-token.md | 2 +- docs/examples/java/account/create-mfa-authenticator.md | 2 +- docs/examples/java/account/create-mfa-challenge.md | 2 +- docs/examples/java/account/create-mfa-recovery-codes.md | 2 +- docs/examples/java/account/create-o-auth2session.md | 2 +- docs/examples/java/account/create-o-auth2token.md | 2 +- docs/examples/java/account/create-phone-token.md | 2 +- docs/examples/java/account/create-phone-verification.md | 2 +- docs/examples/java/account/create-push-target.md | 2 +- docs/examples/java/account/create-recovery.md | 2 +- docs/examples/java/account/create-session.md | 2 +- docs/examples/java/account/create-verification.md | 2 +- docs/examples/java/account/create.md | 2 +- docs/examples/java/account/delete-identity.md | 2 +- docs/examples/java/account/delete-mfa-authenticator.md | 2 +- docs/examples/java/account/delete-push-target.md | 2 +- docs/examples/java/account/delete-session.md | 2 +- docs/examples/java/account/delete-sessions.md | 2 +- docs/examples/java/account/get-mfa-recovery-codes.md | 2 +- docs/examples/java/account/get-prefs.md | 2 +- docs/examples/java/account/get-session.md | 2 +- docs/examples/java/account/get.md | 2 +- docs/examples/java/account/list-identities.md | 2 +- docs/examples/java/account/list-logs.md | 2 +- docs/examples/java/account/list-mfa-factors.md | 2 +- docs/examples/java/account/list-sessions.md | 2 +- docs/examples/java/account/update-email.md | 2 +- docs/examples/java/account/update-m-f-a.md | 2 +- docs/examples/java/account/update-magic-u-r-l-session.md | 2 +- docs/examples/java/account/update-mfa-authenticator.md | 2 +- docs/examples/java/account/update-mfa-challenge.md | 2 +- docs/examples/java/account/update-mfa-recovery-codes.md | 2 +- docs/examples/java/account/update-name.md | 2 +- docs/examples/java/account/update-password.md | 2 +- docs/examples/java/account/update-phone-session.md | 2 +- docs/examples/java/account/update-phone-verification.md | 2 +- docs/examples/java/account/update-phone.md | 2 +- docs/examples/java/account/update-prefs.md | 2 +- docs/examples/java/account/update-push-target.md | 2 +- docs/examples/java/account/update-recovery.md | 2 +- docs/examples/java/account/update-session.md | 2 +- docs/examples/java/account/update-status.md | 2 +- docs/examples/java/account/update-verification.md | 2 +- docs/examples/java/avatars/get-browser.md | 2 +- docs/examples/java/avatars/get-credit-card.md | 2 +- docs/examples/java/avatars/get-favicon.md | 2 +- docs/examples/java/avatars/get-flag.md | 2 +- docs/examples/java/avatars/get-image.md | 2 +- docs/examples/java/avatars/get-initials.md | 2 +- docs/examples/java/avatars/get-q-r.md | 2 +- docs/examples/java/databases/create-document.md | 2 +- docs/examples/java/databases/delete-document.md | 2 +- docs/examples/java/databases/get-document.md | 2 +- docs/examples/java/databases/list-documents.md | 2 +- docs/examples/java/databases/update-document.md | 2 +- docs/examples/java/functions/create-execution.md | 2 +- docs/examples/java/functions/get-execution.md | 2 +- docs/examples/java/functions/list-executions.md | 2 +- docs/examples/java/graphql/mutation.md | 2 +- docs/examples/java/graphql/query.md | 2 +- docs/examples/java/locale/get.md | 2 +- docs/examples/java/locale/list-codes.md | 2 +- docs/examples/java/locale/list-continents.md | 2 +- docs/examples/java/locale/list-countries-e-u.md | 2 +- docs/examples/java/locale/list-countries-phones.md | 2 +- docs/examples/java/locale/list-countries.md | 2 +- docs/examples/java/locale/list-currencies.md | 2 +- docs/examples/java/locale/list-languages.md | 2 +- docs/examples/java/messaging/create-subscriber.md | 2 +- docs/examples/java/messaging/delete-subscriber.md | 2 +- docs/examples/java/storage/create-file.md | 2 +- docs/examples/java/storage/delete-file.md | 2 +- docs/examples/java/storage/get-file-download.md | 2 +- docs/examples/java/storage/get-file-preview.md | 2 +- docs/examples/java/storage/get-file-view.md | 2 +- docs/examples/java/storage/get-file.md | 2 +- docs/examples/java/storage/list-files.md | 2 +- docs/examples/java/storage/update-file.md | 2 +- docs/examples/java/teams/create-membership.md | 2 +- docs/examples/java/teams/create.md | 2 +- docs/examples/java/teams/delete-membership.md | 2 +- docs/examples/java/teams/delete.md | 2 +- docs/examples/java/teams/get-membership.md | 2 +- docs/examples/java/teams/get-prefs.md | 2 +- docs/examples/java/teams/get.md | 2 +- docs/examples/java/teams/list-memberships.md | 2 +- docs/examples/java/teams/list.md | 2 +- docs/examples/java/teams/update-membership-status.md | 2 +- docs/examples/java/teams/update-membership.md | 2 +- docs/examples/java/teams/update-name.md | 2 +- docs/examples/java/teams/update-prefs.md | 2 +- docs/examples/kotlin/account/create-anonymous-session.md | 2 +- docs/examples/kotlin/account/create-email-password-session.md | 2 +- docs/examples/kotlin/account/create-email-token.md | 2 +- docs/examples/kotlin/account/create-j-w-t.md | 2 +- docs/examples/kotlin/account/create-magic-u-r-l-token.md | 2 +- docs/examples/kotlin/account/create-mfa-authenticator.md | 2 +- docs/examples/kotlin/account/create-mfa-challenge.md | 2 +- docs/examples/kotlin/account/create-mfa-recovery-codes.md | 2 +- docs/examples/kotlin/account/create-o-auth2session.md | 2 +- docs/examples/kotlin/account/create-o-auth2token.md | 2 +- docs/examples/kotlin/account/create-phone-token.md | 2 +- docs/examples/kotlin/account/create-phone-verification.md | 2 +- docs/examples/kotlin/account/create-push-target.md | 2 +- docs/examples/kotlin/account/create-recovery.md | 2 +- docs/examples/kotlin/account/create-session.md | 2 +- docs/examples/kotlin/account/create-verification.md | 2 +- docs/examples/kotlin/account/create.md | 2 +- docs/examples/kotlin/account/delete-identity.md | 2 +- docs/examples/kotlin/account/delete-mfa-authenticator.md | 2 +- docs/examples/kotlin/account/delete-push-target.md | 2 +- docs/examples/kotlin/account/delete-session.md | 2 +- docs/examples/kotlin/account/delete-sessions.md | 2 +- docs/examples/kotlin/account/get-mfa-recovery-codes.md | 2 +- docs/examples/kotlin/account/get-prefs.md | 2 +- docs/examples/kotlin/account/get-session.md | 2 +- docs/examples/kotlin/account/get.md | 2 +- docs/examples/kotlin/account/list-identities.md | 2 +- docs/examples/kotlin/account/list-logs.md | 2 +- docs/examples/kotlin/account/list-mfa-factors.md | 2 +- docs/examples/kotlin/account/list-sessions.md | 2 +- docs/examples/kotlin/account/update-email.md | 2 +- docs/examples/kotlin/account/update-m-f-a.md | 2 +- docs/examples/kotlin/account/update-magic-u-r-l-session.md | 2 +- docs/examples/kotlin/account/update-mfa-authenticator.md | 2 +- docs/examples/kotlin/account/update-mfa-challenge.md | 2 +- docs/examples/kotlin/account/update-mfa-recovery-codes.md | 2 +- docs/examples/kotlin/account/update-name.md | 2 +- docs/examples/kotlin/account/update-password.md | 2 +- docs/examples/kotlin/account/update-phone-session.md | 2 +- docs/examples/kotlin/account/update-phone-verification.md | 2 +- docs/examples/kotlin/account/update-phone.md | 2 +- docs/examples/kotlin/account/update-prefs.md | 2 +- docs/examples/kotlin/account/update-push-target.md | 2 +- docs/examples/kotlin/account/update-recovery.md | 2 +- docs/examples/kotlin/account/update-session.md | 2 +- docs/examples/kotlin/account/update-status.md | 2 +- docs/examples/kotlin/account/update-verification.md | 2 +- docs/examples/kotlin/avatars/get-browser.md | 2 +- docs/examples/kotlin/avatars/get-credit-card.md | 2 +- docs/examples/kotlin/avatars/get-favicon.md | 2 +- docs/examples/kotlin/avatars/get-flag.md | 2 +- docs/examples/kotlin/avatars/get-image.md | 2 +- docs/examples/kotlin/avatars/get-initials.md | 2 +- docs/examples/kotlin/avatars/get-q-r.md | 2 +- docs/examples/kotlin/databases/create-document.md | 2 +- docs/examples/kotlin/databases/delete-document.md | 2 +- docs/examples/kotlin/databases/get-document.md | 2 +- docs/examples/kotlin/databases/list-documents.md | 2 +- docs/examples/kotlin/databases/update-document.md | 2 +- docs/examples/kotlin/functions/create-execution.md | 2 +- docs/examples/kotlin/functions/get-execution.md | 2 +- docs/examples/kotlin/functions/list-executions.md | 2 +- docs/examples/kotlin/graphql/mutation.md | 2 +- docs/examples/kotlin/graphql/query.md | 2 +- docs/examples/kotlin/locale/get.md | 2 +- docs/examples/kotlin/locale/list-codes.md | 2 +- docs/examples/kotlin/locale/list-continents.md | 2 +- docs/examples/kotlin/locale/list-countries-e-u.md | 2 +- docs/examples/kotlin/locale/list-countries-phones.md | 2 +- docs/examples/kotlin/locale/list-countries.md | 2 +- docs/examples/kotlin/locale/list-currencies.md | 2 +- docs/examples/kotlin/locale/list-languages.md | 2 +- docs/examples/kotlin/messaging/create-subscriber.md | 2 +- docs/examples/kotlin/messaging/delete-subscriber.md | 2 +- docs/examples/kotlin/storage/create-file.md | 2 +- docs/examples/kotlin/storage/delete-file.md | 2 +- docs/examples/kotlin/storage/get-file-download.md | 2 +- docs/examples/kotlin/storage/get-file-preview.md | 2 +- docs/examples/kotlin/storage/get-file-view.md | 2 +- docs/examples/kotlin/storage/get-file.md | 2 +- docs/examples/kotlin/storage/list-files.md | 2 +- docs/examples/kotlin/storage/update-file.md | 2 +- docs/examples/kotlin/teams/create-membership.md | 2 +- docs/examples/kotlin/teams/create.md | 2 +- docs/examples/kotlin/teams/delete-membership.md | 2 +- docs/examples/kotlin/teams/delete.md | 2 +- docs/examples/kotlin/teams/get-membership.md | 2 +- docs/examples/kotlin/teams/get-prefs.md | 2 +- docs/examples/kotlin/teams/get.md | 2 +- docs/examples/kotlin/teams/list-memberships.md | 2 +- docs/examples/kotlin/teams/list.md | 2 +- docs/examples/kotlin/teams/update-membership-status.md | 2 +- docs/examples/kotlin/teams/update-membership.md | 2 +- docs/examples/kotlin/teams/update-name.md | 2 +- docs/examples/kotlin/teams/update-prefs.md | 2 +- example/src/main/java/io/appwrite/android/utils/Client.kt | 2 +- library/src/main/java/io/appwrite/Client.kt | 2 +- 192 files changed, 192 insertions(+), 192 deletions(-) diff --git a/docs/examples/java/account/create-anonymous-session.md b/docs/examples/java/account/create-anonymous-session.md index 1639cdc..9d80588 100644 --- a/docs/examples/java/account/create-anonymous-session.md +++ b/docs/examples/java/account/create-anonymous-session.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-email-password-session.md b/docs/examples/java/account/create-email-password-session.md index 817bda0..428b6fd 100644 --- a/docs/examples/java/account/create-email-password-session.md +++ b/docs/examples/java/account/create-email-password-session.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-email-token.md b/docs/examples/java/account/create-email-token.md index a4bc83b..869f4a8 100644 --- a/docs/examples/java/account/create-email-token.md +++ b/docs/examples/java/account/create-email-token.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-j-w-t.md b/docs/examples/java/account/create-j-w-t.md index 9aeb29c..9e3bd28 100644 --- a/docs/examples/java/account/create-j-w-t.md +++ b/docs/examples/java/account/create-j-w-t.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-magic-u-r-l-token.md b/docs/examples/java/account/create-magic-u-r-l-token.md index e57758a..6253e00 100644 --- a/docs/examples/java/account/create-magic-u-r-l-token.md +++ b/docs/examples/java/account/create-magic-u-r-l-token.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-mfa-authenticator.md b/docs/examples/java/account/create-mfa-authenticator.md index b8b06c3..54781f2 100644 --- a/docs/examples/java/account/create-mfa-authenticator.md +++ b/docs/examples/java/account/create-mfa-authenticator.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; import io.appwrite.enums.AuthenticatorType; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-mfa-challenge.md b/docs/examples/java/account/create-mfa-challenge.md index d9d9bb6..87a56fe 100644 --- a/docs/examples/java/account/create-mfa-challenge.md +++ b/docs/examples/java/account/create-mfa-challenge.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; import io.appwrite.enums.AuthenticationFactor; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-mfa-recovery-codes.md b/docs/examples/java/account/create-mfa-recovery-codes.md index 6e23ad2..ab50734 100644 --- a/docs/examples/java/account/create-mfa-recovery-codes.md +++ b/docs/examples/java/account/create-mfa-recovery-codes.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-o-auth2session.md b/docs/examples/java/account/create-o-auth2session.md index 59f5b41..4420859 100644 --- a/docs/examples/java/account/create-o-auth2session.md +++ b/docs/examples/java/account/create-o-auth2session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; import io.appwrite.enums.OAuthProvider; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-o-auth2token.md b/docs/examples/java/account/create-o-auth2token.md index 6103196..e5590c8 100644 --- a/docs/examples/java/account/create-o-auth2token.md +++ b/docs/examples/java/account/create-o-auth2token.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; import io.appwrite.enums.OAuthProvider; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-phone-token.md b/docs/examples/java/account/create-phone-token.md index a1ad85b..19d90b3 100644 --- a/docs/examples/java/account/create-phone-token.md +++ b/docs/examples/java/account/create-phone-token.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-phone-verification.md b/docs/examples/java/account/create-phone-verification.md index cca9283..8c16b6c 100644 --- a/docs/examples/java/account/create-phone-verification.md +++ b/docs/examples/java/account/create-phone-verification.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-push-target.md b/docs/examples/java/account/create-push-target.md index 34e8fcb..d434a5c 100644 --- a/docs/examples/java/account/create-push-target.md +++ b/docs/examples/java/account/create-push-target.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-recovery.md b/docs/examples/java/account/create-recovery.md index 4d2af8b..5592c6e 100644 --- a/docs/examples/java/account/create-recovery.md +++ b/docs/examples/java/account/create-recovery.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-session.md b/docs/examples/java/account/create-session.md index 71d11a5..0c59a80 100644 --- a/docs/examples/java/account/create-session.md +++ b/docs/examples/java/account/create-session.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create-verification.md b/docs/examples/java/account/create-verification.md index be4f7c9..e91acc8 100644 --- a/docs/examples/java/account/create-verification.md +++ b/docs/examples/java/account/create-verification.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/create.md b/docs/examples/java/account/create.md index e721248..ad04805 100644 --- a/docs/examples/java/account/create.md +++ b/docs/examples/java/account/create.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/delete-identity.md b/docs/examples/java/account/delete-identity.md index 6a62ea2..d556722 100644 --- a/docs/examples/java/account/delete-identity.md +++ b/docs/examples/java/account/delete-identity.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/delete-mfa-authenticator.md b/docs/examples/java/account/delete-mfa-authenticator.md index bb6cb09..4a9693b 100644 --- a/docs/examples/java/account/delete-mfa-authenticator.md +++ b/docs/examples/java/account/delete-mfa-authenticator.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; import io.appwrite.enums.AuthenticatorType; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/delete-push-target.md b/docs/examples/java/account/delete-push-target.md index c320800..00ab902 100644 --- a/docs/examples/java/account/delete-push-target.md +++ b/docs/examples/java/account/delete-push-target.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/delete-session.md b/docs/examples/java/account/delete-session.md index 2efc0f6..99d2f8e 100644 --- a/docs/examples/java/account/delete-session.md +++ b/docs/examples/java/account/delete-session.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/delete-sessions.md b/docs/examples/java/account/delete-sessions.md index d4c4380..e93f3e3 100644 --- a/docs/examples/java/account/delete-sessions.md +++ b/docs/examples/java/account/delete-sessions.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/get-mfa-recovery-codes.md b/docs/examples/java/account/get-mfa-recovery-codes.md index acf5984..8274bb3 100644 --- a/docs/examples/java/account/get-mfa-recovery-codes.md +++ b/docs/examples/java/account/get-mfa-recovery-codes.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/get-prefs.md b/docs/examples/java/account/get-prefs.md index 0fea3fe..5bb11a4 100644 --- a/docs/examples/java/account/get-prefs.md +++ b/docs/examples/java/account/get-prefs.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/get-session.md b/docs/examples/java/account/get-session.md index 3ce4ab5..288cd3b 100644 --- a/docs/examples/java/account/get-session.md +++ b/docs/examples/java/account/get-session.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/get.md b/docs/examples/java/account/get.md index 5c25ed0..6b5eb3b 100644 --- a/docs/examples/java/account/get.md +++ b/docs/examples/java/account/get.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/list-identities.md b/docs/examples/java/account/list-identities.md index 7f9449d..d4a6f9f 100644 --- a/docs/examples/java/account/list-identities.md +++ b/docs/examples/java/account/list-identities.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/list-logs.md b/docs/examples/java/account/list-logs.md index 3aa66e2..951a479 100644 --- a/docs/examples/java/account/list-logs.md +++ b/docs/examples/java/account/list-logs.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/list-mfa-factors.md b/docs/examples/java/account/list-mfa-factors.md index a10cb8d..9ea8331 100644 --- a/docs/examples/java/account/list-mfa-factors.md +++ b/docs/examples/java/account/list-mfa-factors.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/list-sessions.md b/docs/examples/java/account/list-sessions.md index aa8d37b..8946d96 100644 --- a/docs/examples/java/account/list-sessions.md +++ b/docs/examples/java/account/list-sessions.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-email.md b/docs/examples/java/account/update-email.md index 98cf907..ac80e45 100644 --- a/docs/examples/java/account/update-email.md +++ b/docs/examples/java/account/update-email.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-m-f-a.md b/docs/examples/java/account/update-m-f-a.md index 620a20c..b765cda 100644 --- a/docs/examples/java/account/update-m-f-a.md +++ b/docs/examples/java/account/update-m-f-a.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); 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 1b79b73..5893aa6 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 @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-mfa-authenticator.md b/docs/examples/java/account/update-mfa-authenticator.md index 74321be..b8016e7 100644 --- a/docs/examples/java/account/update-mfa-authenticator.md +++ b/docs/examples/java/account/update-mfa-authenticator.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account; import io.appwrite.enums.AuthenticatorType; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-mfa-challenge.md b/docs/examples/java/account/update-mfa-challenge.md index a92f007..c640150 100644 --- a/docs/examples/java/account/update-mfa-challenge.md +++ b/docs/examples/java/account/update-mfa-challenge.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-mfa-recovery-codes.md b/docs/examples/java/account/update-mfa-recovery-codes.md index 2aa82b1..650ae24 100644 --- a/docs/examples/java/account/update-mfa-recovery-codes.md +++ b/docs/examples/java/account/update-mfa-recovery-codes.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-name.md b/docs/examples/java/account/update-name.md index 40a5e2e..47582c2 100644 --- a/docs/examples/java/account/update-name.md +++ b/docs/examples/java/account/update-name.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-password.md b/docs/examples/java/account/update-password.md index 355c06d..09f572e 100644 --- a/docs/examples/java/account/update-password.md +++ b/docs/examples/java/account/update-password.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-phone-session.md b/docs/examples/java/account/update-phone-session.md index 042238e..2e1b880 100644 --- a/docs/examples/java/account/update-phone-session.md +++ b/docs/examples/java/account/update-phone-session.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-phone-verification.md b/docs/examples/java/account/update-phone-verification.md index ba7b69c..f93ae69 100644 --- a/docs/examples/java/account/update-phone-verification.md +++ b/docs/examples/java/account/update-phone-verification.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-phone.md b/docs/examples/java/account/update-phone.md index b3ce0f6..fae9bfa 100644 --- a/docs/examples/java/account/update-phone.md +++ b/docs/examples/java/account/update-phone.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-prefs.md b/docs/examples/java/account/update-prefs.md index d746067..f1a16c7 100644 --- a/docs/examples/java/account/update-prefs.md +++ b/docs/examples/java/account/update-prefs.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-push-target.md b/docs/examples/java/account/update-push-target.md index f9491e0..197a909 100644 --- a/docs/examples/java/account/update-push-target.md +++ b/docs/examples/java/account/update-push-target.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-recovery.md b/docs/examples/java/account/update-recovery.md index e172f12..953bde4 100644 --- a/docs/examples/java/account/update-recovery.md +++ b/docs/examples/java/account/update-recovery.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-session.md b/docs/examples/java/account/update-session.md index b3e8706..ed82840 100644 --- a/docs/examples/java/account/update-session.md +++ b/docs/examples/java/account/update-session.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-status.md b/docs/examples/java/account/update-status.md index 2216649..9a283c0 100644 --- a/docs/examples/java/account/update-status.md +++ b/docs/examples/java/account/update-status.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/account/update-verification.md b/docs/examples/java/account/update-verification.md index 2594943..caa3869 100644 --- a/docs/examples/java/account/update-verification.md +++ b/docs/examples/java/account/update-verification.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Account; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Account account = new Account(client); diff --git a/docs/examples/java/avatars/get-browser.md b/docs/examples/java/avatars/get-browser.md index f7e8651..4c85796 100644 --- a/docs/examples/java/avatars/get-browser.md +++ b/docs/examples/java/avatars/get-browser.md @@ -4,7 +4,7 @@ import io.appwrite.services.Avatars; import io.appwrite.enums.Browser; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-credit-card.md b/docs/examples/java/avatars/get-credit-card.md index 5b1ee06..a8bc303 100644 --- a/docs/examples/java/avatars/get-credit-card.md +++ b/docs/examples/java/avatars/get-credit-card.md @@ -4,7 +4,7 @@ import io.appwrite.services.Avatars; import io.appwrite.enums.CreditCard; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-favicon.md b/docs/examples/java/avatars/get-favicon.md index 05bf590..70373a6 100644 --- a/docs/examples/java/avatars/get-favicon.md +++ b/docs/examples/java/avatars/get-favicon.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Avatars; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-flag.md b/docs/examples/java/avatars/get-flag.md index 6a2185c..61ced3b 100644 --- a/docs/examples/java/avatars/get-flag.md +++ b/docs/examples/java/avatars/get-flag.md @@ -4,7 +4,7 @@ import io.appwrite.services.Avatars; import io.appwrite.enums.Flag; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-image.md b/docs/examples/java/avatars/get-image.md index 78fbf98..71a90dd 100644 --- a/docs/examples/java/avatars/get-image.md +++ b/docs/examples/java/avatars/get-image.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Avatars; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-initials.md b/docs/examples/java/avatars/get-initials.md index 621798b..ca16ee7 100644 --- a/docs/examples/java/avatars/get-initials.md +++ b/docs/examples/java/avatars/get-initials.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Avatars; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/avatars/get-q-r.md b/docs/examples/java/avatars/get-q-r.md index fc8bc43..781acf6 100644 --- a/docs/examples/java/avatars/get-q-r.md +++ b/docs/examples/java/avatars/get-q-r.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Avatars; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Avatars avatars = new Avatars(client); diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index 6c7e068..4804d75 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Databases; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Databases databases = new Databases(client); diff --git a/docs/examples/java/databases/delete-document.md b/docs/examples/java/databases/delete-document.md index 0cbd6b5..5288e53 100644 --- a/docs/examples/java/databases/delete-document.md +++ b/docs/examples/java/databases/delete-document.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Databases; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Databases databases = new Databases(client); diff --git a/docs/examples/java/databases/get-document.md b/docs/examples/java/databases/get-document.md index 0918c88..e7ae207 100644 --- a/docs/examples/java/databases/get-document.md +++ b/docs/examples/java/databases/get-document.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Databases; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Databases databases = new Databases(client); diff --git a/docs/examples/java/databases/list-documents.md b/docs/examples/java/databases/list-documents.md index 9cc722b..606d677 100644 --- a/docs/examples/java/databases/list-documents.md +++ b/docs/examples/java/databases/list-documents.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Databases; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Databases databases = new Databases(client); diff --git a/docs/examples/java/databases/update-document.md b/docs/examples/java/databases/update-document.md index ccfb498..baa827c 100644 --- a/docs/examples/java/databases/update-document.md +++ b/docs/examples/java/databases/update-document.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Databases; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Databases databases = new Databases(client); diff --git a/docs/examples/java/functions/create-execution.md b/docs/examples/java/functions/create-execution.md index 845f02e..c138b0e 100644 --- a/docs/examples/java/functions/create-execution.md +++ b/docs/examples/java/functions/create-execution.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Functions; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Functions functions = new Functions(client); diff --git a/docs/examples/java/functions/get-execution.md b/docs/examples/java/functions/get-execution.md index c53ef0e..f3195fa 100644 --- a/docs/examples/java/functions/get-execution.md +++ b/docs/examples/java/functions/get-execution.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Functions; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Functions functions = new Functions(client); diff --git a/docs/examples/java/functions/list-executions.md b/docs/examples/java/functions/list-executions.md index b796dc9..f23e5fb 100644 --- a/docs/examples/java/functions/list-executions.md +++ b/docs/examples/java/functions/list-executions.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Functions; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Functions functions = new Functions(client); diff --git a/docs/examples/java/graphql/mutation.md b/docs/examples/java/graphql/mutation.md index b79903b..25f095e 100644 --- a/docs/examples/java/graphql/mutation.md +++ b/docs/examples/java/graphql/mutation.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Graphql; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Graphql graphql = new Graphql(client); diff --git a/docs/examples/java/graphql/query.md b/docs/examples/java/graphql/query.md index 82bad13..6b2a04d 100644 --- a/docs/examples/java/graphql/query.md +++ b/docs/examples/java/graphql/query.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Graphql; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Graphql graphql = new Graphql(client); diff --git a/docs/examples/java/locale/get.md b/docs/examples/java/locale/get.md index 29b542f..89e1e88 100644 --- a/docs/examples/java/locale/get.md +++ b/docs/examples/java/locale/get.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Locale; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-codes.md b/docs/examples/java/locale/list-codes.md index d8c9a0b..85a96fc 100644 --- a/docs/examples/java/locale/list-codes.md +++ b/docs/examples/java/locale/list-codes.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Locale; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-continents.md b/docs/examples/java/locale/list-continents.md index cf43045..6f4572d 100644 --- a/docs/examples/java/locale/list-continents.md +++ b/docs/examples/java/locale/list-continents.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Locale; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-countries-e-u.md b/docs/examples/java/locale/list-countries-e-u.md index b7b56ab..51458a9 100644 --- a/docs/examples/java/locale/list-countries-e-u.md +++ b/docs/examples/java/locale/list-countries-e-u.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Locale; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-countries-phones.md b/docs/examples/java/locale/list-countries-phones.md index c3598c0..93438d2 100644 --- a/docs/examples/java/locale/list-countries-phones.md +++ b/docs/examples/java/locale/list-countries-phones.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Locale; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-countries.md b/docs/examples/java/locale/list-countries.md index 91ac052..5cd5525 100644 --- a/docs/examples/java/locale/list-countries.md +++ b/docs/examples/java/locale/list-countries.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Locale; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-currencies.md b/docs/examples/java/locale/list-currencies.md index 5233004..d3ef02c 100644 --- a/docs/examples/java/locale/list-currencies.md +++ b/docs/examples/java/locale/list-currencies.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Locale; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/locale/list-languages.md b/docs/examples/java/locale/list-languages.md index 0f10563..0d72494 100644 --- a/docs/examples/java/locale/list-languages.md +++ b/docs/examples/java/locale/list-languages.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Locale; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Locale locale = new Locale(client); diff --git a/docs/examples/java/messaging/create-subscriber.md b/docs/examples/java/messaging/create-subscriber.md index e8fa79f..5616435 100644 --- a/docs/examples/java/messaging/create-subscriber.md +++ b/docs/examples/java/messaging/create-subscriber.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Messaging; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Messaging messaging = new Messaging(client); diff --git a/docs/examples/java/messaging/delete-subscriber.md b/docs/examples/java/messaging/delete-subscriber.md index 7e5b3d2..9adae5e 100644 --- a/docs/examples/java/messaging/delete-subscriber.md +++ b/docs/examples/java/messaging/delete-subscriber.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Messaging; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Messaging messaging = new Messaging(client); diff --git a/docs/examples/java/storage/create-file.md b/docs/examples/java/storage/create-file.md index bc9ebed..598e683 100644 --- a/docs/examples/java/storage/create-file.md +++ b/docs/examples/java/storage/create-file.md @@ -4,7 +4,7 @@ import io.appwrite.models.InputFile; import io.appwrite.services.Storage; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/delete-file.md b/docs/examples/java/storage/delete-file.md index eaeb47b..5c63ae7 100644 --- a/docs/examples/java/storage/delete-file.md +++ b/docs/examples/java/storage/delete-file.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Storage; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/get-file-download.md b/docs/examples/java/storage/get-file-download.md index d0fdc41..ce2b846 100644 --- a/docs/examples/java/storage/get-file-download.md +++ b/docs/examples/java/storage/get-file-download.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Storage; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/get-file-preview.md b/docs/examples/java/storage/get-file-preview.md index c935e6f..1f5e365 100644 --- a/docs/examples/java/storage/get-file-preview.md +++ b/docs/examples/java/storage/get-file-preview.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Storage; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/get-file-view.md b/docs/examples/java/storage/get-file-view.md index bbfd04d..cda3545 100644 --- a/docs/examples/java/storage/get-file-view.md +++ b/docs/examples/java/storage/get-file-view.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Storage; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/get-file.md b/docs/examples/java/storage/get-file.md index a63122f..c9cc00d 100644 --- a/docs/examples/java/storage/get-file.md +++ b/docs/examples/java/storage/get-file.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Storage; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/list-files.md b/docs/examples/java/storage/list-files.md index dc327fc..a87286c 100644 --- a/docs/examples/java/storage/list-files.md +++ b/docs/examples/java/storage/list-files.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Storage; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/storage/update-file.md b/docs/examples/java/storage/update-file.md index ed81821..14fa779 100644 --- a/docs/examples/java/storage/update-file.md +++ b/docs/examples/java/storage/update-file.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Storage; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Storage storage = new Storage(client); diff --git a/docs/examples/java/teams/create-membership.md b/docs/examples/java/teams/create-membership.md index b30f176..bb5293e 100644 --- a/docs/examples/java/teams/create-membership.md +++ b/docs/examples/java/teams/create-membership.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/create.md b/docs/examples/java/teams/create.md index a0d4f07..ae2fdf3 100644 --- a/docs/examples/java/teams/create.md +++ b/docs/examples/java/teams/create.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/delete-membership.md b/docs/examples/java/teams/delete-membership.md index 7f9189f..c8bb088 100644 --- a/docs/examples/java/teams/delete-membership.md +++ b/docs/examples/java/teams/delete-membership.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/delete.md b/docs/examples/java/teams/delete.md index 2f4e861..74f6a4f 100644 --- a/docs/examples/java/teams/delete.md +++ b/docs/examples/java/teams/delete.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/get-membership.md b/docs/examples/java/teams/get-membership.md index 529feb2..e9dc578 100644 --- a/docs/examples/java/teams/get-membership.md +++ b/docs/examples/java/teams/get-membership.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/get-prefs.md b/docs/examples/java/teams/get-prefs.md index 61da757..8ba1435 100644 --- a/docs/examples/java/teams/get-prefs.md +++ b/docs/examples/java/teams/get-prefs.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/get.md b/docs/examples/java/teams/get.md index 39fe4d4..f00057a 100644 --- a/docs/examples/java/teams/get.md +++ b/docs/examples/java/teams/get.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/list-memberships.md b/docs/examples/java/teams/list-memberships.md index 58430f0..216ca40 100644 --- a/docs/examples/java/teams/list-memberships.md +++ b/docs/examples/java/teams/list-memberships.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/list.md b/docs/examples/java/teams/list.md index 914509f..b69f21e 100644 --- a/docs/examples/java/teams/list.md +++ b/docs/examples/java/teams/list.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/update-membership-status.md b/docs/examples/java/teams/update-membership-status.md index 5134613..4b31ed5 100644 --- a/docs/examples/java/teams/update-membership-status.md +++ b/docs/examples/java/teams/update-membership-status.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/update-membership.md b/docs/examples/java/teams/update-membership.md index a60c2a0..481be43 100644 --- a/docs/examples/java/teams/update-membership.md +++ b/docs/examples/java/teams/update-membership.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/update-name.md b/docs/examples/java/teams/update-name.md index 54f218e..207bcc8 100644 --- a/docs/examples/java/teams/update-name.md +++ b/docs/examples/java/teams/update-name.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/java/teams/update-prefs.md b/docs/examples/java/teams/update-prefs.md index eaa161e..5a0186f 100644 --- a/docs/examples/java/teams/update-prefs.md +++ b/docs/examples/java/teams/update-prefs.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Teams; Client client = new Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID Teams teams = new Teams(client); diff --git a/docs/examples/kotlin/account/create-anonymous-session.md b/docs/examples/kotlin/account/create-anonymous-session.md index 50a011a..d2966a1 100644 --- a/docs/examples/kotlin/account/create-anonymous-session.md +++ b/docs/examples/kotlin/account/create-anonymous-session.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-email-password-session.md b/docs/examples/kotlin/account/create-email-password-session.md index 8c44759..a327cf2 100644 --- a/docs/examples/kotlin/account/create-email-password-session.md +++ b/docs/examples/kotlin/account/create-email-password-session.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-email-token.md b/docs/examples/kotlin/account/create-email-token.md index 219e793..37c9e1b 100644 --- a/docs/examples/kotlin/account/create-email-token.md +++ b/docs/examples/kotlin/account/create-email-token.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-j-w-t.md b/docs/examples/kotlin/account/create-j-w-t.md index 50014d4..c87eaf3 100644 --- a/docs/examples/kotlin/account/create-j-w-t.md +++ b/docs/examples/kotlin/account/create-j-w-t.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-magic-u-r-l-token.md b/docs/examples/kotlin/account/create-magic-u-r-l-token.md index 905e942..76f4c91 100644 --- a/docs/examples/kotlin/account/create-magic-u-r-l-token.md +++ b/docs/examples/kotlin/account/create-magic-u-r-l-token.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-mfa-authenticator.md b/docs/examples/kotlin/account/create-mfa-authenticator.md index dacf56a..ffb2f2f 100644 --- a/docs/examples/kotlin/account/create-mfa-authenticator.md +++ b/docs/examples/kotlin/account/create-mfa-authenticator.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account import io.appwrite.enums.AuthenticatorType val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-mfa-challenge.md b/docs/examples/kotlin/account/create-mfa-challenge.md index 22c9658..36b12d3 100644 --- a/docs/examples/kotlin/account/create-mfa-challenge.md +++ b/docs/examples/kotlin/account/create-mfa-challenge.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account import io.appwrite.enums.AuthenticationFactor val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-mfa-recovery-codes.md b/docs/examples/kotlin/account/create-mfa-recovery-codes.md index 364bc0e..974c8f2 100644 --- a/docs/examples/kotlin/account/create-mfa-recovery-codes.md +++ b/docs/examples/kotlin/account/create-mfa-recovery-codes.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-o-auth2session.md b/docs/examples/kotlin/account/create-o-auth2session.md index fc9d822..61ea634 100644 --- a/docs/examples/kotlin/account/create-o-auth2session.md +++ b/docs/examples/kotlin/account/create-o-auth2session.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account import io.appwrite.enums.OAuthProvider val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-o-auth2token.md b/docs/examples/kotlin/account/create-o-auth2token.md index 11a814b..cdd2ef3 100644 --- a/docs/examples/kotlin/account/create-o-auth2token.md +++ b/docs/examples/kotlin/account/create-o-auth2token.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account import io.appwrite.enums.OAuthProvider val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-phone-token.md b/docs/examples/kotlin/account/create-phone-token.md index 56b53c2..4eb1a9a 100644 --- a/docs/examples/kotlin/account/create-phone-token.md +++ b/docs/examples/kotlin/account/create-phone-token.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-phone-verification.md b/docs/examples/kotlin/account/create-phone-verification.md index 531aead..f759466 100644 --- a/docs/examples/kotlin/account/create-phone-verification.md +++ b/docs/examples/kotlin/account/create-phone-verification.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-push-target.md b/docs/examples/kotlin/account/create-push-target.md index 7dd2101..59b252b 100644 --- a/docs/examples/kotlin/account/create-push-target.md +++ b/docs/examples/kotlin/account/create-push-target.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-recovery.md b/docs/examples/kotlin/account/create-recovery.md index d03bd32..7e13138 100644 --- a/docs/examples/kotlin/account/create-recovery.md +++ b/docs/examples/kotlin/account/create-recovery.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-session.md b/docs/examples/kotlin/account/create-session.md index 2b3da6d..ab9e20e 100644 --- a/docs/examples/kotlin/account/create-session.md +++ b/docs/examples/kotlin/account/create-session.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create-verification.md b/docs/examples/kotlin/account/create-verification.md index 54174be..669b00b 100644 --- a/docs/examples/kotlin/account/create-verification.md +++ b/docs/examples/kotlin/account/create-verification.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/create.md b/docs/examples/kotlin/account/create.md index 2ee3ae4..16f3a60 100644 --- a/docs/examples/kotlin/account/create.md +++ b/docs/examples/kotlin/account/create.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/delete-identity.md b/docs/examples/kotlin/account/delete-identity.md index 1e5d206..c8d7463 100644 --- a/docs/examples/kotlin/account/delete-identity.md +++ b/docs/examples/kotlin/account/delete-identity.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/delete-mfa-authenticator.md b/docs/examples/kotlin/account/delete-mfa-authenticator.md index 48220b2..057e021 100644 --- a/docs/examples/kotlin/account/delete-mfa-authenticator.md +++ b/docs/examples/kotlin/account/delete-mfa-authenticator.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account import io.appwrite.enums.AuthenticatorType val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/delete-push-target.md b/docs/examples/kotlin/account/delete-push-target.md index e67b180..8e0b418 100644 --- a/docs/examples/kotlin/account/delete-push-target.md +++ b/docs/examples/kotlin/account/delete-push-target.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/delete-session.md b/docs/examples/kotlin/account/delete-session.md index 0990989..6af414b 100644 --- a/docs/examples/kotlin/account/delete-session.md +++ b/docs/examples/kotlin/account/delete-session.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/delete-sessions.md b/docs/examples/kotlin/account/delete-sessions.md index 8c464e0..f7e6c71 100644 --- a/docs/examples/kotlin/account/delete-sessions.md +++ b/docs/examples/kotlin/account/delete-sessions.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/get-mfa-recovery-codes.md b/docs/examples/kotlin/account/get-mfa-recovery-codes.md index bd12e83..6201658 100644 --- a/docs/examples/kotlin/account/get-mfa-recovery-codes.md +++ b/docs/examples/kotlin/account/get-mfa-recovery-codes.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/get-prefs.md b/docs/examples/kotlin/account/get-prefs.md index 9227eff..85dbb18 100644 --- a/docs/examples/kotlin/account/get-prefs.md +++ b/docs/examples/kotlin/account/get-prefs.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/get-session.md b/docs/examples/kotlin/account/get-session.md index 42e61fd..4de64a1 100644 --- a/docs/examples/kotlin/account/get-session.md +++ b/docs/examples/kotlin/account/get-session.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/get.md b/docs/examples/kotlin/account/get.md index 8c90304..3e85e79 100644 --- a/docs/examples/kotlin/account/get.md +++ b/docs/examples/kotlin/account/get.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/list-identities.md b/docs/examples/kotlin/account/list-identities.md index 53e388d..5908a44 100644 --- a/docs/examples/kotlin/account/list-identities.md +++ b/docs/examples/kotlin/account/list-identities.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/list-logs.md b/docs/examples/kotlin/account/list-logs.md index 683a94b..385ccc0 100644 --- a/docs/examples/kotlin/account/list-logs.md +++ b/docs/examples/kotlin/account/list-logs.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/list-mfa-factors.md b/docs/examples/kotlin/account/list-mfa-factors.md index ecfa6c2..09119ab 100644 --- a/docs/examples/kotlin/account/list-mfa-factors.md +++ b/docs/examples/kotlin/account/list-mfa-factors.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/list-sessions.md b/docs/examples/kotlin/account/list-sessions.md index 2da413d..573dd86 100644 --- a/docs/examples/kotlin/account/list-sessions.md +++ b/docs/examples/kotlin/account/list-sessions.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-email.md b/docs/examples/kotlin/account/update-email.md index 072d6db..0862f11 100644 --- a/docs/examples/kotlin/account/update-email.md +++ b/docs/examples/kotlin/account/update-email.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-m-f-a.md b/docs/examples/kotlin/account/update-m-f-a.md index 3cac098..f214e78 100644 --- a/docs/examples/kotlin/account/update-m-f-a.md +++ b/docs/examples/kotlin/account/update-m-f-a.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) 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 52d0ad7..2c1a0b0 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 @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-mfa-authenticator.md b/docs/examples/kotlin/account/update-mfa-authenticator.md index 321f25b..987825e 100644 --- a/docs/examples/kotlin/account/update-mfa-authenticator.md +++ b/docs/examples/kotlin/account/update-mfa-authenticator.md @@ -4,7 +4,7 @@ import io.appwrite.services.Account import io.appwrite.enums.AuthenticatorType val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-mfa-challenge.md b/docs/examples/kotlin/account/update-mfa-challenge.md index 021f515..c7f8139 100644 --- a/docs/examples/kotlin/account/update-mfa-challenge.md +++ b/docs/examples/kotlin/account/update-mfa-challenge.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-mfa-recovery-codes.md b/docs/examples/kotlin/account/update-mfa-recovery-codes.md index d4ea7f5..c0ee3c3 100644 --- a/docs/examples/kotlin/account/update-mfa-recovery-codes.md +++ b/docs/examples/kotlin/account/update-mfa-recovery-codes.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-name.md b/docs/examples/kotlin/account/update-name.md index 374f84f..2cb5327 100644 --- a/docs/examples/kotlin/account/update-name.md +++ b/docs/examples/kotlin/account/update-name.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-password.md b/docs/examples/kotlin/account/update-password.md index edf5117..140ca8b 100644 --- a/docs/examples/kotlin/account/update-password.md +++ b/docs/examples/kotlin/account/update-password.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-phone-session.md b/docs/examples/kotlin/account/update-phone-session.md index 93e080d..b3911dd 100644 --- a/docs/examples/kotlin/account/update-phone-session.md +++ b/docs/examples/kotlin/account/update-phone-session.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-phone-verification.md b/docs/examples/kotlin/account/update-phone-verification.md index 226b21d..ad0d5d7 100644 --- a/docs/examples/kotlin/account/update-phone-verification.md +++ b/docs/examples/kotlin/account/update-phone-verification.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-phone.md b/docs/examples/kotlin/account/update-phone.md index 772c099..84ff508 100644 --- a/docs/examples/kotlin/account/update-phone.md +++ b/docs/examples/kotlin/account/update-phone.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-prefs.md b/docs/examples/kotlin/account/update-prefs.md index c5c7a3d..fdfed57 100644 --- a/docs/examples/kotlin/account/update-prefs.md +++ b/docs/examples/kotlin/account/update-prefs.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-push-target.md b/docs/examples/kotlin/account/update-push-target.md index c6e6f21..5c38168 100644 --- a/docs/examples/kotlin/account/update-push-target.md +++ b/docs/examples/kotlin/account/update-push-target.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-recovery.md b/docs/examples/kotlin/account/update-recovery.md index b448114..d505d1a 100644 --- a/docs/examples/kotlin/account/update-recovery.md +++ b/docs/examples/kotlin/account/update-recovery.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-session.md b/docs/examples/kotlin/account/update-session.md index 43d84e1..6fc9a9f 100644 --- a/docs/examples/kotlin/account/update-session.md +++ b/docs/examples/kotlin/account/update-session.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-status.md b/docs/examples/kotlin/account/update-status.md index 4f44ce1..b86a25a 100644 --- a/docs/examples/kotlin/account/update-status.md +++ b/docs/examples/kotlin/account/update-status.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/account/update-verification.md b/docs/examples/kotlin/account/update-verification.md index 3c9c465..028eb7c 100644 --- a/docs/examples/kotlin/account/update-verification.md +++ b/docs/examples/kotlin/account/update-verification.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val account = Account(client) diff --git a/docs/examples/kotlin/avatars/get-browser.md b/docs/examples/kotlin/avatars/get-browser.md index 34f6f28..4e2f5e0 100644 --- a/docs/examples/kotlin/avatars/get-browser.md +++ b/docs/examples/kotlin/avatars/get-browser.md @@ -4,7 +4,7 @@ import io.appwrite.services.Avatars import io.appwrite.enums.Browser val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-credit-card.md b/docs/examples/kotlin/avatars/get-credit-card.md index 52eea79..91aae45 100644 --- a/docs/examples/kotlin/avatars/get-credit-card.md +++ b/docs/examples/kotlin/avatars/get-credit-card.md @@ -4,7 +4,7 @@ import io.appwrite.services.Avatars import io.appwrite.enums.CreditCard val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-favicon.md b/docs/examples/kotlin/avatars/get-favicon.md index 5f83bdd..01df8cb 100644 --- a/docs/examples/kotlin/avatars/get-favicon.md +++ b/docs/examples/kotlin/avatars/get-favicon.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-flag.md b/docs/examples/kotlin/avatars/get-flag.md index cfd5d01..1d8f5f6 100644 --- a/docs/examples/kotlin/avatars/get-flag.md +++ b/docs/examples/kotlin/avatars/get-flag.md @@ -4,7 +4,7 @@ import io.appwrite.services.Avatars import io.appwrite.enums.Flag val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-image.md b/docs/examples/kotlin/avatars/get-image.md index a9a7c2a..64166c0 100644 --- a/docs/examples/kotlin/avatars/get-image.md +++ b/docs/examples/kotlin/avatars/get-image.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-initials.md b/docs/examples/kotlin/avatars/get-initials.md index bd2ae1b..883da02 100644 --- a/docs/examples/kotlin/avatars/get-initials.md +++ b/docs/examples/kotlin/avatars/get-initials.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/avatars/get-q-r.md b/docs/examples/kotlin/avatars/get-q-r.md index 9e02a0c..fa8a38c 100644 --- a/docs/examples/kotlin/avatars/get-q-r.md +++ b/docs/examples/kotlin/avatars/get-q-r.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val avatars = Avatars(client) diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index 2b77405..849a636 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Databases val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val databases = Databases(client) diff --git a/docs/examples/kotlin/databases/delete-document.md b/docs/examples/kotlin/databases/delete-document.md index e3e6de3..052bf97 100644 --- a/docs/examples/kotlin/databases/delete-document.md +++ b/docs/examples/kotlin/databases/delete-document.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Databases val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val databases = Databases(client) diff --git a/docs/examples/kotlin/databases/get-document.md b/docs/examples/kotlin/databases/get-document.md index 6ed6c8b..157af2b 100644 --- a/docs/examples/kotlin/databases/get-document.md +++ b/docs/examples/kotlin/databases/get-document.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Databases val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val databases = Databases(client) diff --git a/docs/examples/kotlin/databases/list-documents.md b/docs/examples/kotlin/databases/list-documents.md index ff419c4..1cc785f 100644 --- a/docs/examples/kotlin/databases/list-documents.md +++ b/docs/examples/kotlin/databases/list-documents.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Databases val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val databases = Databases(client) diff --git a/docs/examples/kotlin/databases/update-document.md b/docs/examples/kotlin/databases/update-document.md index 630e2b6..d61fdea 100644 --- a/docs/examples/kotlin/databases/update-document.md +++ b/docs/examples/kotlin/databases/update-document.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Databases val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val databases = Databases(client) diff --git a/docs/examples/kotlin/functions/create-execution.md b/docs/examples/kotlin/functions/create-execution.md index 937bb4f..cb7c60b 100644 --- a/docs/examples/kotlin/functions/create-execution.md +++ b/docs/examples/kotlin/functions/create-execution.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Functions val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val functions = Functions(client) diff --git a/docs/examples/kotlin/functions/get-execution.md b/docs/examples/kotlin/functions/get-execution.md index 60b2e0f..267be53 100644 --- a/docs/examples/kotlin/functions/get-execution.md +++ b/docs/examples/kotlin/functions/get-execution.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Functions val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val functions = Functions(client) diff --git a/docs/examples/kotlin/functions/list-executions.md b/docs/examples/kotlin/functions/list-executions.md index 90b2bf6..a56993f 100644 --- a/docs/examples/kotlin/functions/list-executions.md +++ b/docs/examples/kotlin/functions/list-executions.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Functions val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val functions = Functions(client) diff --git a/docs/examples/kotlin/graphql/mutation.md b/docs/examples/kotlin/graphql/mutation.md index e90c9ae..a3a7622 100644 --- a/docs/examples/kotlin/graphql/mutation.md +++ b/docs/examples/kotlin/graphql/mutation.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Graphql val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val graphql = Graphql(client) diff --git a/docs/examples/kotlin/graphql/query.md b/docs/examples/kotlin/graphql/query.md index 2ce0cb1..13f149c 100644 --- a/docs/examples/kotlin/graphql/query.md +++ b/docs/examples/kotlin/graphql/query.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Graphql val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val graphql = Graphql(client) diff --git a/docs/examples/kotlin/locale/get.md b/docs/examples/kotlin/locale/get.md index f2f235a..a116aed 100644 --- a/docs/examples/kotlin/locale/get.md +++ b/docs/examples/kotlin/locale/get.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-codes.md b/docs/examples/kotlin/locale/list-codes.md index 895c96d..0b63b06 100644 --- a/docs/examples/kotlin/locale/list-codes.md +++ b/docs/examples/kotlin/locale/list-codes.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-continents.md b/docs/examples/kotlin/locale/list-continents.md index e320344..98acdc9 100644 --- a/docs/examples/kotlin/locale/list-continents.md +++ b/docs/examples/kotlin/locale/list-continents.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-countries-e-u.md b/docs/examples/kotlin/locale/list-countries-e-u.md index b9182aa..c016025 100644 --- a/docs/examples/kotlin/locale/list-countries-e-u.md +++ b/docs/examples/kotlin/locale/list-countries-e-u.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-countries-phones.md b/docs/examples/kotlin/locale/list-countries-phones.md index 961ebd3..d95c1c6 100644 --- a/docs/examples/kotlin/locale/list-countries-phones.md +++ b/docs/examples/kotlin/locale/list-countries-phones.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-countries.md b/docs/examples/kotlin/locale/list-countries.md index 1ebae69..4775161 100644 --- a/docs/examples/kotlin/locale/list-countries.md +++ b/docs/examples/kotlin/locale/list-countries.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-currencies.md b/docs/examples/kotlin/locale/list-currencies.md index 7500aa7..6d0a04f 100644 --- a/docs/examples/kotlin/locale/list-currencies.md +++ b/docs/examples/kotlin/locale/list-currencies.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/locale/list-languages.md b/docs/examples/kotlin/locale/list-languages.md index 2be0ba5..de588aa 100644 --- a/docs/examples/kotlin/locale/list-languages.md +++ b/docs/examples/kotlin/locale/list-languages.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Locale val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val locale = Locale(client) diff --git a/docs/examples/kotlin/messaging/create-subscriber.md b/docs/examples/kotlin/messaging/create-subscriber.md index db23342..b7e244f 100644 --- a/docs/examples/kotlin/messaging/create-subscriber.md +++ b/docs/examples/kotlin/messaging/create-subscriber.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Messaging val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val messaging = Messaging(client) diff --git a/docs/examples/kotlin/messaging/delete-subscriber.md b/docs/examples/kotlin/messaging/delete-subscriber.md index ab0d479..9e102d6 100644 --- a/docs/examples/kotlin/messaging/delete-subscriber.md +++ b/docs/examples/kotlin/messaging/delete-subscriber.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Messaging val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val messaging = Messaging(client) diff --git a/docs/examples/kotlin/storage/create-file.md b/docs/examples/kotlin/storage/create-file.md index d327e72..1c78c51 100644 --- a/docs/examples/kotlin/storage/create-file.md +++ b/docs/examples/kotlin/storage/create-file.md @@ -4,7 +4,7 @@ import io.appwrite.models.InputFile import io.appwrite.services.Storage val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/delete-file.md b/docs/examples/kotlin/storage/delete-file.md index 60df78e..ca40f41 100644 --- a/docs/examples/kotlin/storage/delete-file.md +++ b/docs/examples/kotlin/storage/delete-file.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/get-file-download.md b/docs/examples/kotlin/storage/get-file-download.md index bb97541..b4d3386 100644 --- a/docs/examples/kotlin/storage/get-file-download.md +++ b/docs/examples/kotlin/storage/get-file-download.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/get-file-preview.md b/docs/examples/kotlin/storage/get-file-preview.md index 904f3ec..31aa6e2 100644 --- a/docs/examples/kotlin/storage/get-file-preview.md +++ b/docs/examples/kotlin/storage/get-file-preview.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/get-file-view.md b/docs/examples/kotlin/storage/get-file-view.md index 898c1ee..7a5b31d 100644 --- a/docs/examples/kotlin/storage/get-file-view.md +++ b/docs/examples/kotlin/storage/get-file-view.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/get-file.md b/docs/examples/kotlin/storage/get-file.md index a07095d..1e99430 100644 --- a/docs/examples/kotlin/storage/get-file.md +++ b/docs/examples/kotlin/storage/get-file.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/list-files.md b/docs/examples/kotlin/storage/list-files.md index 640b705..06f6cda 100644 --- a/docs/examples/kotlin/storage/list-files.md +++ b/docs/examples/kotlin/storage/list-files.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/storage/update-file.md b/docs/examples/kotlin/storage/update-file.md index f7a20f0..116d156 100644 --- a/docs/examples/kotlin/storage/update-file.md +++ b/docs/examples/kotlin/storage/update-file.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Storage val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val storage = Storage(client) diff --git a/docs/examples/kotlin/teams/create-membership.md b/docs/examples/kotlin/teams/create-membership.md index 63f3c67..70eb7dd 100644 --- a/docs/examples/kotlin/teams/create-membership.md +++ b/docs/examples/kotlin/teams/create-membership.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/create.md b/docs/examples/kotlin/teams/create.md index f214a37..dfa4df4 100644 --- a/docs/examples/kotlin/teams/create.md +++ b/docs/examples/kotlin/teams/create.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/delete-membership.md b/docs/examples/kotlin/teams/delete-membership.md index f3a54b3..adf1119 100644 --- a/docs/examples/kotlin/teams/delete-membership.md +++ b/docs/examples/kotlin/teams/delete-membership.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/delete.md b/docs/examples/kotlin/teams/delete.md index bc8e8d0..e144a78 100644 --- a/docs/examples/kotlin/teams/delete.md +++ b/docs/examples/kotlin/teams/delete.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/get-membership.md b/docs/examples/kotlin/teams/get-membership.md index e5a589e..8fb8c54 100644 --- a/docs/examples/kotlin/teams/get-membership.md +++ b/docs/examples/kotlin/teams/get-membership.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/get-prefs.md b/docs/examples/kotlin/teams/get-prefs.md index af7503a..5e892fb 100644 --- a/docs/examples/kotlin/teams/get-prefs.md +++ b/docs/examples/kotlin/teams/get-prefs.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/get.md b/docs/examples/kotlin/teams/get.md index 70759bc..dbb487d 100644 --- a/docs/examples/kotlin/teams/get.md +++ b/docs/examples/kotlin/teams/get.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/list-memberships.md b/docs/examples/kotlin/teams/list-memberships.md index abb140e..e305403 100644 --- a/docs/examples/kotlin/teams/list-memberships.md +++ b/docs/examples/kotlin/teams/list-memberships.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/list.md b/docs/examples/kotlin/teams/list.md index 5d80873..984858d 100644 --- a/docs/examples/kotlin/teams/list.md +++ b/docs/examples/kotlin/teams/list.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/update-membership-status.md b/docs/examples/kotlin/teams/update-membership-status.md index 9ecf417..c3770c7 100644 --- a/docs/examples/kotlin/teams/update-membership-status.md +++ b/docs/examples/kotlin/teams/update-membership-status.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/update-membership.md b/docs/examples/kotlin/teams/update-membership.md index 15b2ac0..86216a8 100644 --- a/docs/examples/kotlin/teams/update-membership.md +++ b/docs/examples/kotlin/teams/update-membership.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/update-name.md b/docs/examples/kotlin/teams/update-name.md index 0040737..abeb6dc 100644 --- a/docs/examples/kotlin/teams/update-name.md +++ b/docs/examples/kotlin/teams/update-name.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val teams = Teams(client) diff --git a/docs/examples/kotlin/teams/update-prefs.md b/docs/examples/kotlin/teams/update-prefs.md index f70a5eb..d0066a9 100644 --- a/docs/examples/kotlin/teams/update-prefs.md +++ b/docs/examples/kotlin/teams/update-prefs.md @@ -3,7 +3,7 @@ import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Teams val client = Client(context) - .setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID val teams = Teams(client) diff --git a/example/src/main/java/io/appwrite/android/utils/Client.kt b/example/src/main/java/io/appwrite/android/utils/Client.kt index 027b718..f62869b 100644 --- a/example/src/main/java/io/appwrite/android/utils/Client.kt +++ b/example/src/main/java/io/appwrite/android/utils/Client.kt @@ -8,7 +8,7 @@ object Client { fun create(context: Context) { client = Client(context) - .setEndpoint("http://192.168.4.24/v1") + .setEndpoint("https://.cloud.appwrite.io/v1") .setProject("65a8e2b4632c04b1f5da") .setSelfSigned(true) } diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 4a51694..909e62f 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -39,7 +39,7 @@ import kotlin.coroutines.resume class Client @JvmOverloads constructor( context: Context, - var endpoint: String = "https://<REGION>.cloud.appwrite.io/v1", + var endpoint: String = "https://cloud.appwrite.io/v1", var endpointRealtime: String? = null, private var selfSigned: Boolean = false ) : CoroutineScope { From 4d7524d625173c1c0d0f0d30e3fa1a70dfbc2a73 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Sun, 18 May 2025 00:02:51 +1200 Subject: [PATCH 097/118] Add support for 1.7 --- README.md | 8 +-- docs/examples/java/avatars/get-browser.md | 2 +- docs/examples/java/avatars/get-credit-card.md | 2 +- docs/examples/java/avatars/get-flag.md | 2 +- .../java/databases/create-document.md | 4 +- .../java/databases/create-documents.md | 24 ++++++++ .../java/functions/list-executions.md | 1 - .../java/storage/get-file-download.md | 1 + .../examples/java/storage/get-file-preview.md | 3 +- docs/examples/java/storage/get-file-view.md | 1 + docs/examples/kotlin/avatars/get-browser.md | 2 +- .../kotlin/avatars/get-credit-card.md | 2 +- docs/examples/kotlin/avatars/get-flag.md | 2 +- .../kotlin/databases/create-document.md | 4 +- .../kotlin/databases/create-documents.md | 15 +++++ .../kotlin/functions/list-executions.md | 1 - .../kotlin/storage/get-file-download.md | 1 + .../kotlin/storage/get-file-preview.md | 3 +- docs/examples/kotlin/storage/get-file-view.md | 1 + library/src/main/java/io/appwrite/Client.kt | 4 +- .../java/io/appwrite/enums/ImageFormat.kt | 2 - .../main/java/io/appwrite/models/Execution.kt | 2 +- .../main/java/io/appwrite/services/Avatars.kt | 6 +- .../java/io/appwrite/services/Databases.kt | 58 +++++++++++++++++++ .../java/io/appwrite/services/Functions.kt | 3 - .../main/java/io/appwrite/services/Storage.kt | 13 ++++- .../main/java/io/appwrite/services/Teams.kt | 2 +- 27 files changed, 140 insertions(+), 29 deletions(-) create mode 100644 docs/examples/java/databases/create-documents.md create mode 100644 docs/examples/kotlin/databases/create-documents.md diff --git a/README.md b/README.md index 9edac18..4abf758 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.6.2-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.7.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.6.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.7.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:7.0.1") +implementation("io.appwrite:sdk-for-android:7.1.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 7.0.1 + 7.1.0 ``` diff --git a/docs/examples/java/avatars/get-browser.md b/docs/examples/java/avatars/get-browser.md index 4c85796..1b6632f 100644 --- a/docs/examples/java/avatars/get-browser.md +++ b/docs/examples/java/avatars/get-browser.md @@ -13,7 +13,7 @@ avatars.getBrowser( Browser.AVANT_BROWSER, // code 0, // width (optional) 0, // height (optional) - 0, // quality (optional) + -1, // quality (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/avatars/get-credit-card.md b/docs/examples/java/avatars/get-credit-card.md index a8bc303..e2ac2c2 100644 --- a/docs/examples/java/avatars/get-credit-card.md +++ b/docs/examples/java/avatars/get-credit-card.md @@ -13,7 +13,7 @@ avatars.getCreditCard( CreditCard.AMERICAN_EXPRESS, // code 0, // width (optional) 0, // height (optional) - 0, // quality (optional) + -1, // quality (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/avatars/get-flag.md b/docs/examples/java/avatars/get-flag.md index 61ced3b..689e27f 100644 --- a/docs/examples/java/avatars/get-flag.md +++ b/docs/examples/java/avatars/get-flag.md @@ -13,7 +13,7 @@ avatars.getFlag( Flag.AFGHANISTAN, // code 0, // width (optional) 0, // height (optional) - 0, // quality (optional) + -1, // quality (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index 4804d75..7fb129b 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -4,7 +4,9 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID + .setSession("") // The user session to authenticate with + .setKey("") // + .setJWT(""); // Your secret JSON Web Token Databases databases = new Databases(client); diff --git a/docs/examples/java/databases/create-documents.md b/docs/examples/java/databases/create-documents.md new file mode 100644 index 0000000..dbdc64f --- /dev/null +++ b/docs/examples/java/databases/create-documents.md @@ -0,0 +1,24 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setKey(""); // + +Databases databases = new Databases(client); + +databases.createDocuments( + "", // databaseId + "", // collectionId + listOf(), // documents + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/functions/list-executions.md b/docs/examples/java/functions/list-executions.md index f23e5fb..0270cf0 100644 --- a/docs/examples/java/functions/list-executions.md +++ b/docs/examples/java/functions/list-executions.md @@ -11,7 +11,6 @@ Functions functions = new Functions(client); functions.listExecutions( "", // functionId listOf(), // queries (optional) - "", // search (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/get-file-download.md b/docs/examples/java/storage/get-file-download.md index ce2b846..73a8617 100644 --- a/docs/examples/java/storage/get-file-download.md +++ b/docs/examples/java/storage/get-file-download.md @@ -11,6 +11,7 @@ Storage storage = new Storage(client); storage.getFileDownload( "", // bucketId "", // fileId + "", // token (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/get-file-preview.md b/docs/examples/java/storage/get-file-preview.md index 1f5e365..67b92eb 100644 --- a/docs/examples/java/storage/get-file-preview.md +++ b/docs/examples/java/storage/get-file-preview.md @@ -14,7 +14,7 @@ storage.getFilePreview( 0, // width (optional) 0, // height (optional) ImageGravity.CENTER, // gravity (optional) - 0, // quality (optional) + -1, // quality (optional) 0, // borderWidth (optional) "", // borderColor (optional) 0, // borderRadius (optional) @@ -22,6 +22,7 @@ storage.getFilePreview( -360, // rotation (optional) "", // background (optional) ImageFormat.JPG, // output (optional) + "", // token (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/storage/get-file-view.md b/docs/examples/java/storage/get-file-view.md index cda3545..b042b1f 100644 --- a/docs/examples/java/storage/get-file-view.md +++ b/docs/examples/java/storage/get-file-view.md @@ -11,6 +11,7 @@ Storage storage = new Storage(client); storage.getFileView( "", // bucketId "", // fileId + "", // token (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/kotlin/avatars/get-browser.md b/docs/examples/kotlin/avatars/get-browser.md index 4e2f5e0..d04adfb 100644 --- a/docs/examples/kotlin/avatars/get-browser.md +++ b/docs/examples/kotlin/avatars/get-browser.md @@ -13,5 +13,5 @@ val result = avatars.getBrowser( code = Browser.AVANT_BROWSER, width = 0, // (optional) height = 0, // (optional) - quality = 0, // (optional) + quality = -1, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-credit-card.md b/docs/examples/kotlin/avatars/get-credit-card.md index 91aae45..91c88da 100644 --- a/docs/examples/kotlin/avatars/get-credit-card.md +++ b/docs/examples/kotlin/avatars/get-credit-card.md @@ -13,5 +13,5 @@ val result = avatars.getCreditCard( code = CreditCard.AMERICAN_EXPRESS, width = 0, // (optional) height = 0, // (optional) - quality = 0, // (optional) + quality = -1, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/avatars/get-flag.md b/docs/examples/kotlin/avatars/get-flag.md index 1d8f5f6..1dbc1cd 100644 --- a/docs/examples/kotlin/avatars/get-flag.md +++ b/docs/examples/kotlin/avatars/get-flag.md @@ -13,5 +13,5 @@ val result = avatars.getFlag( code = Flag.AFGHANISTAN, width = 0, // (optional) height = 0, // (optional) - quality = 0, // (optional) + quality = -1, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index 849a636..0bafb31 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -4,7 +4,9 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID + .setSession("") // The user session to authenticate with + .setKey("") // + .setJWT("") // Your secret JSON Web Token val databases = Databases(client) diff --git a/docs/examples/kotlin/databases/create-documents.md b/docs/examples/kotlin/databases/create-documents.md new file mode 100644 index 0000000..33635b4 --- /dev/null +++ b/docs/examples/kotlin/databases/create-documents.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setKey("") // + +val databases = Databases(client) + +val result = databases.createDocuments( + databaseId = "", + collectionId = "", + documents = listOf(), +) \ No newline at end of file diff --git a/docs/examples/kotlin/functions/list-executions.md b/docs/examples/kotlin/functions/list-executions.md index a56993f..37ea8b8 100644 --- a/docs/examples/kotlin/functions/list-executions.md +++ b/docs/examples/kotlin/functions/list-executions.md @@ -11,5 +11,4 @@ val functions = Functions(client) val result = functions.listExecutions( functionId = "", queries = listOf(), // (optional) - search = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file-download.md b/docs/examples/kotlin/storage/get-file-download.md index b4d3386..89c6e8a 100644 --- a/docs/examples/kotlin/storage/get-file-download.md +++ b/docs/examples/kotlin/storage/get-file-download.md @@ -11,4 +11,5 @@ val storage = Storage(client) val result = storage.getFileDownload( bucketId = "", fileId = "", + token = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file-preview.md b/docs/examples/kotlin/storage/get-file-preview.md index 31aa6e2..d766dc7 100644 --- a/docs/examples/kotlin/storage/get-file-preview.md +++ b/docs/examples/kotlin/storage/get-file-preview.md @@ -14,7 +14,7 @@ val result = storage.getFilePreview( width = 0, // (optional) height = 0, // (optional) gravity = ImageGravity.CENTER, // (optional) - quality = 0, // (optional) + quality = -1, // (optional) borderWidth = 0, // (optional) borderColor = "", // (optional) borderRadius = 0, // (optional) @@ -22,4 +22,5 @@ val result = storage.getFilePreview( rotation = -360, // (optional) background = "", // (optional) output = ImageFormat.JPG, // (optional) + token = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/storage/get-file-view.md b/docs/examples/kotlin/storage/get-file-view.md index 7a5b31d..513e1f9 100644 --- a/docs/examples/kotlin/storage/get-file-view.md +++ b/docs/examples/kotlin/storage/get-file-view.md @@ -11,4 +11,5 @@ val storage = Storage(client) val result = storage.getFileView( bucketId = "", fileId = "", + token = "", // (optional) ) \ 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 909e62f..67400ea 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -87,8 +87,8 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "7.0.1", - "x-appwrite-response-format" to "1.6.0" + "x-sdk-version" to "7.1.0", + "x-appwrite-response-format" to "1.7.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/enums/ImageFormat.kt b/library/src/main/java/io/appwrite/enums/ImageFormat.kt index 7249f2a..c3dea06 100644 --- a/library/src/main/java/io/appwrite/enums/ImageFormat.kt +++ b/library/src/main/java/io/appwrite/enums/ImageFormat.kt @@ -7,8 +7,6 @@ enum class ImageFormat(val value: String) { JPG("jpg"), @SerializedName("jpeg") JPEG("jpeg"), - @SerializedName("gif") - GIF("gif"), @SerializedName("png") PNG("png"), @SerializedName("webp") diff --git a/library/src/main/java/io/appwrite/models/Execution.kt b/library/src/main/java/io/appwrite/models/Execution.kt index 1b6226a..216e146 100644 --- a/library/src/main/java/io/appwrite/models/Execution.kt +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -98,7 +98,7 @@ data class Execution( val errors: String, /** - * Function execution duration in seconds. + * Resource(function/site) execution duration in seconds. */ @SerializedName("duration") val duration: Double, diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt index 2900bf4..55406cc 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -23,7 +23,7 @@ class Avatars(client: Client) : Service(client) { * @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. + * @param quality Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. * @return [ByteArray] */ @JvmOverloads @@ -57,7 +57,7 @@ class Avatars(client: Client) : Service(client) { * @param code Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro, rupay. * @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. + * @param quality Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. * @return [ByteArray] */ @JvmOverloads @@ -115,7 +115,7 @@ class Avatars(client: Client) : Service(client) { * @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. + * @param quality Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. * @return [ByteArray] */ @JvmOverloads diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index b6559a9..73384a1 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -146,6 +146,64 @@ class Databases(client: Client) : Service(client) { nestedType = classOf(), ) + /** + * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/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 documents Array of documents data as JSON objects. + * @return [io.appwrite.models.DocumentList] + */ + suspend fun createDocuments( + databaseId: String, + collectionId: String, + documents: List, + nestedType: Class, + ): io.appwrite.models.DocumentList { + val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + + val apiParams = mutableMapOf( + "documents" to documents, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.DocumentList = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.DocumentList.from(map = it as Map, nestedType) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/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 documents Array of documents data as JSON objects. + * @return [io.appwrite.models.DocumentList] + */ + @Throws(AppwriteException::class) + suspend fun createDocuments( + databaseId: String, + collectionId: String, + documents: List, + ): io.appwrite.models.DocumentList> = createDocuments( + databaseId, + collectionId, + documents, + nestedType = classOf(), + ) + /** * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. * diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index a3644f2..b370448 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -20,21 +20,18 @@ class Functions(client: Client) : Service(client) { * * @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/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId - * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.ExecutionList] */ @JvmOverloads suspend fun listExecutions( functionId: String, queries: List? = null, - search: String? = null, ): io.appwrite.models.ExecutionList { val apiPath = "/functions/{functionId}/executions" .replace("{functionId}", functionId) val apiParams = mutableMapOf( "queries" to queries, - "search" to search, ) val apiHeaders = mutableMapOf( ) diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index 391dedb..3b0323a 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -213,17 +213,21 @@ class Storage(client: Client) : Service(client) { * * @param bucketId Storage bucket ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). * @param fileId File ID. + * @param token File token for accessing this file. * @return [ByteArray] */ + @JvmOverloads suspend fun getFileDownload( bucketId: String, fileId: String, + token: String? = null, ): ByteArray { val apiPath = "/storage/buckets/{bucketId}/files/{fileId}/download" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) val apiParams = mutableMapOf( + "token" to token, "project" to client.config["project"], ) return client.call( @@ -243,7 +247,7 @@ class Storage(client: Client) : Service(client) { * @param width Resize preview image width, Pass an integer between 0 to 4000. * @param height Resize preview image height, Pass an integer between 0 to 4000. * @param gravity Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right - * @param quality Preview image quality. Pass an integer between 0 to 100. Defaults to 100. + * @param quality Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. * @param borderWidth Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0. * @param borderColor Preview image border color. Use a valid HEX color, no # is needed for prefix. * @param borderRadius Preview image border radius in pixels. Pass an integer between 0 to 4000. @@ -251,6 +255,7 @@ class Storage(client: Client) : Service(client) { * @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). + * @param token File token for accessing this file. * @return [ByteArray] */ @JvmOverloads @@ -268,6 +273,7 @@ class Storage(client: Client) : Service(client) { rotation: Long? = null, background: String? = null, output: io.appwrite.enums.ImageFormat? = null, + token: String? = null, ): ByteArray { val apiPath = "/storage/buckets/{bucketId}/files/{fileId}/preview" .replace("{bucketId}", bucketId) @@ -285,6 +291,7 @@ class Storage(client: Client) : Service(client) { "rotation" to rotation, "background" to background, "output" to output, + "token" to token, "project" to client.config["project"], ) return client.call( @@ -301,17 +308,21 @@ class Storage(client: Client) : Service(client) { * * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). * @param fileId File ID. + * @param token File token for accessing this file. * @return [ByteArray] */ + @JvmOverloads suspend fun getFileView( bucketId: String, fileId: String, + token: String? = null, ): ByteArray { val apiPath = "/storage/buckets/{bucketId}/files/{fileId}/view" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) val apiParams = mutableMapOf( + "token" to token, "project" to client.config["project"], ) return client.call( diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 6810ce1..2756a5a 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -256,7 +256,7 @@ class Teams(client: Client) : Service(client) { * Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint. Hide sensitive attributes from the response by toggling membership privacy in the Console. * * @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/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm, roles * @param search Search term to filter your list results. Max length: 256 chars. * @return [io.appwrite.models.MembershipList] */ From 32f43932b4685330f7b47ad0963ff53d5a51443e Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Sun, 18 May 2025 02:03:51 +1200 Subject: [PATCH 098/118] Add 1.7 support --- .../java/databases/create-documents.md | 24 -------- .../kotlin/databases/create-documents.md | 15 ----- .../java/io/appwrite/services/Databases.kt | 58 ------------------- 3 files changed, 97 deletions(-) delete mode 100644 docs/examples/java/databases/create-documents.md delete mode 100644 docs/examples/kotlin/databases/create-documents.md diff --git a/docs/examples/java/databases/create-documents.md b/docs/examples/java/databases/create-documents.md deleted file mode 100644 index dbdc64f..0000000 --- a/docs/examples/java/databases/create-documents.md +++ /dev/null @@ -1,24 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Databases; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setKey(""); // - -Databases databases = new Databases(client); - -databases.createDocuments( - "", // databaseId - "", // collectionId - listOf(), // documents - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - diff --git a/docs/examples/kotlin/databases/create-documents.md b/docs/examples/kotlin/databases/create-documents.md deleted file mode 100644 index 33635b4..0000000 --- a/docs/examples/kotlin/databases/create-documents.md +++ /dev/null @@ -1,15 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Databases - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setKey("") // - -val databases = Databases(client) - -val result = databases.createDocuments( - databaseId = "", - collectionId = "", - documents = listOf(), -) \ 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 73384a1..b6559a9 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -146,64 +146,6 @@ class Databases(client: Client) : Service(client) { nestedType = classOf(), ) - /** - * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/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 documents Array of documents data as JSON objects. - * @return [io.appwrite.models.DocumentList] - */ - suspend fun createDocuments( - databaseId: String, - collectionId: String, - documents: List, - nestedType: Class, - ): io.appwrite.models.DocumentList { - val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" - .replace("{databaseId}", databaseId) - .replace("{collectionId}", collectionId) - - val apiParams = mutableMapOf( - "documents" to documents, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.DocumentList = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.DocumentList.from(map = it as Map, nestedType) - } - return client.call( - "POST", - apiPath, - apiHeaders, - apiParams, - responseType = classOf(), - converter, - ) - } - - /** - * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/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 documents Array of documents data as JSON objects. - * @return [io.appwrite.models.DocumentList] - */ - @Throws(AppwriteException::class) - suspend fun createDocuments( - databaseId: String, - collectionId: String, - documents: List, - ): io.appwrite.models.DocumentList> = createDocuments( - databaseId, - collectionId, - documents, - nestedType = classOf(), - ) - /** * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. * From c6f6d9676997788acb80eecb9f902bfe6a4fb073 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 18 May 2025 07:48:42 +0000 Subject: [PATCH 099/118] chore: bump to next major versions --- README.md | 4 ++-- library/src/main/java/io/appwrite/Client.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4abf758..f00352f 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:7.1.0") +implementation("io.appwrite:sdk-for-android:8.0.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 7.1.0 + 8.0.0 ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 67400ea..7905e40 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -87,7 +87,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "7.1.0", + "x-sdk-version" to "8.0.0", "x-appwrite-response-format" to "1.7.0" ) config = mutableMapOf() From 4ec6a521bae8f7fb8f737b4aeeefde532ea59627 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 21 May 2025 05:14:35 +0000 Subject: [PATCH 100/118] chore: add setDevKey and upsertDocument methods --- CHANGELOG.md | 9 ++- README.md | 4 +- .../java/databases/create-documents.md | 24 ++++++++ .../kotlin/databases/create-documents.md | 15 +++++ library/src/main/java/io/appwrite/Client.kt | 2 +- .../java/io/appwrite/services/Databases.kt | 58 +++++++++++++++++++ 6 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 docs/examples/java/databases/create-documents.md create mode 100644 docs/examples/kotlin/databases/create-documents.md diff --git a/CHANGELOG.md b/CHANGELOG.md index fa4d35e..8406e63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,8 @@ -# Change Log \ No newline at end of file +# Change Log + +## 8.0.0 + +* Add `token` param to `getFilePreview` and `getFileView` for File tokens usage +* Update default `quality` for `getFilePreview` from 0 to -1 +* Remove `Gif` from ImageFormat enum +* Remove `search` param from `listExecutions` method \ No newline at end of file diff --git a/README.md b/README.md index f00352f..1eee246 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:8.0.0") +implementation("io.appwrite:sdk-for-android:8.0.1") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 8.0.0 + 8.0.1 ``` diff --git a/docs/examples/java/databases/create-documents.md b/docs/examples/java/databases/create-documents.md new file mode 100644 index 0000000..dbdc64f --- /dev/null +++ b/docs/examples/java/databases/create-documents.md @@ -0,0 +1,24 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setKey(""); // + +Databases databases = new Databases(client); + +databases.createDocuments( + "", // databaseId + "", // collectionId + listOf(), // documents + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/kotlin/databases/create-documents.md b/docs/examples/kotlin/databases/create-documents.md new file mode 100644 index 0000000..33635b4 --- /dev/null +++ b/docs/examples/kotlin/databases/create-documents.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setKey("") // + +val databases = Databases(client) + +val result = databases.createDocuments( + databaseId = "", + collectionId = "", + documents = listOf(), +) \ 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 7905e40..6ea42ae 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -87,7 +87,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "8.0.0", + "x-sdk-version" to "8.0.1", "x-appwrite-response-format" to "1.7.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index b6559a9..73384a1 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -146,6 +146,64 @@ class Databases(client: Client) : Service(client) { nestedType = classOf(), ) + /** + * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/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 documents Array of documents data as JSON objects. + * @return [io.appwrite.models.DocumentList] + */ + suspend fun createDocuments( + databaseId: String, + collectionId: String, + documents: List, + nestedType: Class, + ): io.appwrite.models.DocumentList { + val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + + val apiParams = mutableMapOf( + "documents" to documents, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.DocumentList = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.DocumentList.from(map = it as Map, nestedType) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/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 documents Array of documents data as JSON objects. + * @return [io.appwrite.models.DocumentList] + */ + @Throws(AppwriteException::class) + suspend fun createDocuments( + databaseId: String, + collectionId: String, + documents: List, + ): io.appwrite.models.DocumentList> = createDocuments( + databaseId, + collectionId, + documents, + nestedType = classOf(), + ) + /** * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. * From 881da2e1b1662f1c965d7d816308ecf725bc9497 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 21 May 2025 05:16:30 +0000 Subject: [PATCH 101/118] chore: add setDevkey and upsertDocument methods --- ...create-documents.md => upsert-document.md} | 8 +- ...create-documents.md => upsert-document.md} | 8 +- library/src/main/java/io/appwrite/Client.kt | 15 ++++ .../java/io/appwrite/services/Databases.kt | 84 +++++++++++-------- 4 files changed, 74 insertions(+), 41 deletions(-) rename docs/examples/java/databases/{create-documents.md => upsert-document.md} (73%) rename docs/examples/kotlin/databases/{create-documents.md => upsert-document.md} (60%) diff --git a/docs/examples/java/databases/create-documents.md b/docs/examples/java/databases/upsert-document.md similarity index 73% rename from docs/examples/java/databases/create-documents.md rename to docs/examples/java/databases/upsert-document.md index dbdc64f..868576b 100644 --- a/docs/examples/java/databases/create-documents.md +++ b/docs/examples/java/databases/upsert-document.md @@ -4,14 +4,16 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setKey(""); // + .setProject(""); // Your project ID Databases databases = new Databases(client); -databases.createDocuments( +databases.upsertDocument( "", // databaseId "", // collectionId - listOf(), // documents + "", // documentId + mapOf( "a" to "b" ), // data + listOf("read("any")"), // permissions (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/kotlin/databases/create-documents.md b/docs/examples/kotlin/databases/upsert-document.md similarity index 60% rename from docs/examples/kotlin/databases/create-documents.md rename to docs/examples/kotlin/databases/upsert-document.md index 33635b4..a31dfc8 100644 --- a/docs/examples/kotlin/databases/create-documents.md +++ b/docs/examples/kotlin/databases/upsert-document.md @@ -4,12 +4,14 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setKey("") // + .setProject("") // Your project ID val databases = Databases(client) -val result = databases.createDocuments( +val result = databases.upsertDocument( databaseId = "", collectionId = "", - documents = listOf(), + documentId = "", + data = mapOf( "a" to "b" ), + permissions = listOf("read("any")"), // (optional) ) \ 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 6ea42ae..f223cef 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -153,6 +153,21 @@ class Client @JvmOverloads constructor( return this } + /** + * Set DevKey + * + * Your secret dev API key + * + * @param {string} devkey + * + * @return this + */ + fun setDevKey(value: String): Client { + config["devKey"] = value + addHeader("x-appwrite-dev-key", value) + return this + } + /** * Set self Signed * diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index 73384a1..2601af2 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -147,35 +147,38 @@ class Databases(client: Client) : Service(client) { ) /** - * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * 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). Make sure to define attributes before creating documents. - * @param documents Array of documents data as JSON objects. - * @return [io.appwrite.models.DocumentList] + * @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. + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @return [io.appwrite.models.Document] */ - suspend fun createDocuments( + @JvmOverloads + suspend fun getDocument( databaseId: String, collectionId: String, - documents: List, + documentId: String, + queries: List? = null, nestedType: Class, - ): io.appwrite.models.DocumentList { - val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" + ): io.appwrite.models.Document { + val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) + .replace("{documentId}", documentId) val apiParams = mutableMapOf( - "documents" to documents, + "queries" to queries, ) val apiHeaders = mutableMapOf( - "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.DocumentList = { + val converter: (Any) -> io.appwrite.models.Document = { @Suppress("UNCHECKED_CAST") - io.appwrite.models.DocumentList.from(map = it as Map, nestedType) + io.appwrite.models.Document.from(map = it as Map, nestedType) } return client.call( - "POST", + "GET", apiPath, apiHeaders, apiParams, @@ -185,40 +188,46 @@ class Databases(client: Client) : Service(client) { } /** - * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * 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). Make sure to define attributes before creating documents. - * @param documents Array of documents data as JSON objects. - * @return [io.appwrite.models.DocumentList] + * @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. + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @return [io.appwrite.models.Document] */ + @JvmOverloads @Throws(AppwriteException::class) - suspend fun createDocuments( + suspend fun getDocument( databaseId: String, collectionId: String, - documents: List, - ): io.appwrite.models.DocumentList> = createDocuments( + documentId: String, + queries: List? = null, + ): io.appwrite.models.Document> = getDocument( databaseId, collectionId, - documents, + documentId, + queries, nestedType = classOf(), ) /** - * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. + * Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/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). + * @param collectionId Collection ID. * @param documentId Document ID. - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param data Document data as JSON object. Include all required attributes of the document to be created or updated. + * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ @JvmOverloads - suspend fun getDocument( + suspend fun upsertDocument( databaseId: String, collectionId: String, documentId: String, - queries: List? = null, + data: Any, + permissions: List? = null, nestedType: Class, ): io.appwrite.models.Document { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" @@ -227,16 +236,18 @@ class Databases(client: Client) : Service(client) { .replace("{documentId}", documentId) val apiParams = mutableMapOf( - "queries" to queries, + "data" to data, + "permissions" to permissions, ) val apiHeaders = mutableMapOf( + "content-type" to "application/json", ) val converter: (Any) -> io.appwrite.models.Document = { @Suppress("UNCHECKED_CAST") io.appwrite.models.Document.from(map = it as Map, nestedType) } return client.call( - "GET", + "PUT", apiPath, apiHeaders, apiParams, @@ -246,26 +257,29 @@ class Databases(client: Client) : Service(client) { } /** - * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. + * Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/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). + * @param collectionId Collection ID. * @param documentId Document ID. - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param data Document data as JSON object. Include all required attributes of the document to be created or updated. + * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun getDocument( + suspend fun upsertDocument( databaseId: String, collectionId: String, documentId: String, - queries: List? = null, - ): io.appwrite.models.Document> = getDocument( + data: Any, + permissions: List? = null, + ): io.appwrite.models.Document> = upsertDocument( databaseId, collectionId, documentId, - queries, + data, + permissions, nestedType = classOf(), ) From 151e7a021f87bb3dceeec3e0a007779f9b6a2a24 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 21 May 2025 06:27:29 +0000 Subject: [PATCH 102/118] chore: bump to minor version --- README.md | 4 ++-- library/src/main/java/io/appwrite/Client.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1eee246..6bfc46c 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:8.0.1") +implementation("io.appwrite:sdk-for-android:8.1.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 8.0.1 + 8.1.0 ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index f223cef..5f12d7f 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -87,7 +87,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "8.0.1", + "x-sdk-version" to "8.1.0", "x-appwrite-response-format" to "1.7.0" ) config = mutableMapOf() From 39fdc6e2eb5cffef1e6f451310af2d1aff884f95 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 18 Jul 2025 12:48:19 +1200 Subject: [PATCH 103/118] Add inc/dec --- README.md | 6 +- .../java/databases/create-document.md | 1 + .../databases/decrement-document-attribute.md | 27 +++ .../databases/increment-document-attribute.md | 27 +++ .../kotlin/databases/create-document.md | 1 + .../databases/decrement-document-attribute.md | 18 ++ .../databases/increment-document-attribute.md | 18 ++ library/src/main/java/io/appwrite/Client.kt | 2 +- .../java/io/appwrite/enums/ImageFormat.kt | 4 +- .../main/java/io/appwrite/models/Document.kt | 10 ++ .../java/io/appwrite/services/Databases.kt | 160 +++++++++++++++++- 11 files changed, 267 insertions(+), 7 deletions(-) create mode 100644 docs/examples/java/databases/decrement-document-attribute.md create mode 100644 docs/examples/java/databases/increment-document-attribute.md create mode 100644 docs/examples/kotlin/databases/decrement-document-attribute.md create mode 100644 docs/examples/kotlin/databases/increment-document-attribute.md diff --git a/README.md b/README.md index 6bfc46c..745f21c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![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.7.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.7.4-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) @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:8.1.0") +implementation("io.appwrite:sdk-for-android:8.2.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 8.1.0 + 8.2.0 ``` diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index 7fb129b..3625d96 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -4,6 +4,7 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setAdmin("") // .setSession("") // The user session to authenticate with .setKey("") // .setJWT(""); // Your secret JSON Web Token diff --git a/docs/examples/java/databases/decrement-document-attribute.md b/docs/examples/java/databases/decrement-document-attribute.md new file mode 100644 index 0000000..de6a4ab --- /dev/null +++ b/docs/examples/java/databases/decrement-document-attribute.md @@ -0,0 +1,27 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Databases databases = new Databases(client); + +databases.decrementDocumentAttribute( + "", // databaseId + "", // collectionId + "", // documentId + "", // attribute + 0, // value (optional) + 0, // min (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/databases/increment-document-attribute.md b/docs/examples/java/databases/increment-document-attribute.md new file mode 100644 index 0000000..94ffa9d --- /dev/null +++ b/docs/examples/java/databases/increment-document-attribute.md @@ -0,0 +1,27 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Databases databases = new Databases(client); + +databases.incrementDocumentAttribute( + "", // databaseId + "", // collectionId + "", // documentId + "", // attribute + 0, // value (optional) + 0, // max (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index 0bafb31..38f9389 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -4,6 +4,7 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setAdmin("") // .setSession("") // The user session to authenticate with .setKey("") // .setJWT("") // Your secret JSON Web Token diff --git a/docs/examples/kotlin/databases/decrement-document-attribute.md b/docs/examples/kotlin/databases/decrement-document-attribute.md new file mode 100644 index 0000000..c500fa8 --- /dev/null +++ b/docs/examples/kotlin/databases/decrement-document-attribute.md @@ -0,0 +1,18 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val databases = Databases(client) + +val result = databases.decrementDocumentAttribute( + databaseId = "", + collectionId = "", + documentId = "", + attribute = "", + value = 0, // (optional) + min = 0, // (optional) +) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/increment-document-attribute.md b/docs/examples/kotlin/databases/increment-document-attribute.md new file mode 100644 index 0000000..0ae6b02 --- /dev/null +++ b/docs/examples/kotlin/databases/increment-document-attribute.md @@ -0,0 +1,18 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val databases = Databases(client) + +val result = databases.incrementDocumentAttribute( + databaseId = "", + collectionId = "", + documentId = "", + attribute = "", + value = 0, // (optional) + max = 0, // (optional) +) \ 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 5f12d7f..bf0480f 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -87,7 +87,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "8.1.0", + "x-sdk-version" to "8.2.0", "x-appwrite-response-format" to "1.7.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/enums/ImageFormat.kt b/library/src/main/java/io/appwrite/enums/ImageFormat.kt index c3dea06..8e74806 100644 --- a/library/src/main/java/io/appwrite/enums/ImageFormat.kt +++ b/library/src/main/java/io/appwrite/enums/ImageFormat.kt @@ -14,7 +14,9 @@ enum class ImageFormat(val value: String) { @SerializedName("heic") HEIC("heic"), @SerializedName("avif") - AVIF("avif"); + AVIF("avif"), + @SerializedName("gif") + GIF("gif"); override fun toString() = value } \ 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 01204de..c0dfe61 100644 --- a/library/src/main/java/io/appwrite/models/Document.kt +++ b/library/src/main/java/io/appwrite/models/Document.kt @@ -13,6 +13,12 @@ data class Document( @SerializedName("\$id") val id: String, + /** + * Document automatically incrementing ID. + */ + @SerializedName("\$sequence") + val sequence: Long, + /** * Collection ID. */ @@ -51,6 +57,7 @@ data class Document( ) { fun toMap(): Map = mapOf( "\$id" to id as Any, + "\$sequence" to sequence as Any, "\$collectionId" to collectionId as Any, "\$databaseId" to databaseId as Any, "\$createdAt" to createdAt as Any, @@ -62,6 +69,7 @@ data class Document( companion object { operator fun invoke( id: String, + sequence: Long, collectionId: String, databaseId: String, createdAt: String, @@ -70,6 +78,7 @@ data class Document( data: Map ) = Document>( id, + sequence, collectionId, databaseId, createdAt, @@ -84,6 +93,7 @@ data class Document( nestedType: Class ) = Document( id = map["\$id"] as String, + sequence = (map["\$sequence"] as Number).toLong(), collectionId = map["\$collectionId"] as String, databaseId = map["\$databaseId"] as String, createdAt = map["\$createdAt"] as String, diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index 2601af2..edc10f5 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -212,7 +212,7 @@ class Databases(client: Client) : Service(client) { ) /** - * Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. * * @param databaseId Database ID. * @param collectionId Collection ID. @@ -257,7 +257,7 @@ class Databases(client: Client) : Service(client) { } /** - * Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. * * @param databaseId Database ID. * @param collectionId Collection ID. @@ -388,4 +388,160 @@ class Databases(client: Client) : Service(client) { } + /** + * Decrement a specific attribute of a document by a given value. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. + * @param documentId Document ID. + * @param attribute Attribute key. + * @param value Value to decrement the attribute by. The value must be a number. + * @param min Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @return [io.appwrite.models.Document] + */ + @JvmOverloads + suspend fun decrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = null, + min: Double? = null, + nestedType: Class, + ): io.appwrite.models.Document { + val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + .replace("{documentId}", documentId) + .replace("{attribute}", attribute) + + val apiParams = mutableMapOf( + "value" to value, + "min" to min, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Document = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Document.from(map = it as Map, nestedType) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Decrement a specific attribute of a document by a given value. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. + * @param documentId Document ID. + * @param attribute Attribute key. + * @param value Value to decrement the attribute by. The value must be a number. + * @param min Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @return [io.appwrite.models.Document] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun decrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = null, + min: Double? = null, + ): io.appwrite.models.Document> = decrementDocumentAttribute( + databaseId, + collectionId, + documentId, + attribute, + value, + min, + nestedType = classOf(), + ) + + /** + * Increment a specific attribute of a document by a given value. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. + * @param documentId Document ID. + * @param attribute Attribute key. + * @param value Value to increment the attribute by. The value must be a number. + * @param max Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @return [io.appwrite.models.Document] + */ + @JvmOverloads + suspend fun incrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = null, + max: Double? = null, + nestedType: Class, + ): io.appwrite.models.Document { + val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + .replace("{documentId}", documentId) + .replace("{attribute}", attribute) + + val apiParams = mutableMapOf( + "value" to value, + "max" to max, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Document = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Document.from(map = it as Map, nestedType) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Increment a specific attribute of a document by a given value. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. + * @param documentId Document ID. + * @param attribute Attribute key. + * @param value Value to increment the attribute by. The value must be a number. + * @param max Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @return [io.appwrite.models.Document] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun incrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = null, + max: Double? = null, + ): io.appwrite.models.Document> = incrementDocumentAttribute( + databaseId, + collectionId, + documentId, + attribute, + value, + max, + nestedType = classOf(), + ) + } \ No newline at end of file From 49bf798964ead5c527ad984400a99379c51938df Mon Sep 17 00:00:00 2001 From: root Date: Tue, 22 Jul 2025 16:14:53 +0000 Subject: [PATCH 104/118] chore: regenerate --- README.md | 8 +- .../java/databases/create-document.md | 1 - .../java/databases/upsert-document.md | 6 +- docs/examples/java/tables/create-row.md | 28 ++ docs/examples/java/tables/create-rows.md | 25 + .../delete-row.md} | 13 +- .../get-row.md} | 14 +- docs/examples/java/tables/list-rows.md | 24 + docs/examples/java/tables/update-row.md | 26 ++ docs/examples/java/tables/upsert-row.md | 26 ++ .../kotlin/databases/create-document.md | 1 - .../kotlin/databases/upsert-document.md | 6 +- docs/examples/kotlin/tables/create-row.md | 19 + docs/examples/kotlin/tables/create-rows.md | 16 + .../delete-row.md} | 13 +- .../get-row.md} | 14 +- docs/examples/kotlin/tables/list-rows.md | 15 + docs/examples/kotlin/tables/update-row.md | 17 + docs/examples/kotlin/tables/upsert-row.md | 17 + library/src/main/java/io/appwrite/Client.kt | 4 +- .../java/io/appwrite/models/ContinentList.kt | 2 +- .../java/io/appwrite/models/CountryList.kt | 2 +- .../java/io/appwrite/models/CurrencyList.kt | 2 +- .../java/io/appwrite/models/DocumentList.kt | 2 +- .../java/io/appwrite/models/ExecutionList.kt | 2 +- .../main/java/io/appwrite/models/FileList.kt | 2 +- .../java/io/appwrite/models/IdentityList.kt | 2 +- .../java/io/appwrite/models/LanguageList.kt | 2 +- .../java/io/appwrite/models/LocaleCodeList.kt | 2 +- .../main/java/io/appwrite/models/LogList.kt | 2 +- .../java/io/appwrite/models/MembershipList.kt | 2 +- .../main/java/io/appwrite/models/PhoneList.kt | 2 +- .../src/main/java/io/appwrite/models/Row.kt | 105 +++++ .../main/java/io/appwrite/models/RowList.kt | 46 ++ .../java/io/appwrite/models/SessionList.kt | 2 +- .../main/java/io/appwrite/models/TeamList.kt | 2 +- .../main/java/io/appwrite/services/Account.kt | 6 + .../java/io/appwrite/services/Databases.kt | 225 +++------ .../main/java/io/appwrite/services/Tables.kt | 435 ++++++++++++++++++ 39 files changed, 908 insertions(+), 230 deletions(-) create mode 100644 docs/examples/java/tables/create-row.md create mode 100644 docs/examples/java/tables/create-rows.md rename docs/examples/java/{databases/decrement-document-attribute.md => tables/delete-row.md} (64%) rename docs/examples/java/{databases/increment-document-attribute.md => tables/get-row.md} (64%) create mode 100644 docs/examples/java/tables/list-rows.md create mode 100644 docs/examples/java/tables/update-row.md create mode 100644 docs/examples/java/tables/upsert-row.md create mode 100644 docs/examples/kotlin/tables/create-row.md create mode 100644 docs/examples/kotlin/tables/create-rows.md rename docs/examples/kotlin/{databases/decrement-document-attribute.md => tables/delete-row.md} (50%) rename docs/examples/kotlin/{databases/increment-document-attribute.md => tables/get-row.md} (50%) create mode 100644 docs/examples/kotlin/tables/list-rows.md create mode 100644 docs/examples/kotlin/tables/update-row.md create mode 100644 docs/examples/kotlin/tables/upsert-row.md create mode 100644 library/src/main/java/io/appwrite/models/Row.kt create mode 100644 library/src/main/java/io/appwrite/models/RowList.kt create mode 100644 library/src/main/java/io/appwrite/services/Tables.kt diff --git a/README.md b/README.md index 745f21c..5ced453 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.7.4-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.8.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.7.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.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).** Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Android SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:8.2.0") +implementation("io.appwrite:sdk-for-android:9.0.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 8.2.0 + 9.0.0 ``` diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index 3625d96..7fb129b 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -4,7 +4,6 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setAdmin("") // .setSession("") // The user session to authenticate with .setKey("") // .setJWT(""); // Your secret JSON Web Token diff --git a/docs/examples/java/databases/upsert-document.md b/docs/examples/java/databases/upsert-document.md index 868576b..ba7336f 100644 --- a/docs/examples/java/databases/upsert-document.md +++ b/docs/examples/java/databases/upsert-document.md @@ -4,7 +4,9 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID + .setSession("") // The user session to authenticate with + .setKey("") // + .setJWT(""); // Your secret JSON Web Token Databases databases = new Databases(client); @@ -12,8 +14,6 @@ databases.upsertDocument( "", // databaseId "", // collectionId "", // documentId - mapOf( "a" to "b" ), // data - listOf("read("any")"), // permissions (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tables/create-row.md b/docs/examples/java/tables/create-row.md new file mode 100644 index 0000000..8102b82 --- /dev/null +++ b/docs/examples/java/tables/create-row.md @@ -0,0 +1,28 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Tables; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setSession("") // The user session to authenticate with + .setKey("") // + .setJWT(""); // Your secret JSON Web Token + +Tables tables = new Tables(client); + +tables.createRow( + "", // databaseId + "", // tableId + "", // rowId + mapOf( "a" to "b" ), // data + listOf("read("any")"), // permissions (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/tables/create-rows.md b/docs/examples/java/tables/create-rows.md new file mode 100644 index 0000000..26f5d67 --- /dev/null +++ b/docs/examples/java/tables/create-rows.md @@ -0,0 +1,25 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Tables; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setAdmin("") // + .setKey(""); // + +Tables tables = new Tables(client); + +tables.createRows( + "", // databaseId + "", // tableId + listOf(), // rows + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/databases/decrement-document-attribute.md b/docs/examples/java/tables/delete-row.md similarity index 64% rename from docs/examples/java/databases/decrement-document-attribute.md rename to docs/examples/java/tables/delete-row.md index de6a4ab..596a8b7 100644 --- a/docs/examples/java/databases/decrement-document-attribute.md +++ b/docs/examples/java/tables/delete-row.md @@ -1,20 +1,17 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Databases; +import io.appwrite.services.Tables; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID -Databases databases = new Databases(client); +Tables tables = new Tables(client); -databases.decrementDocumentAttribute( +tables.deleteRow( "", // databaseId - "", // collectionId - "", // documentId - "", // attribute - 0, // value (optional) - 0, // min (optional) + "", // tableId + "", // rowId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/increment-document-attribute.md b/docs/examples/java/tables/get-row.md similarity index 64% rename from docs/examples/java/databases/increment-document-attribute.md rename to docs/examples/java/tables/get-row.md index 94ffa9d..882a195 100644 --- a/docs/examples/java/databases/increment-document-attribute.md +++ b/docs/examples/java/tables/get-row.md @@ -1,20 +1,18 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Databases; +import io.appwrite.services.Tables; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID -Databases databases = new Databases(client); +Tables tables = new Tables(client); -databases.incrementDocumentAttribute( +tables.getRow( "", // databaseId - "", // collectionId - "", // documentId - "", // attribute - 0, // value (optional) - 0, // max (optional) + "", // tableId + "", // rowId + listOf(), // queries (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tables/list-rows.md b/docs/examples/java/tables/list-rows.md new file mode 100644 index 0000000..4d37570 --- /dev/null +++ b/docs/examples/java/tables/list-rows.md @@ -0,0 +1,24 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Tables; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Tables tables = new Tables(client); + +tables.listRows( + "", // databaseId + "", // tableId + listOf(), // queries (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/tables/update-row.md b/docs/examples/java/tables/update-row.md new file mode 100644 index 0000000..0421c9c --- /dev/null +++ b/docs/examples/java/tables/update-row.md @@ -0,0 +1,26 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Tables; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Tables tables = new Tables(client); + +tables.updateRow( + "", // databaseId + "", // tableId + "", // rowId + mapOf( "a" to "b" ), // data (optional) + listOf("read("any")"), // permissions (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/tables/upsert-row.md b/docs/examples/java/tables/upsert-row.md new file mode 100644 index 0000000..a8be0cf --- /dev/null +++ b/docs/examples/java/tables/upsert-row.md @@ -0,0 +1,26 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Tables; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setSession("") // The user session to authenticate with + .setKey("") // + .setJWT(""); // Your secret JSON Web Token + +Tables tables = new Tables(client); + +tables.upsertRow( + "", // databaseId + "", // tableId + "", // rowId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index 38f9389..0bafb31 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -4,7 +4,6 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setAdmin("") // .setSession("") // The user session to authenticate with .setKey("") // .setJWT("") // Your secret JSON Web Token diff --git a/docs/examples/kotlin/databases/upsert-document.md b/docs/examples/kotlin/databases/upsert-document.md index a31dfc8..7939fde 100644 --- a/docs/examples/kotlin/databases/upsert-document.md +++ b/docs/examples/kotlin/databases/upsert-document.md @@ -4,7 +4,9 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID + .setSession("") // The user session to authenticate with + .setKey("") // + .setJWT("") // Your secret JSON Web Token val databases = Databases(client) @@ -12,6 +14,4 @@ val result = databases.upsertDocument( databaseId = "", collectionId = "", documentId = "", - data = mapOf( "a" to "b" ), - permissions = listOf("read("any")"), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/tables/create-row.md b/docs/examples/kotlin/tables/create-row.md new file mode 100644 index 0000000..8c581bf --- /dev/null +++ b/docs/examples/kotlin/tables/create-row.md @@ -0,0 +1,19 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Tables + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setSession("") // The user session to authenticate with + .setKey("") // + .setJWT("") // Your secret JSON Web Token + +val tables = Tables(client) + +val result = tables.createRow( + databaseId = "", + tableId = "", + rowId = "", + data = mapOf( "a" to "b" ), + permissions = listOf("read("any")"), // (optional) +) \ No newline at end of file diff --git a/docs/examples/kotlin/tables/create-rows.md b/docs/examples/kotlin/tables/create-rows.md new file mode 100644 index 0000000..1fde9c5 --- /dev/null +++ b/docs/examples/kotlin/tables/create-rows.md @@ -0,0 +1,16 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Tables + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setAdmin("") // + .setKey("") // + +val tables = Tables(client) + +val result = tables.createRows( + databaseId = "", + tableId = "", + rows = listOf(), +) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/decrement-document-attribute.md b/docs/examples/kotlin/tables/delete-row.md similarity index 50% rename from docs/examples/kotlin/databases/decrement-document-attribute.md rename to docs/examples/kotlin/tables/delete-row.md index c500fa8..ffa3229 100644 --- a/docs/examples/kotlin/databases/decrement-document-attribute.md +++ b/docs/examples/kotlin/tables/delete-row.md @@ -1,18 +1,15 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Databases +import io.appwrite.services.Tables val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -val databases = Databases(client) +val tables = Tables(client) -val result = databases.decrementDocumentAttribute( +val result = tables.deleteRow( databaseId = "", - collectionId = "", - documentId = "", - attribute = "", - value = 0, // (optional) - min = 0, // (optional) + tableId = "", + rowId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/increment-document-attribute.md b/docs/examples/kotlin/tables/get-row.md similarity index 50% rename from docs/examples/kotlin/databases/increment-document-attribute.md rename to docs/examples/kotlin/tables/get-row.md index 0ae6b02..15dabff 100644 --- a/docs/examples/kotlin/databases/increment-document-attribute.md +++ b/docs/examples/kotlin/tables/get-row.md @@ -1,18 +1,16 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Databases +import io.appwrite.services.Tables val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -val databases = Databases(client) +val tables = Tables(client) -val result = databases.incrementDocumentAttribute( +val result = tables.getRow( databaseId = "", - collectionId = "", - documentId = "", - attribute = "", - value = 0, // (optional) - max = 0, // (optional) + tableId = "", + rowId = "", + queries = listOf(), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/tables/list-rows.md b/docs/examples/kotlin/tables/list-rows.md new file mode 100644 index 0000000..ff36543 --- /dev/null +++ b/docs/examples/kotlin/tables/list-rows.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Tables + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val tables = Tables(client) + +val result = tables.listRows( + databaseId = "", + tableId = "", + queries = listOf(), // (optional) +) \ No newline at end of file diff --git a/docs/examples/kotlin/tables/update-row.md b/docs/examples/kotlin/tables/update-row.md new file mode 100644 index 0000000..e9b515c --- /dev/null +++ b/docs/examples/kotlin/tables/update-row.md @@ -0,0 +1,17 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Tables + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val tables = Tables(client) + +val result = tables.updateRow( + databaseId = "", + tableId = "", + rowId = "", + data = mapOf( "a" to "b" ), // (optional) + permissions = listOf("read("any")"), // (optional) +) \ No newline at end of file diff --git a/docs/examples/kotlin/tables/upsert-row.md b/docs/examples/kotlin/tables/upsert-row.md new file mode 100644 index 0000000..6b7cb66 --- /dev/null +++ b/docs/examples/kotlin/tables/upsert-row.md @@ -0,0 +1,17 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Tables + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setSession("") // The user session to authenticate with + .setKey("") // + .setJWT("") // Your secret JSON Web Token + +val tables = Tables(client) + +val result = tables.upsertRow( + databaseId = "", + tableId = "", + rowId = "", +) \ 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 bf0480f..10f9255 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -87,8 +87,8 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "8.2.0", - "x-appwrite-response-format" to "1.7.0" + "x-sdk-version" to "9.0.0", + "x-appwrite-response-format" to "1.8.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/models/ContinentList.kt b/library/src/main/java/io/appwrite/models/ContinentList.kt index fdd490a..a6ec310 100644 --- a/library/src/main/java/io/appwrite/models/ContinentList.kt +++ b/library/src/main/java/io/appwrite/models/ContinentList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class ContinentList( /** - * Total number of continents documents that matched your query. + * Total number of continents rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/CountryList.kt b/library/src/main/java/io/appwrite/models/CountryList.kt index 350a894..546cf73 100644 --- a/library/src/main/java/io/appwrite/models/CountryList.kt +++ b/library/src/main/java/io/appwrite/models/CountryList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class CountryList( /** - * Total number of countries documents that matched your query. + * Total number of countries rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/CurrencyList.kt b/library/src/main/java/io/appwrite/models/CurrencyList.kt index fe1e001..95dec92 100644 --- a/library/src/main/java/io/appwrite/models/CurrencyList.kt +++ b/library/src/main/java/io/appwrite/models/CurrencyList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class CurrencyList( /** - * Total number of currencies documents that matched your query. + * Total number of currencies rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/DocumentList.kt b/library/src/main/java/io/appwrite/models/DocumentList.kt index fa3dd20..6f40579 100644 --- a/library/src/main/java/io/appwrite/models/DocumentList.kt +++ b/library/src/main/java/io/appwrite/models/DocumentList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class DocumentList( /** - * Total number of documents documents that matched your query. + * Total number of documents rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/ExecutionList.kt b/library/src/main/java/io/appwrite/models/ExecutionList.kt index 322aeee..ac11e4f 100644 --- a/library/src/main/java/io/appwrite/models/ExecutionList.kt +++ b/library/src/main/java/io/appwrite/models/ExecutionList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class ExecutionList( /** - * Total number of executions documents that matched your query. + * Total number of executions rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/FileList.kt b/library/src/main/java/io/appwrite/models/FileList.kt index 5af18f1..ba69ea8 100644 --- a/library/src/main/java/io/appwrite/models/FileList.kt +++ b/library/src/main/java/io/appwrite/models/FileList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class FileList( /** - * Total number of files documents that matched your query. + * Total number of files rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/IdentityList.kt b/library/src/main/java/io/appwrite/models/IdentityList.kt index 1cbb07d..2e1a33a 100644 --- a/library/src/main/java/io/appwrite/models/IdentityList.kt +++ b/library/src/main/java/io/appwrite/models/IdentityList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class IdentityList( /** - * Total number of identities documents that matched your query. + * Total number of identities rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/LanguageList.kt b/library/src/main/java/io/appwrite/models/LanguageList.kt index 07559b9..ab78452 100644 --- a/library/src/main/java/io/appwrite/models/LanguageList.kt +++ b/library/src/main/java/io/appwrite/models/LanguageList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class LanguageList( /** - * Total number of languages documents that matched your query. + * Total number of languages rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/LocaleCodeList.kt b/library/src/main/java/io/appwrite/models/LocaleCodeList.kt index 3973a03..6f47333 100644 --- a/library/src/main/java/io/appwrite/models/LocaleCodeList.kt +++ b/library/src/main/java/io/appwrite/models/LocaleCodeList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class LocaleCodeList( /** - * Total number of localeCodes documents that matched your query. + * Total number of localeCodes rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/LogList.kt b/library/src/main/java/io/appwrite/models/LogList.kt index b9f381c..d2e0b00 100644 --- a/library/src/main/java/io/appwrite/models/LogList.kt +++ b/library/src/main/java/io/appwrite/models/LogList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class LogList( /** - * Total number of logs documents that matched your query. + * Total number of logs rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/MembershipList.kt b/library/src/main/java/io/appwrite/models/MembershipList.kt index 7feaaaa..efcffc4 100644 --- a/library/src/main/java/io/appwrite/models/MembershipList.kt +++ b/library/src/main/java/io/appwrite/models/MembershipList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class MembershipList( /** - * Total number of memberships documents that matched your query. + * Total number of memberships rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/PhoneList.kt b/library/src/main/java/io/appwrite/models/PhoneList.kt index b17de4f..675295f 100644 --- a/library/src/main/java/io/appwrite/models/PhoneList.kt +++ b/library/src/main/java/io/appwrite/models/PhoneList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class PhoneList( /** - * Total number of phones documents that matched your query. + * Total number of phones rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/Row.kt b/library/src/main/java/io/appwrite/models/Row.kt new file mode 100644 index 0000000..bb5c14f --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Row.kt @@ -0,0 +1,105 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Row + */ +data class Row( + /** + * Row ID. + */ + @SerializedName("\$id") + val id: String, + + /** + * Row automatically incrementing ID. + */ + @SerializedName("\$sequence") + val sequence: Long, + + /** + * Table ID. + */ + @SerializedName("\$tableId") + val tableId: String, + + /** + * Database ID. + */ + @SerializedName("\$databaseId") + val databaseId: String, + + /** + * Row creation date in ISO 8601 format. + */ + @SerializedName("\$createdAt") + val createdAt: String, + + /** + * Row update date in ISO 8601 format. + */ + @SerializedName("\$updatedAt") + val updatedAt: String, + + /** + * Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + @SerializedName("\$permissions") + val permissions: List, + + /** + * Additional properties + */ + @SerializedName("data") + val data: T +) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$sequence" to sequence as Any, + "\$tableId" to tableId as Any, + "\$databaseId" to databaseId as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "\$permissions" to permissions as Any, + "data" to data!!.jsonCast(to = Map::class.java) + ) + + companion object { + operator fun invoke( + id: String, + sequence: Long, + tableId: String, + databaseId: String, + createdAt: String, + updatedAt: String, + permissions: List, + data: Map + ) = Row>( + id, + sequence, + tableId, + databaseId, + createdAt, + updatedAt, + permissions, + data + ) + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + nestedType: Class + ) = Row( + id = map["\$id"] as String, + sequence = (map["\$sequence"] as Number).toLong(), + tableId = map["\$tableId"] 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/RowList.kt b/library/src/main/java/io/appwrite/models/RowList.kt new file mode 100644 index 0000000..289f39b --- /dev/null +++ b/library/src/main/java/io/appwrite/models/RowList.kt @@ -0,0 +1,46 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Rows List + */ +data class RowList( + /** + * Total number of rows rows that matched your query. + */ + @SerializedName("total") + val total: Long, + + /** + * List of rows. + */ + @SerializedName("rows") + val rows: List>, + +) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "rows" to rows.map { it.toMap() } as Any, + ) + + companion object { + operator fun invoke( + total: Long, + rows: List>>, + ) = RowList>( + total, + rows, + ) + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + nestedType: Class + ) = RowList( + total = (map["total"] as Number).toLong(), + rows = (map["rows"] as List>).map { Row.from(map = it, nestedType) }, + ) + } +} \ 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 c7080e6..13e0c36 100644 --- a/library/src/main/java/io/appwrite/models/SessionList.kt +++ b/library/src/main/java/io/appwrite/models/SessionList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class SessionList( /** - * Total number of sessions documents that matched your query. + * Total number of sessions rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/TeamList.kt b/library/src/main/java/io/appwrite/models/TeamList.kt index 17ccd6b..f1a1968 100644 --- a/library/src/main/java/io/appwrite/models/TeamList.kt +++ b/library/src/main/java/io/appwrite/models/TeamList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class TeamList( /** - * Total number of teams documents that matched your query. + * Total number of teams rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index f50f074..bebf4db 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -1067,6 +1067,9 @@ class Account(client: Client) : Service(client) { * @param secret Valid verification token. * @return [io.appwrite.models.Session] */ + @Deprecated( + message = "This API has been deprecated." + ) suspend fun updateMagicURLSession( userId: String, secret: String, @@ -1174,6 +1177,9 @@ class Account(client: Client) : Service(client) { * @param secret Valid verification token. * @return [io.appwrite.models.Session] */ + @Deprecated( + message = "This API has been deprecated." + ) suspend fun updatePhoneSession( userId: String, secret: String, diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index edc10f5..d219644 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -23,6 +23,11 @@ class Databases(client: Client) : Service(client) { * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.DocumentList] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `Tables.listRows` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Tables.listRows"), + since = "1.8.0" + ) @JvmOverloads suspend fun listDocuments( databaseId: String, @@ -61,6 +66,11 @@ class Databases(client: Client) : Service(client) { * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.DocumentList] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `Tables.listRows` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Tables.listRows"), + since = "1.8.0" + ) @JvmOverloads @Throws(AppwriteException::class) suspend fun listDocuments( @@ -84,6 +94,11 @@ class Databases(client: Client) : Service(client) { * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `Tables.createRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Tables.createRow"), + since = "1.8.0" + ) @JvmOverloads suspend fun createDocument( databaseId: String, @@ -129,6 +144,11 @@ class Databases(client: Client) : Service(client) { * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `Tables.createRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Tables.createRow"), + since = "1.8.0" + ) @JvmOverloads @Throws(AppwriteException::class) suspend fun createDocument( @@ -155,6 +175,11 @@ class Databases(client: Client) : Service(client) { * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.Document] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `Tables.getRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Tables.getRow"), + since = "1.8.0" + ) @JvmOverloads suspend fun getDocument( databaseId: String, @@ -196,6 +221,11 @@ class Databases(client: Client) : Service(client) { * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.Document] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `Tables.getRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Tables.getRow"), + since = "1.8.0" + ) @JvmOverloads @Throws(AppwriteException::class) suspend fun getDocument( @@ -217,17 +247,17 @@ class Databases(client: Client) : Service(client) { * @param databaseId Database ID. * @param collectionId Collection ID. * @param documentId Document ID. - * @param data Document data as JSON object. Include all required attributes of the document to be created or updated. - * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ - @JvmOverloads + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `Tables.upsertRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Tables.upsertRow"), + since = "1.8.0" + ) suspend fun upsertDocument( databaseId: String, collectionId: String, documentId: String, - data: Any, - permissions: List? = null, nestedType: Class, ): io.appwrite.models.Document { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" @@ -236,8 +266,6 @@ class Databases(client: Client) : Service(client) { .replace("{documentId}", documentId) val apiParams = mutableMapOf( - "data" to data, - "permissions" to permissions, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -262,24 +290,22 @@ class Databases(client: Client) : Service(client) { * @param databaseId Database ID. * @param collectionId Collection ID. * @param documentId Document ID. - * @param data Document data as JSON object. Include all required attributes of the document to be created or updated. - * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ - @JvmOverloads + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `Tables.upsertRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Tables.upsertRow"), + since = "1.8.0" + ) @Throws(AppwriteException::class) suspend fun upsertDocument( databaseId: String, collectionId: String, documentId: String, - data: Any, - permissions: List? = null, ): io.appwrite.models.Document> = upsertDocument( databaseId, collectionId, documentId, - data, - permissions, nestedType = classOf(), ) @@ -293,6 +319,11 @@ class Databases(client: Client) : Service(client) { * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `Tables.updateRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Tables.updateRow"), + since = "1.8.0" + ) @JvmOverloads suspend fun updateDocument( databaseId: String, @@ -338,6 +369,11 @@ class Databases(client: Client) : Service(client) { * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `Tables.updateRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Tables.updateRow"), + since = "1.8.0" + ) @JvmOverloads @Throws(AppwriteException::class) suspend fun updateDocument( @@ -363,6 +399,11 @@ class Databases(client: Client) : Service(client) { * @param documentId Document ID. * @return [Any] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `Tables.deleteRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Tables.deleteRow"), + since = "1.8.0" + ) suspend fun deleteDocument( databaseId: String, collectionId: String, @@ -388,160 +429,4 @@ class Databases(client: Client) : Service(client) { } - /** - * Decrement a specific attribute of a document by a given value. - * - * @param databaseId Database ID. - * @param collectionId Collection ID. - * @param documentId Document ID. - * @param attribute Attribute key. - * @param value Value to decrement the attribute by. The value must be a number. - * @param min Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. - * @return [io.appwrite.models.Document] - */ - @JvmOverloads - suspend fun decrementDocumentAttribute( - databaseId: String, - collectionId: String, - documentId: String, - attribute: String, - value: Double? = null, - min: Double? = null, - nestedType: Class, - ): io.appwrite.models.Document { - val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement" - .replace("{databaseId}", databaseId) - .replace("{collectionId}", collectionId) - .replace("{documentId}", documentId) - .replace("{attribute}", attribute) - - val apiParams = mutableMapOf( - "value" to value, - "min" to min, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Document = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.Document.from(map = it as Map, nestedType) - } - return client.call( - "PATCH", - apiPath, - apiHeaders, - apiParams, - responseType = classOf(), - converter, - ) - } - - /** - * Decrement a specific attribute of a document by a given value. - * - * @param databaseId Database ID. - * @param collectionId Collection ID. - * @param documentId Document ID. - * @param attribute Attribute key. - * @param value Value to decrement the attribute by. The value must be a number. - * @param min Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. - * @return [io.appwrite.models.Document] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun decrementDocumentAttribute( - databaseId: String, - collectionId: String, - documentId: String, - attribute: String, - value: Double? = null, - min: Double? = null, - ): io.appwrite.models.Document> = decrementDocumentAttribute( - databaseId, - collectionId, - documentId, - attribute, - value, - min, - nestedType = classOf(), - ) - - /** - * Increment a specific attribute of a document by a given value. - * - * @param databaseId Database ID. - * @param collectionId Collection ID. - * @param documentId Document ID. - * @param attribute Attribute key. - * @param value Value to increment the attribute by. The value must be a number. - * @param max Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. - * @return [io.appwrite.models.Document] - */ - @JvmOverloads - suspend fun incrementDocumentAttribute( - databaseId: String, - collectionId: String, - documentId: String, - attribute: String, - value: Double? = null, - max: Double? = null, - nestedType: Class, - ): io.appwrite.models.Document { - val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment" - .replace("{databaseId}", databaseId) - .replace("{collectionId}", collectionId) - .replace("{documentId}", documentId) - .replace("{attribute}", attribute) - - val apiParams = mutableMapOf( - "value" to value, - "max" to max, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Document = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.Document.from(map = it as Map, nestedType) - } - return client.call( - "PATCH", - apiPath, - apiHeaders, - apiParams, - responseType = classOf(), - converter, - ) - } - - /** - * Increment a specific attribute of a document by a given value. - * - * @param databaseId Database ID. - * @param collectionId Collection ID. - * @param documentId Document ID. - * @param attribute Attribute key. - * @param value Value to increment the attribute by. The value must be a number. - * @param max Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. - * @return [io.appwrite.models.Document] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun incrementDocumentAttribute( - databaseId: String, - collectionId: String, - documentId: String, - attribute: String, - value: Double? = null, - max: Double? = null, - ): io.appwrite.models.Document> = incrementDocumentAttribute( - databaseId, - collectionId, - documentId, - attribute, - value, - max, - nestedType = classOf(), - ) - } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Tables.kt b/library/src/main/java/io/appwrite/services/Tables.kt new file mode 100644 index 0000000..f1ff34d --- /dev/null +++ b/library/src/main/java/io/appwrite/services/Tables.kt @@ -0,0 +1,435 @@ +package io.appwrite.services + +import android.net.Uri +import io.appwrite.Client +import io.appwrite.Service +import io.appwrite.models.* +import io.appwrite.enums.* +import io.appwrite.exceptions.AppwriteException +import io.appwrite.extensions.classOf +import okhttp3.Cookie +import java.io.File + +/** + * The Tables service allows you to create structured tables of rows, query and filter lists of rows +**/ +class Tables(client: Client) : Service(client) { + + /** + * Get a list of all the user's rows in a given table. You can use the query params to filter your results. + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @return [io.appwrite.models.RowList] + */ + @JvmOverloads + suspend fun listRows( + databaseId: String, + tableId: String, + queries: List? = null, + nestedType: Class, + ): io.appwrite.models.RowList { + val apiPath = "/databases/{databaseId}/tables/{tableId}/rows" + .replace("{databaseId}", databaseId) + .replace("{tableId}", tableId) + + val apiParams = mutableMapOf( + "queries" to queries, + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.RowList = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.RowList.from(map = it as Map, nestedType) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Get a list of all the user's rows in a given table. You can use the query params to filter your results. + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @return [io.appwrite.models.RowList] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun listRows( + databaseId: String, + tableId: String, + queries: List? = null, + ): io.appwrite.models.RowList> = listRows( + databaseId, + tableId, + queries, + nestedType = classOf(), + ) + + /** + * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). Make sure to define columns before creating rows. + * @param rowId Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 Row data as JSON object. + * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @return [io.appwrite.models.Row] + */ + @JvmOverloads + suspend fun createRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any, + permissions: List? = null, + nestedType: Class, + ): io.appwrite.models.Row { + val apiPath = "/databases/{databaseId}/tables/{tableId}/rows" + .replace("{databaseId}", databaseId) + .replace("{tableId}", tableId) + + val apiParams = mutableMapOf( + "rowId" to rowId, + "data" to data, + "permissions" to permissions, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Row = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Row.from(map = it as Map, nestedType) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). Make sure to define columns before creating rows. + * @param rowId Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 Row data as JSON object. + * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @return [io.appwrite.models.Row] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any, + permissions: List? = null, + ): io.appwrite.models.Row> = createRow( + databaseId, + tableId, + rowId, + data, + permissions, + nestedType = classOf(), + ) + + /** + * Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). Make sure to define columns before creating rows. + * @param rows Array of documents data as JSON objects. + * @return [io.appwrite.models.RowList] + */ + suspend fun createRows( + databaseId: String, + tableId: String, + rows: List, + nestedType: Class, + ): io.appwrite.models.RowList { + val apiPath = "/databases/{databaseId}/tables/{tableId}/rows" + .replace("{databaseId}", databaseId) + .replace("{tableId}", tableId) + + val apiParams = mutableMapOf( + "rows" to rows, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.RowList = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.RowList.from(map = it as Map, nestedType) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). Make sure to define columns before creating rows. + * @param rows Array of documents data as JSON objects. + * @return [io.appwrite.models.RowList] + */ + @Throws(AppwriteException::class) + suspend fun createRows( + databaseId: String, + tableId: String, + rows: List, + ): io.appwrite.models.RowList> = createRows( + databaseId, + tableId, + rows, + nestedType = classOf(), + ) + + /** + * Get a row by its unique ID. This endpoint response returns a JSON object with the row data. + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). + * @param rowId Row ID. + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @return [io.appwrite.models.Row] + */ + @JvmOverloads + suspend fun getRow( + databaseId: String, + tableId: String, + rowId: String, + queries: List? = null, + nestedType: Class, + ): io.appwrite.models.Row { + val apiPath = "/databases/{databaseId}/tables/{tableId}/rows/{rowId}" + .replace("{databaseId}", databaseId) + .replace("{tableId}", tableId) + .replace("{rowId}", rowId) + + val apiParams = mutableMapOf( + "queries" to queries, + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.Row = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Row.from(map = it as Map, nestedType) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Get a row by its unique ID. This endpoint response returns a JSON object with the row data. + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). + * @param rowId Row ID. + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @return [io.appwrite.models.Row] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getRow( + databaseId: String, + tableId: String, + rowId: String, + queries: List? = null, + ): io.appwrite.models.Row> = getRow( + databaseId, + tableId, + rowId, + queries, + nestedType = classOf(), + ) + + /** + * Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. + * + * @param databaseId Database ID. + * @param tableId Table ID. + * @param rowId Row ID. + * @return [io.appwrite.models.Row] + */ + suspend fun upsertRow( + databaseId: String, + tableId: String, + rowId: String, + nestedType: Class, + ): io.appwrite.models.Row { + val apiPath = "/databases/{databaseId}/tables/{tableId}/rows/{rowId}" + .replace("{databaseId}", databaseId) + .replace("{tableId}", tableId) + .replace("{rowId}", rowId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Row = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Row.from(map = it as Map, nestedType) + } + return client.call( + "PUT", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. + * + * @param databaseId Database ID. + * @param tableId Table ID. + * @param rowId Row ID. + * @return [io.appwrite.models.Row] + */ + @Throws(AppwriteException::class) + suspend fun upsertRow( + databaseId: String, + tableId: String, + rowId: String, + ): io.appwrite.models.Row> = upsertRow( + databaseId, + tableId, + rowId, + nestedType = classOf(), + ) + + /** + * Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. + * + * @param databaseId Database ID. + * @param tableId Table ID. + * @param rowId Row ID. + * @param data Row data as JSON object. Include only columns and value pairs to be updated. + * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @return [io.appwrite.models.Row] + */ + @JvmOverloads + suspend fun updateRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any? = null, + permissions: List? = null, + nestedType: Class, + ): io.appwrite.models.Row { + val apiPath = "/databases/{databaseId}/tables/{tableId}/rows/{rowId}" + .replace("{databaseId}", databaseId) + .replace("{tableId}", tableId) + .replace("{rowId}", rowId) + + val apiParams = mutableMapOf( + "data" to data, + "permissions" to permissions, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Row = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Row.from(map = it as Map, nestedType) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. + * + * @param databaseId Database ID. + * @param tableId Table ID. + * @param rowId Row ID. + * @param data Row data as JSON object. Include only columns and value pairs to be updated. + * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @return [io.appwrite.models.Row] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updateRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any? = null, + permissions: List? = null, + ): io.appwrite.models.Row> = updateRow( + databaseId, + tableId, + rowId, + data, + permissions, + nestedType = classOf(), + ) + + /** + * Delete a row by its unique ID. + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). + * @param rowId Row ID. + * @return [Any] + */ + suspend fun deleteRow( + databaseId: String, + tableId: String, + rowId: String, + ): Any { + val apiPath = "/databases/{databaseId}/tables/{tableId}/rows/{rowId}" + .replace("{databaseId}", databaseId) + .replace("{tableId}", tableId) + .replace("{rowId}", rowId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = Any::class.java, + ) + } + + +} \ No newline at end of file From a52f013463eb61619fa9e75be67ffb4831eb7f60 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 24 Jul 2025 06:35:45 +0000 Subject: [PATCH 105/118] chore: regen --- README.md | 8 +- .../java/databases/create-document.md | 4 +- .../decrement-document-attribute.md} | 13 +- .../increment-document-attribute.md} | 15 +- .../java/databases/upsert-document.md | 6 +- docs/examples/java/tables/create-row.md | 28 -- docs/examples/java/tables/create-rows.md | 25 - docs/examples/java/tables/delete-row.md | 24 - docs/examples/java/tables/get-row.md | 25 - docs/examples/java/tables/upsert-row.md | 26 -- .../kotlin/databases/create-document.md | 4 +- .../decrement-document-attribute.md} | 15 +- .../increment-document-attribute.md} | 14 +- .../kotlin/databases/upsert-document.md | 6 +- docs/examples/kotlin/tables/create-row.md | 19 - docs/examples/kotlin/tables/create-rows.md | 16 - docs/examples/kotlin/tables/delete-row.md | 15 - docs/examples/kotlin/tables/list-rows.md | 15 - docs/examples/kotlin/tables/upsert-row.md | 17 - library/src/main/java/io/appwrite/Client.kt | 4 +- .../java/io/appwrite/models/ContinentList.kt | 2 +- .../java/io/appwrite/models/CountryList.kt | 2 +- .../java/io/appwrite/models/CurrencyList.kt | 2 +- .../java/io/appwrite/models/DocumentList.kt | 2 +- .../java/io/appwrite/models/ExecutionList.kt | 2 +- .../main/java/io/appwrite/models/FileList.kt | 2 +- .../java/io/appwrite/models/IdentityList.kt | 2 +- .../java/io/appwrite/models/LanguageList.kt | 2 +- .../java/io/appwrite/models/LocaleCodeList.kt | 2 +- .../main/java/io/appwrite/models/LogList.kt | 2 +- .../java/io/appwrite/models/MembershipList.kt | 2 +- .../main/java/io/appwrite/models/PhoneList.kt | 2 +- .../src/main/java/io/appwrite/models/Row.kt | 105 ----- .../main/java/io/appwrite/models/RowList.kt | 46 -- .../java/io/appwrite/models/SessionList.kt | 2 +- .../main/java/io/appwrite/models/TeamList.kt | 2 +- .../main/java/io/appwrite/services/Account.kt | 6 - .../java/io/appwrite/services/Databases.kt | 225 ++++++--- .../main/java/io/appwrite/services/Tables.kt | 435 ------------------ 39 files changed, 230 insertions(+), 914 deletions(-) rename docs/examples/java/{tables/list-rows.md => databases/decrement-document-attribute.md} (64%) rename docs/examples/java/{tables/update-row.md => databases/increment-document-attribute.md} (64%) delete mode 100644 docs/examples/java/tables/create-row.md delete mode 100644 docs/examples/java/tables/create-rows.md delete mode 100644 docs/examples/java/tables/delete-row.md delete mode 100644 docs/examples/java/tables/get-row.md delete mode 100644 docs/examples/java/tables/upsert-row.md rename docs/examples/kotlin/{tables/update-row.md => databases/decrement-document-attribute.md} (50%) rename docs/examples/kotlin/{tables/get-row.md => databases/increment-document-attribute.md} (50%) delete mode 100644 docs/examples/kotlin/tables/create-row.md delete mode 100644 docs/examples/kotlin/tables/create-rows.md delete mode 100644 docs/examples/kotlin/tables/delete-row.md delete mode 100644 docs/examples/kotlin/tables/list-rows.md delete mode 100644 docs/examples/kotlin/tables/upsert-row.md delete mode 100644 library/src/main/java/io/appwrite/models/Row.kt delete mode 100644 library/src/main/java/io/appwrite/models/RowList.kt delete mode 100644 library/src/main/java/io/appwrite/services/Tables.kt diff --git a/README.md b/README.md index 5ced453..745f21c 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.8.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.7.4-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.8.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.7.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:9.0.0") +implementation("io.appwrite:sdk-for-android:8.2.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 9.0.0 + 8.2.0 ``` diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index 7fb129b..4804d75 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -4,9 +4,7 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setSession("") // The user session to authenticate with - .setKey("") // - .setJWT(""); // Your secret JSON Web Token + .setProject(""); // Your project ID Databases databases = new Databases(client); diff --git a/docs/examples/java/tables/list-rows.md b/docs/examples/java/databases/decrement-document-attribute.md similarity index 64% rename from docs/examples/java/tables/list-rows.md rename to docs/examples/java/databases/decrement-document-attribute.md index 4d37570..de6a4ab 100644 --- a/docs/examples/java/tables/list-rows.md +++ b/docs/examples/java/databases/decrement-document-attribute.md @@ -1,17 +1,20 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Tables; +import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID -Tables tables = new Tables(client); +Databases databases = new Databases(client); -tables.listRows( +databases.decrementDocumentAttribute( "", // databaseId - "", // tableId - listOf(), // queries (optional) + "", // collectionId + "", // documentId + "", // attribute + 0, // value (optional) + 0, // min (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tables/update-row.md b/docs/examples/java/databases/increment-document-attribute.md similarity index 64% rename from docs/examples/java/tables/update-row.md rename to docs/examples/java/databases/increment-document-attribute.md index 0421c9c..94ffa9d 100644 --- a/docs/examples/java/tables/update-row.md +++ b/docs/examples/java/databases/increment-document-attribute.md @@ -1,19 +1,20 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Tables; +import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID -Tables tables = new Tables(client); +Databases databases = new Databases(client); -tables.updateRow( +databases.incrementDocumentAttribute( "", // databaseId - "", // tableId - "", // rowId - mapOf( "a" to "b" ), // data (optional) - listOf("read("any")"), // permissions (optional) + "", // collectionId + "", // documentId + "", // attribute + 0, // value (optional) + 0, // max (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/upsert-document.md b/docs/examples/java/databases/upsert-document.md index ba7336f..868576b 100644 --- a/docs/examples/java/databases/upsert-document.md +++ b/docs/examples/java/databases/upsert-document.md @@ -4,9 +4,7 @@ import io.appwrite.services.Databases; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setSession("") // The user session to authenticate with - .setKey("") // - .setJWT(""); // Your secret JSON Web Token + .setProject(""); // Your project ID Databases databases = new Databases(client); @@ -14,6 +12,8 @@ databases.upsertDocument( "", // databaseId "", // collectionId "", // documentId + mapOf( "a" to "b" ), // data + listOf("read("any")"), // permissions (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tables/create-row.md b/docs/examples/java/tables/create-row.md deleted file mode 100644 index 8102b82..0000000 --- a/docs/examples/java/tables/create-row.md +++ /dev/null @@ -1,28 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Tables; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setSession("") // The user session to authenticate with - .setKey("") // - .setJWT(""); // Your secret JSON Web Token - -Tables tables = new Tables(client); - -tables.createRow( - "", // databaseId - "", // tableId - "", // rowId - mapOf( "a" to "b" ), // data - listOf("read("any")"), // permissions (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - diff --git a/docs/examples/java/tables/create-rows.md b/docs/examples/java/tables/create-rows.md deleted file mode 100644 index 26f5d67..0000000 --- a/docs/examples/java/tables/create-rows.md +++ /dev/null @@ -1,25 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Tables; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setAdmin("") // - .setKey(""); // - -Tables tables = new Tables(client); - -tables.createRows( - "", // databaseId - "", // tableId - listOf(), // rows - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - diff --git a/docs/examples/java/tables/delete-row.md b/docs/examples/java/tables/delete-row.md deleted file mode 100644 index 596a8b7..0000000 --- a/docs/examples/java/tables/delete-row.md +++ /dev/null @@ -1,24 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Tables; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Tables tables = new Tables(client); - -tables.deleteRow( - "", // databaseId - "", // tableId - "", // rowId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - diff --git a/docs/examples/java/tables/get-row.md b/docs/examples/java/tables/get-row.md deleted file mode 100644 index 882a195..0000000 --- a/docs/examples/java/tables/get-row.md +++ /dev/null @@ -1,25 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Tables; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Tables tables = new Tables(client); - -tables.getRow( - "", // databaseId - "", // tableId - "", // rowId - listOf(), // queries (optional) - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - diff --git a/docs/examples/java/tables/upsert-row.md b/docs/examples/java/tables/upsert-row.md deleted file mode 100644 index a8be0cf..0000000 --- a/docs/examples/java/tables/upsert-row.md +++ /dev/null @@ -1,26 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Tables; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setSession("") // The user session to authenticate with - .setKey("") // - .setJWT(""); // Your secret JSON Web Token - -Tables tables = new Tables(client); - -tables.upsertRow( - "", // databaseId - "", // tableId - "", // rowId - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index 0bafb31..849a636 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -4,9 +4,7 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setSession("") // The user session to authenticate with - .setKey("") // - .setJWT("") // Your secret JSON Web Token + .setProject("") // Your project ID val databases = Databases(client) diff --git a/docs/examples/kotlin/tables/update-row.md b/docs/examples/kotlin/databases/decrement-document-attribute.md similarity index 50% rename from docs/examples/kotlin/tables/update-row.md rename to docs/examples/kotlin/databases/decrement-document-attribute.md index e9b515c..c500fa8 100644 --- a/docs/examples/kotlin/tables/update-row.md +++ b/docs/examples/kotlin/databases/decrement-document-attribute.md @@ -1,17 +1,18 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Tables +import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -val tables = Tables(client) +val databases = Databases(client) -val result = tables.updateRow( +val result = databases.decrementDocumentAttribute( databaseId = "", - tableId = "", - rowId = "", - data = mapOf( "a" to "b" ), // (optional) - permissions = listOf("read("any")"), // (optional) + collectionId = "", + documentId = "", + attribute = "", + value = 0, // (optional) + min = 0, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/tables/get-row.md b/docs/examples/kotlin/databases/increment-document-attribute.md similarity index 50% rename from docs/examples/kotlin/tables/get-row.md rename to docs/examples/kotlin/databases/increment-document-attribute.md index 15dabff..0ae6b02 100644 --- a/docs/examples/kotlin/tables/get-row.md +++ b/docs/examples/kotlin/databases/increment-document-attribute.md @@ -1,16 +1,18 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Tables +import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -val tables = Tables(client) +val databases = Databases(client) -val result = tables.getRow( +val result = databases.incrementDocumentAttribute( databaseId = "", - tableId = "", - rowId = "", - queries = listOf(), // (optional) + collectionId = "", + documentId = "", + attribute = "", + value = 0, // (optional) + max = 0, // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/upsert-document.md b/docs/examples/kotlin/databases/upsert-document.md index 7939fde..a31dfc8 100644 --- a/docs/examples/kotlin/databases/upsert-document.md +++ b/docs/examples/kotlin/databases/upsert-document.md @@ -4,9 +4,7 @@ import io.appwrite.services.Databases val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setSession("") // The user session to authenticate with - .setKey("") // - .setJWT("") // Your secret JSON Web Token + .setProject("") // Your project ID val databases = Databases(client) @@ -14,4 +12,6 @@ val result = databases.upsertDocument( databaseId = "", collectionId = "", documentId = "", + data = mapOf( "a" to "b" ), + permissions = listOf("read("any")"), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/tables/create-row.md b/docs/examples/kotlin/tables/create-row.md deleted file mode 100644 index 8c581bf..0000000 --- a/docs/examples/kotlin/tables/create-row.md +++ /dev/null @@ -1,19 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Tables - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setSession("") // The user session to authenticate with - .setKey("") // - .setJWT("") // Your secret JSON Web Token - -val tables = Tables(client) - -val result = tables.createRow( - databaseId = "", - tableId = "", - rowId = "", - data = mapOf( "a" to "b" ), - permissions = listOf("read("any")"), // (optional) -) \ No newline at end of file diff --git a/docs/examples/kotlin/tables/create-rows.md b/docs/examples/kotlin/tables/create-rows.md deleted file mode 100644 index 1fde9c5..0000000 --- a/docs/examples/kotlin/tables/create-rows.md +++ /dev/null @@ -1,16 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Tables - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setAdmin("") // - .setKey("") // - -val tables = Tables(client) - -val result = tables.createRows( - databaseId = "", - tableId = "", - rows = listOf(), -) \ No newline at end of file diff --git a/docs/examples/kotlin/tables/delete-row.md b/docs/examples/kotlin/tables/delete-row.md deleted file mode 100644 index ffa3229..0000000 --- a/docs/examples/kotlin/tables/delete-row.md +++ /dev/null @@ -1,15 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Tables - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val tables = Tables(client) - -val result = tables.deleteRow( - databaseId = "", - tableId = "", - rowId = "", -) \ No newline at end of file diff --git a/docs/examples/kotlin/tables/list-rows.md b/docs/examples/kotlin/tables/list-rows.md deleted file mode 100644 index ff36543..0000000 --- a/docs/examples/kotlin/tables/list-rows.md +++ /dev/null @@ -1,15 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Tables - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val tables = Tables(client) - -val result = tables.listRows( - databaseId = "", - tableId = "", - queries = listOf(), // (optional) -) \ No newline at end of file diff --git a/docs/examples/kotlin/tables/upsert-row.md b/docs/examples/kotlin/tables/upsert-row.md deleted file mode 100644 index 6b7cb66..0000000 --- a/docs/examples/kotlin/tables/upsert-row.md +++ /dev/null @@ -1,17 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Tables - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setSession("") // The user session to authenticate with - .setKey("") // - .setJWT("") // Your secret JSON Web Token - -val tables = Tables(client) - -val result = tables.upsertRow( - databaseId = "", - tableId = "", - rowId = "", -) \ 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 10f9255..bf0480f 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -87,8 +87,8 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "9.0.0", - "x-appwrite-response-format" to "1.8.0" + "x-sdk-version" to "8.2.0", + "x-appwrite-response-format" to "1.7.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/models/ContinentList.kt b/library/src/main/java/io/appwrite/models/ContinentList.kt index a6ec310..fdd490a 100644 --- a/library/src/main/java/io/appwrite/models/ContinentList.kt +++ b/library/src/main/java/io/appwrite/models/ContinentList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class ContinentList( /** - * Total number of continents rows that matched your query. + * Total number of continents documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/CountryList.kt b/library/src/main/java/io/appwrite/models/CountryList.kt index 546cf73..350a894 100644 --- a/library/src/main/java/io/appwrite/models/CountryList.kt +++ b/library/src/main/java/io/appwrite/models/CountryList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class CountryList( /** - * Total number of countries rows that matched your query. + * Total number of countries documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/CurrencyList.kt b/library/src/main/java/io/appwrite/models/CurrencyList.kt index 95dec92..fe1e001 100644 --- a/library/src/main/java/io/appwrite/models/CurrencyList.kt +++ b/library/src/main/java/io/appwrite/models/CurrencyList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class CurrencyList( /** - * Total number of currencies rows that matched your query. + * Total number of currencies documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/DocumentList.kt b/library/src/main/java/io/appwrite/models/DocumentList.kt index 6f40579..fa3dd20 100644 --- a/library/src/main/java/io/appwrite/models/DocumentList.kt +++ b/library/src/main/java/io/appwrite/models/DocumentList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class DocumentList( /** - * Total number of documents rows that matched your query. + * Total number of documents documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/ExecutionList.kt b/library/src/main/java/io/appwrite/models/ExecutionList.kt index ac11e4f..322aeee 100644 --- a/library/src/main/java/io/appwrite/models/ExecutionList.kt +++ b/library/src/main/java/io/appwrite/models/ExecutionList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class ExecutionList( /** - * Total number of executions rows that matched your query. + * Total number of executions documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/FileList.kt b/library/src/main/java/io/appwrite/models/FileList.kt index ba69ea8..5af18f1 100644 --- a/library/src/main/java/io/appwrite/models/FileList.kt +++ b/library/src/main/java/io/appwrite/models/FileList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class FileList( /** - * Total number of files rows that matched your query. + * Total number of files documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/IdentityList.kt b/library/src/main/java/io/appwrite/models/IdentityList.kt index 2e1a33a..1cbb07d 100644 --- a/library/src/main/java/io/appwrite/models/IdentityList.kt +++ b/library/src/main/java/io/appwrite/models/IdentityList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class IdentityList( /** - * Total number of identities rows that matched your query. + * Total number of identities documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/LanguageList.kt b/library/src/main/java/io/appwrite/models/LanguageList.kt index ab78452..07559b9 100644 --- a/library/src/main/java/io/appwrite/models/LanguageList.kt +++ b/library/src/main/java/io/appwrite/models/LanguageList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class LanguageList( /** - * Total number of languages rows that matched your query. + * Total number of languages documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/LocaleCodeList.kt b/library/src/main/java/io/appwrite/models/LocaleCodeList.kt index 6f47333..3973a03 100644 --- a/library/src/main/java/io/appwrite/models/LocaleCodeList.kt +++ b/library/src/main/java/io/appwrite/models/LocaleCodeList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class LocaleCodeList( /** - * Total number of localeCodes rows that matched your query. + * Total number of localeCodes documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/LogList.kt b/library/src/main/java/io/appwrite/models/LogList.kt index d2e0b00..b9f381c 100644 --- a/library/src/main/java/io/appwrite/models/LogList.kt +++ b/library/src/main/java/io/appwrite/models/LogList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class LogList( /** - * Total number of logs rows that matched your query. + * Total number of logs documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/MembershipList.kt b/library/src/main/java/io/appwrite/models/MembershipList.kt index efcffc4..7feaaaa 100644 --- a/library/src/main/java/io/appwrite/models/MembershipList.kt +++ b/library/src/main/java/io/appwrite/models/MembershipList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class MembershipList( /** - * Total number of memberships rows that matched your query. + * Total number of memberships documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/PhoneList.kt b/library/src/main/java/io/appwrite/models/PhoneList.kt index 675295f..b17de4f 100644 --- a/library/src/main/java/io/appwrite/models/PhoneList.kt +++ b/library/src/main/java/io/appwrite/models/PhoneList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class PhoneList( /** - * Total number of phones rows that matched your query. + * Total number of phones documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/Row.kt b/library/src/main/java/io/appwrite/models/Row.kt deleted file mode 100644 index bb5c14f..0000000 --- a/library/src/main/java/io/appwrite/models/Row.kt +++ /dev/null @@ -1,105 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * Row - */ -data class Row( - /** - * Row ID. - */ - @SerializedName("\$id") - val id: String, - - /** - * Row automatically incrementing ID. - */ - @SerializedName("\$sequence") - val sequence: Long, - - /** - * Table ID. - */ - @SerializedName("\$tableId") - val tableId: String, - - /** - * Database ID. - */ - @SerializedName("\$databaseId") - val databaseId: String, - - /** - * Row creation date in ISO 8601 format. - */ - @SerializedName("\$createdAt") - val createdAt: String, - - /** - * Row update date in ISO 8601 format. - */ - @SerializedName("\$updatedAt") - val updatedAt: String, - - /** - * Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - */ - @SerializedName("\$permissions") - val permissions: List, - - /** - * Additional properties - */ - @SerializedName("data") - val data: T -) { - fun toMap(): Map = mapOf( - "\$id" to id as Any, - "\$sequence" to sequence as Any, - "\$tableId" to tableId as Any, - "\$databaseId" to databaseId as Any, - "\$createdAt" to createdAt as Any, - "\$updatedAt" to updatedAt as Any, - "\$permissions" to permissions as Any, - "data" to data!!.jsonCast(to = Map::class.java) - ) - - companion object { - operator fun invoke( - id: String, - sequence: Long, - tableId: String, - databaseId: String, - createdAt: String, - updatedAt: String, - permissions: List, - data: Map - ) = Row>( - id, - sequence, - tableId, - databaseId, - createdAt, - updatedAt, - permissions, - data - ) - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - nestedType: Class - ) = Row( - id = map["\$id"] as String, - sequence = (map["\$sequence"] as Number).toLong(), - tableId = map["\$tableId"] 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/RowList.kt b/library/src/main/java/io/appwrite/models/RowList.kt deleted file mode 100644 index 289f39b..0000000 --- a/library/src/main/java/io/appwrite/models/RowList.kt +++ /dev/null @@ -1,46 +0,0 @@ -package io.appwrite.models - -import com.google.gson.annotations.SerializedName -import io.appwrite.extensions.jsonCast - -/** - * Rows List - */ -data class RowList( - /** - * Total number of rows rows that matched your query. - */ - @SerializedName("total") - val total: Long, - - /** - * List of rows. - */ - @SerializedName("rows") - val rows: List>, - -) { - fun toMap(): Map = mapOf( - "total" to total as Any, - "rows" to rows.map { it.toMap() } as Any, - ) - - companion object { - operator fun invoke( - total: Long, - rows: List>>, - ) = RowList>( - total, - rows, - ) - - @Suppress("UNCHECKED_CAST") - fun from( - map: Map, - nestedType: Class - ) = RowList( - total = (map["total"] as Number).toLong(), - rows = (map["rows"] as List>).map { Row.from(map = it, nestedType) }, - ) - } -} \ 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 13e0c36..c7080e6 100644 --- a/library/src/main/java/io/appwrite/models/SessionList.kt +++ b/library/src/main/java/io/appwrite/models/SessionList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class SessionList( /** - * Total number of sessions rows that matched your query. + * Total number of sessions documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/TeamList.kt b/library/src/main/java/io/appwrite/models/TeamList.kt index f1a1968..17ccd6b 100644 --- a/library/src/main/java/io/appwrite/models/TeamList.kt +++ b/library/src/main/java/io/appwrite/models/TeamList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class TeamList( /** - * Total number of teams rows that matched your query. + * Total number of teams documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index bebf4db..f50f074 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -1067,9 +1067,6 @@ class Account(client: Client) : Service(client) { * @param secret Valid verification token. * @return [io.appwrite.models.Session] */ - @Deprecated( - message = "This API has been deprecated." - ) suspend fun updateMagicURLSession( userId: String, secret: String, @@ -1177,9 +1174,6 @@ class Account(client: Client) : Service(client) { * @param secret Valid verification token. * @return [io.appwrite.models.Session] */ - @Deprecated( - message = "This API has been deprecated." - ) suspend fun updatePhoneSession( userId: String, secret: String, diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index d219644..edc10f5 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -23,11 +23,6 @@ class Databases(client: Client) : Service(client) { * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.DocumentList] */ - @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `Tables.listRows` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Tables.listRows"), - since = "1.8.0" - ) @JvmOverloads suspend fun listDocuments( databaseId: String, @@ -66,11 +61,6 @@ class Databases(client: Client) : Service(client) { * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.DocumentList] */ - @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `Tables.listRows` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Tables.listRows"), - since = "1.8.0" - ) @JvmOverloads @Throws(AppwriteException::class) suspend fun listDocuments( @@ -94,11 +84,6 @@ class Databases(client: Client) : Service(client) { * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ - @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `Tables.createRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Tables.createRow"), - since = "1.8.0" - ) @JvmOverloads suspend fun createDocument( databaseId: String, @@ -144,11 +129,6 @@ class Databases(client: Client) : Service(client) { * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ - @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `Tables.createRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Tables.createRow"), - since = "1.8.0" - ) @JvmOverloads @Throws(AppwriteException::class) suspend fun createDocument( @@ -175,11 +155,6 @@ class Databases(client: Client) : Service(client) { * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.Document] */ - @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `Tables.getRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Tables.getRow"), - since = "1.8.0" - ) @JvmOverloads suspend fun getDocument( databaseId: String, @@ -221,11 +196,6 @@ class Databases(client: Client) : Service(client) { * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.Document] */ - @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `Tables.getRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Tables.getRow"), - since = "1.8.0" - ) @JvmOverloads @Throws(AppwriteException::class) suspend fun getDocument( @@ -247,17 +217,17 @@ class Databases(client: Client) : Service(client) { * @param databaseId Database ID. * @param collectionId Collection ID. * @param documentId Document ID. + * @param data Document data as JSON object. Include all required attributes of the document to be created or updated. + * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ - @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `Tables.upsertRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Tables.upsertRow"), - since = "1.8.0" - ) + @JvmOverloads suspend fun upsertDocument( databaseId: String, collectionId: String, documentId: String, + data: Any, + permissions: List? = null, nestedType: Class, ): io.appwrite.models.Document { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" @@ -266,6 +236,8 @@ class Databases(client: Client) : Service(client) { .replace("{documentId}", documentId) val apiParams = mutableMapOf( + "data" to data, + "permissions" to permissions, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -290,22 +262,24 @@ class Databases(client: Client) : Service(client) { * @param databaseId Database ID. * @param collectionId Collection ID. * @param documentId Document ID. + * @param data Document data as JSON object. Include all required attributes of the document to be created or updated. + * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ - @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `Tables.upsertRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Tables.upsertRow"), - since = "1.8.0" - ) + @JvmOverloads @Throws(AppwriteException::class) suspend fun upsertDocument( databaseId: String, collectionId: String, documentId: String, + data: Any, + permissions: List? = null, ): io.appwrite.models.Document> = upsertDocument( databaseId, collectionId, documentId, + data, + permissions, nestedType = classOf(), ) @@ -319,11 +293,6 @@ class Databases(client: Client) : Service(client) { * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ - @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `Tables.updateRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Tables.updateRow"), - since = "1.8.0" - ) @JvmOverloads suspend fun updateDocument( databaseId: String, @@ -369,11 +338,6 @@ class Databases(client: Client) : Service(client) { * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ - @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `Tables.updateRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Tables.updateRow"), - since = "1.8.0" - ) @JvmOverloads @Throws(AppwriteException::class) suspend fun updateDocument( @@ -399,11 +363,6 @@ class Databases(client: Client) : Service(client) { * @param documentId Document ID. * @return [Any] */ - @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `Tables.deleteRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Tables.deleteRow"), - since = "1.8.0" - ) suspend fun deleteDocument( databaseId: String, collectionId: String, @@ -429,4 +388,160 @@ class Databases(client: Client) : Service(client) { } + /** + * Decrement a specific attribute of a document by a given value. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. + * @param documentId Document ID. + * @param attribute Attribute key. + * @param value Value to decrement the attribute by. The value must be a number. + * @param min Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @return [io.appwrite.models.Document] + */ + @JvmOverloads + suspend fun decrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = null, + min: Double? = null, + nestedType: Class, + ): io.appwrite.models.Document { + val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + .replace("{documentId}", documentId) + .replace("{attribute}", attribute) + + val apiParams = mutableMapOf( + "value" to value, + "min" to min, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Document = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Document.from(map = it as Map, nestedType) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Decrement a specific attribute of a document by a given value. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. + * @param documentId Document ID. + * @param attribute Attribute key. + * @param value Value to decrement the attribute by. The value must be a number. + * @param min Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @return [io.appwrite.models.Document] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun decrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = null, + min: Double? = null, + ): io.appwrite.models.Document> = decrementDocumentAttribute( + databaseId, + collectionId, + documentId, + attribute, + value, + min, + nestedType = classOf(), + ) + + /** + * Increment a specific attribute of a document by a given value. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. + * @param documentId Document ID. + * @param attribute Attribute key. + * @param value Value to increment the attribute by. The value must be a number. + * @param max Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @return [io.appwrite.models.Document] + */ + @JvmOverloads + suspend fun incrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = null, + max: Double? = null, + nestedType: Class, + ): io.appwrite.models.Document { + val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + .replace("{documentId}", documentId) + .replace("{attribute}", attribute) + + val apiParams = mutableMapOf( + "value" to value, + "max" to max, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Document = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Document.from(map = it as Map, nestedType) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Increment a specific attribute of a document by a given value. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. + * @param documentId Document ID. + * @param attribute Attribute key. + * @param value Value to increment the attribute by. The value must be a number. + * @param max Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @return [io.appwrite.models.Document] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun incrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = null, + max: Double? = null, + ): io.appwrite.models.Document> = incrementDocumentAttribute( + databaseId, + collectionId, + documentId, + attribute, + value, + max, + nestedType = classOf(), + ) + } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Tables.kt b/library/src/main/java/io/appwrite/services/Tables.kt deleted file mode 100644 index f1ff34d..0000000 --- a/library/src/main/java/io/appwrite/services/Tables.kt +++ /dev/null @@ -1,435 +0,0 @@ -package io.appwrite.services - -import android.net.Uri -import io.appwrite.Client -import io.appwrite.Service -import io.appwrite.models.* -import io.appwrite.enums.* -import io.appwrite.exceptions.AppwriteException -import io.appwrite.extensions.classOf -import okhttp3.Cookie -import java.io.File - -/** - * The Tables service allows you to create structured tables of rows, query and filter lists of rows -**/ -class Tables(client: Client) : Service(client) { - - /** - * Get a list of all the user's rows in a given table. You can use the query params to filter your results. - * - * @param databaseId Database ID. - * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @return [io.appwrite.models.RowList] - */ - @JvmOverloads - suspend fun listRows( - databaseId: String, - tableId: String, - queries: List? = null, - nestedType: Class, - ): io.appwrite.models.RowList { - val apiPath = "/databases/{databaseId}/tables/{tableId}/rows" - .replace("{databaseId}", databaseId) - .replace("{tableId}", tableId) - - val apiParams = mutableMapOf( - "queries" to queries, - ) - val apiHeaders = mutableMapOf( - ) - val converter: (Any) -> io.appwrite.models.RowList = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.RowList.from(map = it as Map, nestedType) - } - return client.call( - "GET", - apiPath, - apiHeaders, - apiParams, - responseType = classOf(), - converter, - ) - } - - /** - * Get a list of all the user's rows in a given table. You can use the query params to filter your results. - * - * @param databaseId Database ID. - * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @return [io.appwrite.models.RowList] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun listRows( - databaseId: String, - tableId: String, - queries: List? = null, - ): io.appwrite.models.RowList> = listRows( - databaseId, - tableId, - queries, - nestedType = classOf(), - ) - - /** - * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. - * - * @param databaseId Database ID. - * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). Make sure to define columns before creating rows. - * @param rowId Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 Row data as JSON object. - * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @return [io.appwrite.models.Row] - */ - @JvmOverloads - suspend fun createRow( - databaseId: String, - tableId: String, - rowId: String, - data: Any, - permissions: List? = null, - nestedType: Class, - ): io.appwrite.models.Row { - val apiPath = "/databases/{databaseId}/tables/{tableId}/rows" - .replace("{databaseId}", databaseId) - .replace("{tableId}", tableId) - - val apiParams = mutableMapOf( - "rowId" to rowId, - "data" to data, - "permissions" to permissions, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Row = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.Row.from(map = it as Map, nestedType) - } - return client.call( - "POST", - apiPath, - apiHeaders, - apiParams, - responseType = classOf(), - converter, - ) - } - - /** - * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. - * - * @param databaseId Database ID. - * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). Make sure to define columns before creating rows. - * @param rowId Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 Row data as JSON object. - * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @return [io.appwrite.models.Row] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun createRow( - databaseId: String, - tableId: String, - rowId: String, - data: Any, - permissions: List? = null, - ): io.appwrite.models.Row> = createRow( - databaseId, - tableId, - rowId, - data, - permissions, - nestedType = classOf(), - ) - - /** - * Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. - * - * @param databaseId Database ID. - * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). Make sure to define columns before creating rows. - * @param rows Array of documents data as JSON objects. - * @return [io.appwrite.models.RowList] - */ - suspend fun createRows( - databaseId: String, - tableId: String, - rows: List, - nestedType: Class, - ): io.appwrite.models.RowList { - val apiPath = "/databases/{databaseId}/tables/{tableId}/rows" - .replace("{databaseId}", databaseId) - .replace("{tableId}", tableId) - - val apiParams = mutableMapOf( - "rows" to rows, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.RowList = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.RowList.from(map = it as Map, nestedType) - } - return client.call( - "POST", - apiPath, - apiHeaders, - apiParams, - responseType = classOf(), - converter, - ) - } - - /** - * Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. - * - * @param databaseId Database ID. - * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). Make sure to define columns before creating rows. - * @param rows Array of documents data as JSON objects. - * @return [io.appwrite.models.RowList] - */ - @Throws(AppwriteException::class) - suspend fun createRows( - databaseId: String, - tableId: String, - rows: List, - ): io.appwrite.models.RowList> = createRows( - databaseId, - tableId, - rows, - nestedType = classOf(), - ) - - /** - * Get a row by its unique ID. This endpoint response returns a JSON object with the row data. - * - * @param databaseId Database ID. - * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). - * @param rowId Row ID. - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @return [io.appwrite.models.Row] - */ - @JvmOverloads - suspend fun getRow( - databaseId: String, - tableId: String, - rowId: String, - queries: List? = null, - nestedType: Class, - ): io.appwrite.models.Row { - val apiPath = "/databases/{databaseId}/tables/{tableId}/rows/{rowId}" - .replace("{databaseId}", databaseId) - .replace("{tableId}", tableId) - .replace("{rowId}", rowId) - - val apiParams = mutableMapOf( - "queries" to queries, - ) - val apiHeaders = mutableMapOf( - ) - val converter: (Any) -> io.appwrite.models.Row = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.Row.from(map = it as Map, nestedType) - } - return client.call( - "GET", - apiPath, - apiHeaders, - apiParams, - responseType = classOf(), - converter, - ) - } - - /** - * Get a row by its unique ID. This endpoint response returns a JSON object with the row data. - * - * @param databaseId Database ID. - * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). - * @param rowId Row ID. - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @return [io.appwrite.models.Row] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun getRow( - databaseId: String, - tableId: String, - rowId: String, - queries: List? = null, - ): io.appwrite.models.Row> = getRow( - databaseId, - tableId, - rowId, - queries, - nestedType = classOf(), - ) - - /** - * Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. - * - * @param databaseId Database ID. - * @param tableId Table ID. - * @param rowId Row ID. - * @return [io.appwrite.models.Row] - */ - suspend fun upsertRow( - databaseId: String, - tableId: String, - rowId: String, - nestedType: Class, - ): io.appwrite.models.Row { - val apiPath = "/databases/{databaseId}/tables/{tableId}/rows/{rowId}" - .replace("{databaseId}", databaseId) - .replace("{tableId}", tableId) - .replace("{rowId}", rowId) - - val apiParams = mutableMapOf( - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Row = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.Row.from(map = it as Map, nestedType) - } - return client.call( - "PUT", - apiPath, - apiHeaders, - apiParams, - responseType = classOf(), - converter, - ) - } - - /** - * Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. - * - * @param databaseId Database ID. - * @param tableId Table ID. - * @param rowId Row ID. - * @return [io.appwrite.models.Row] - */ - @Throws(AppwriteException::class) - suspend fun upsertRow( - databaseId: String, - tableId: String, - rowId: String, - ): io.appwrite.models.Row> = upsertRow( - databaseId, - tableId, - rowId, - nestedType = classOf(), - ) - - /** - * Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. - * - * @param databaseId Database ID. - * @param tableId Table ID. - * @param rowId Row ID. - * @param data Row data as JSON object. Include only columns and value pairs to be updated. - * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @return [io.appwrite.models.Row] - */ - @JvmOverloads - suspend fun updateRow( - databaseId: String, - tableId: String, - rowId: String, - data: Any? = null, - permissions: List? = null, - nestedType: Class, - ): io.appwrite.models.Row { - val apiPath = "/databases/{databaseId}/tables/{tableId}/rows/{rowId}" - .replace("{databaseId}", databaseId) - .replace("{tableId}", tableId) - .replace("{rowId}", rowId) - - val apiParams = mutableMapOf( - "data" to data, - "permissions" to permissions, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Row = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.Row.from(map = it as Map, nestedType) - } - return client.call( - "PATCH", - apiPath, - apiHeaders, - apiParams, - responseType = classOf(), - converter, - ) - } - - /** - * Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. - * - * @param databaseId Database ID. - * @param tableId Table ID. - * @param rowId Row ID. - * @param data Row data as JSON object. Include only columns and value pairs to be updated. - * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @return [io.appwrite.models.Row] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun updateRow( - databaseId: String, - tableId: String, - rowId: String, - data: Any? = null, - permissions: List? = null, - ): io.appwrite.models.Row> = updateRow( - databaseId, - tableId, - rowId, - data, - permissions, - nestedType = classOf(), - ) - - /** - * Delete a row by its unique ID. - * - * @param databaseId Database ID. - * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). - * @param rowId Row ID. - * @return [Any] - */ - suspend fun deleteRow( - databaseId: String, - tableId: String, - rowId: String, - ): Any { - val apiPath = "/databases/{databaseId}/tables/{tableId}/rows/{rowId}" - .replace("{databaseId}", databaseId) - .replace("{tableId}", tableId) - .replace("{rowId}", rowId) - - val apiParams = mutableMapOf( - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - return client.call( - "DELETE", - apiPath, - apiHeaders, - apiParams, - responseType = Any::class.java, - ) - } - - -} \ No newline at end of file From b36d2af7e125a6e858c7714cbc5bd5a65f727cb6 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 24 Jul 2025 06:39:21 +0000 Subject: [PATCH 106/118] chore: add changelog --- CHANGELOG.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8406e63..38d0c4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,23 @@ # Change Log +## 8.2.0 + +* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service +* Add `gif` support to `ImageFormat` enum +* Add `sequence` support to `Document` model + +## 8.1.0 + +* Add `devKeys` support to `Client` service +* Add `upsertDocument` support to `Databases` service + ## 8.0.0 * Add `token` param to `getFilePreview` and `getFileView` for File tokens usage * Update default `quality` for `getFilePreview` from 0 to -1 * Remove `Gif` from ImageFormat enum -* Remove `search` param from `listExecutions` method \ No newline at end of file +* Remove `search` param from `listExecutions` method + +## 7.0.1 + +* Fix requests failing by removing `Content-Type` header from `GET` and `HEAD` requests From 6761dcac106e906548f579b95701c97651157f3b Mon Sep 17 00:00:00 2001 From: root Date: Fri, 25 Jul 2025 11:45:58 +0000 Subject: [PATCH 107/118] update readme --- README.md | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 77 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 745f21c..c15bc26 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ In order to capture the Appwrite OAuth callback url, the following activity need - + @@ -91,8 +91,8 @@ import io.appwrite.Client import io.appwrite.services.Account val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setEndpoint("https:///v1") // Your API Endpoint + .setProject("") // Your project ID .setSelfSigned(true) // Remove in production ``` @@ -123,8 +123,8 @@ import io.appwrite.services.Account import io.appwrite.ID val client = Client(context) - .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint - .setProject("5df5acd0d48c2") // Your project ID + .setEndpoint("https:///v1") // Your API Endpoint + .setProject("") // Your project ID .setSelfSigned(true) // Remove in production val account = Account(client) @@ -136,7 +136,79 @@ val user = account.create( ) ``` +### Type Safety with Models + +The Appwrite Android SDK provides type safety when working with database documents through generic methods. Methods like `listDocuments`, `getDocument`, and others accept a `nestedType` parameter that allows you to specify your custom model type for full type safety. + +```kotlin +data class Book( + val name: String, + val author: String, + val releaseYear: String? = null, + val category: String? = null, + val genre: List? = null, + val isCheckedOut: Boolean +) + +val databases = Databases(client) + +try { + val documents = databases.listDocuments( + databaseId = "your-database-id", + collectionId = "your-collection-id", + nestedType = Book::class.java // Pass in your custom model type + ) + + for (book in documents.documents) { + Log.d("Appwrite", "Book: ${book.name} by ${book.author}") // Now you have full type safety + } +} catch (e: AppwriteException) { + Log.e("Appwrite", e.message ?: "Unknown error") +} +``` + +**Tip**: You can use the `appwrite types` command to automatically generate model definitions based on your Appwrite database schema. Learn more about [type generation](https://appwrite.io/docs/products/databases/type-generation). + +### Working with Model Methods + +All Appwrite models come with built-in methods for data conversion and manipulation: + +**`toMap()`** - Converts a model instance to a Map format, useful for debugging or manual data manipulation: +```kotlin +val account = Account(client) +val user = account.get() +val userMap = user.toMap() +Log.d("Appwrite", userMap.toString()) // Prints all user properties as a Map +``` + +**`from(map:, nestedType:)`** - Creates a model instance from a Map, useful when working with raw data: +```kotlin +val userData: Map = mapOf( + "\$id" to "123", + "name" to "John", + "email" to "john@example.com" +) +val user = User.from(userData, User::class.java) +``` + +**JSON Serialization** - Models can be easily converted to/from JSON using Gson (which the SDK uses internally): +```kotlin +import com.google.gson.Gson + +val account = Account(client) +val user = account.get() + +// Convert to JSON +val gson = Gson() +val jsonString = gson.toJson(user) +Log.d("Appwrite", "User JSON: $jsonString") + +// Convert from JSON +val userFromJson = gson.fromJson(jsonString, User::class.java) +``` + ### Error Handling + The Appwrite Android SDK raises an `AppwriteException` object with `message`, `code` and `response` properties. You can handle any errors by catching `AppwriteException` and present the `message` to the user or handle it yourself based on the provided error information. Below is an example. ```kotlin From bfe1e1730b9bbd2c91bdeb6140528d9412c0bb13 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 6 Aug 2025 07:46:00 +0000 Subject: [PATCH 108/118] update maven deployment --- README.md | 59 ++++++++++++++++++- .../java/functions/create-execution.md | 2 +- .../kotlin/functions/create-execution.md | 2 +- library/src/main/java/io/appwrite/Client.kt | 2 +- 4 files changed, 60 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c15bc26..db65d39 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:8.2.0") +implementation("io.appwrite:sdk-for-android:8.2.2") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 8.2.0 + 8.2.2 ``` @@ -140,6 +140,7 @@ val user = account.create( The Appwrite Android SDK provides type safety when working with database documents through generic methods. Methods like `listDocuments`, `getDocument`, and others accept a `nestedType` parameter that allows you to specify your custom model type for full type safety. +**Kotlin:** ```kotlin data class Book( val name: String, @@ -167,6 +168,60 @@ try { } ``` +**Java:** +```java +public class Book { + private String name; + private String author; + private String releaseYear; + private String category; + private List genre; + private boolean isCheckedOut; + + // Constructor + public Book(String name, String author, boolean isCheckedOut) { + this.name = name; + this.author = author; + this.isCheckedOut = isCheckedOut; + } + + // Getters and setters + public String getName() { return name; } + public void setName(String name) { this.name = name; } + + public String getAuthor() { return author; } + public void setAuthor(String author) { this.author = author; } + + public String getReleaseYear() { return releaseYear; } + public void setReleaseYear(String releaseYear) { this.releaseYear = releaseYear; } + + public String getCategory() { return category; } + public void setCategory(String category) { this.category = category; } + + public List getGenre() { return genre; } + public void setGenre(List genre) { this.genre = genre; } + + public boolean isCheckedOut() { return isCheckedOut; } + public void setCheckedOut(boolean checkedOut) { isCheckedOut = checkedOut; } +} + +Databases databases = new Databases(client); + +try { + DocumentList documents = databases.listDocuments( + "your-database-id", + "your-collection-id", + Book.class // Pass in your custom model type + ); + + for (Book book : documents.getDocuments()) { + Log.d("Appwrite", "Book: " + book.getName() + " by " + book.getAuthor()); // Now you have full type safety + } +} catch (AppwriteException e) { + Log.e("Appwrite", e.getMessage() != null ? e.getMessage() : "Unknown error"); +} +``` + **Tip**: You can use the `appwrite types` command to automatically generate model definitions based on your Appwrite database schema. Learn more about [type generation](https://appwrite.io/docs/products/databases/type-generation). ### Working with Model Methods diff --git a/docs/examples/java/functions/create-execution.md b/docs/examples/java/functions/create-execution.md index c138b0e..06c5027 100644 --- a/docs/examples/java/functions/create-execution.md +++ b/docs/examples/java/functions/create-execution.md @@ -15,7 +15,7 @@ functions.createExecution( "", // path (optional) ExecutionMethod.GET, // method (optional) mapOf( "a" to "b" ), // headers (optional) - "", // scheduledAt (optional) + "", // scheduledAt (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/kotlin/functions/create-execution.md b/docs/examples/kotlin/functions/create-execution.md index cb7c60b..5e1950b 100644 --- a/docs/examples/kotlin/functions/create-execution.md +++ b/docs/examples/kotlin/functions/create-execution.md @@ -15,5 +15,5 @@ val result = functions.createExecution( path = "", // (optional) method = ExecutionMethod.GET, // (optional) headers = mapOf( "a" to "b" ), // (optional) - scheduledAt = "", // (optional) + scheduledAt = "", // (optional) ) \ 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 bf0480f..1dbeda8 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -87,7 +87,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "8.2.0", + "x-sdk-version" to "8.2.2", "x-appwrite-response-format" to "1.7.0" ) config = mutableMapOf() From 9e72610cfd498873dc4becb666ac36fb64dc11c0 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 6 Aug 2025 07:52:59 +0000 Subject: [PATCH 109/118] chore: update maven dependencies --- scripts/publish-config.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/publish-config.gradle b/scripts/publish-config.gradle index 299c6c4..5934f92 100644 --- a/scripts/publish-config.gradle +++ b/scripts/publish-config.gradle @@ -30,8 +30,8 @@ nexusPublishing { stagingProfileId = sonatypeStagingProfileId username = ossrhUsername password = ossrhPassword - nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) - snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) + nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/")) + snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/")) } } } \ No newline at end of file From 7b68746eae35c38d362c7107ff913abbaa369cdd Mon Sep 17 00:00:00 2001 From: root Date: Wed, 6 Aug 2025 08:09:33 +0000 Subject: [PATCH 110/118] chore: regenerate sdk --- README.md | 4 ++-- library/src/main/java/io/appwrite/Client.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index db65d39..234943c 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:8.2.2") +implementation("io.appwrite:sdk-for-android:8.2.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 8.2.2 + 8.2.0 ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 1dbeda8..bf0480f 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -87,7 +87,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "8.2.2", + "x-sdk-version" to "8.2.0", "x-appwrite-response-format" to "1.7.0" ) config = mutableMapOf() From 2f6378fda4b246cf0d15f63b22d651ab8a82dfec Mon Sep 17 00:00:00 2001 From: root Date: Wed, 6 Aug 2025 08:22:53 +0000 Subject: [PATCH 111/118] update version --- README.md | 4 ++-- library/src/main/java/io/appwrite/Client.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 234943c..db65d39 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:8.2.0") +implementation("io.appwrite:sdk-for-android:8.2.2") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 8.2.0 + 8.2.2 ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index bf0480f..1dbeda8 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -87,7 +87,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "8.2.0", + "x-sdk-version" to "8.2.2", "x-appwrite-response-format" to "1.7.0" ) config = mutableMapOf() From 30edd39ec096995f2b8424aba31d99d2477bbca1 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 20 Aug 2025 03:09:50 +1200 Subject: [PATCH 112/118] Add 1.8.x support --- README.md | 8 +- .../create-row.md} | 15 +- .../delete-row.md} | 13 +- docs/examples/java/tablesdb/get-row.md | 25 ++ docs/examples/java/tablesdb/list-rows.md | 24 ++ docs/examples/java/tablesdb/update-row.md | 26 ++ docs/examples/java/tablesdb/upsert-row.md | 26 ++ .../create-row.md} | 15 +- .../delete-row.md} | 13 +- docs/examples/kotlin/tablesdb/get-row.md | 16 + docs/examples/kotlin/tablesdb/list-rows.md | 15 + docs/examples/kotlin/tablesdb/update-row.md | 17 + docs/examples/kotlin/tablesdb/upsert-row.md | 17 + library/src/main/java/io/appwrite/Client.kt | 4 +- library/src/main/java/io/appwrite/Query.kt | 78 ++++ .../java/io/appwrite/models/ContinentList.kt | 2 +- .../java/io/appwrite/models/CountryList.kt | 2 +- .../java/io/appwrite/models/CurrencyList.kt | 2 +- .../java/io/appwrite/models/DocumentList.kt | 2 +- .../java/io/appwrite/models/ExecutionList.kt | 2 +- .../main/java/io/appwrite/models/FileList.kt | 2 +- .../java/io/appwrite/models/IdentityList.kt | 2 +- .../java/io/appwrite/models/LanguageList.kt | 2 +- .../java/io/appwrite/models/LocaleCodeList.kt | 2 +- .../main/java/io/appwrite/models/LogList.kt | 2 +- .../java/io/appwrite/models/MembershipList.kt | 2 +- .../main/java/io/appwrite/models/PhoneList.kt | 2 +- .../src/main/java/io/appwrite/models/Row.kt | 105 +++++ .../main/java/io/appwrite/models/RowList.kt | 46 +++ .../java/io/appwrite/models/SessionList.kt | 2 +- .../main/java/io/appwrite/models/TeamList.kt | 2 +- .../main/java/io/appwrite/services/Account.kt | 6 + .../java/io/appwrite/services/Databases.kt | 215 +++------- .../java/io/appwrite/services/TablesDb.kt | 391 ++++++++++++++++++ 34 files changed, 893 insertions(+), 210 deletions(-) rename docs/examples/java/{databases/decrement-document-attribute.md => tablesdb/create-row.md} (64%) rename docs/examples/java/{databases/increment-document-attribute.md => tablesdb/delete-row.md} (64%) create mode 100644 docs/examples/java/tablesdb/get-row.md create mode 100644 docs/examples/java/tablesdb/list-rows.md create mode 100644 docs/examples/java/tablesdb/update-row.md create mode 100644 docs/examples/java/tablesdb/upsert-row.md rename docs/examples/kotlin/{databases/decrement-document-attribute.md => tablesdb/create-row.md} (50%) rename docs/examples/kotlin/{databases/increment-document-attribute.md => tablesdb/delete-row.md} (50%) create mode 100644 docs/examples/kotlin/tablesdb/get-row.md create mode 100644 docs/examples/kotlin/tablesdb/list-rows.md create mode 100644 docs/examples/kotlin/tablesdb/update-row.md create mode 100644 docs/examples/kotlin/tablesdb/upsert-row.md create mode 100644 library/src/main/java/io/appwrite/models/Row.kt create mode 100644 library/src/main/java/io/appwrite/models/RowList.kt create mode 100644 library/src/main/java/io/appwrite/services/TablesDb.kt diff --git a/README.md b/README.md index db65d39..a0c4c6d 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.7.4-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.8.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.7.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.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).** Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Android SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:8.2.2") +implementation("io.appwrite:sdk-for-android:9.0.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 8.2.2 + 9.0.0 ``` diff --git a/docs/examples/java/databases/decrement-document-attribute.md b/docs/examples/java/tablesdb/create-row.md similarity index 64% rename from docs/examples/java/databases/decrement-document-attribute.md rename to docs/examples/java/tablesdb/create-row.md index de6a4ab..4c7d10d 100644 --- a/docs/examples/java/databases/decrement-document-attribute.md +++ b/docs/examples/java/tablesdb/create-row.md @@ -1,20 +1,19 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Databases; +import io.appwrite.services.TablesDb; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID -Databases databases = new Databases(client); +TablesDb tablesDb = new TablesDb(client); -databases.decrementDocumentAttribute( +tablesDb.createRow( "", // databaseId - "", // collectionId - "", // documentId - "", // attribute - 0, // value (optional) - 0, // min (optional) + "", // tableId + "", // rowId + mapOf( "a" to "b" ), // data + listOf("read("any")"), // permissions (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/increment-document-attribute.md b/docs/examples/java/tablesdb/delete-row.md similarity index 64% rename from docs/examples/java/databases/increment-document-attribute.md rename to docs/examples/java/tablesdb/delete-row.md index 94ffa9d..776f6bd 100644 --- a/docs/examples/java/databases/increment-document-attribute.md +++ b/docs/examples/java/tablesdb/delete-row.md @@ -1,20 +1,17 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Databases; +import io.appwrite.services.TablesDb; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID -Databases databases = new Databases(client); +TablesDb tablesDb = new TablesDb(client); -databases.incrementDocumentAttribute( +tablesDb.deleteRow( "", // databaseId - "", // collectionId - "", // documentId - "", // attribute - 0, // value (optional) - 0, // max (optional) + "", // tableId + "", // rowId new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tablesdb/get-row.md b/docs/examples/java/tablesdb/get-row.md new file mode 100644 index 0000000..a0e20a3 --- /dev/null +++ b/docs/examples/java/tablesdb/get-row.md @@ -0,0 +1,25 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.TablesDb; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +TablesDb tablesDb = new TablesDb(client); + +tablesDb.getRow( + "", // databaseId + "", // tableId + "", // rowId + listOf(), // queries (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/tablesdb/list-rows.md b/docs/examples/java/tablesdb/list-rows.md new file mode 100644 index 0000000..9bd6f6d --- /dev/null +++ b/docs/examples/java/tablesdb/list-rows.md @@ -0,0 +1,24 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.TablesDb; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +TablesDb tablesDb = new TablesDb(client); + +tablesDb.listRows( + "", // databaseId + "", // tableId + listOf(), // queries (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/tablesdb/update-row.md b/docs/examples/java/tablesdb/update-row.md new file mode 100644 index 0000000..fdcd8ac --- /dev/null +++ b/docs/examples/java/tablesdb/update-row.md @@ -0,0 +1,26 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.TablesDb; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +TablesDb tablesDb = new TablesDb(client); + +tablesDb.updateRow( + "", // databaseId + "", // tableId + "", // rowId + mapOf( "a" to "b" ), // data (optional) + listOf("read("any")"), // permissions (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/tablesdb/upsert-row.md b/docs/examples/java/tablesdb/upsert-row.md new file mode 100644 index 0000000..6c60b9c --- /dev/null +++ b/docs/examples/java/tablesdb/upsert-row.md @@ -0,0 +1,26 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.TablesDb; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +TablesDb tablesDb = new TablesDb(client); + +tablesDb.upsertRow( + "", // databaseId + "", // tableId + "", // rowId + mapOf( "a" to "b" ), // data (optional) + listOf("read("any")"), // permissions (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/kotlin/databases/decrement-document-attribute.md b/docs/examples/kotlin/tablesdb/create-row.md similarity index 50% rename from docs/examples/kotlin/databases/decrement-document-attribute.md rename to docs/examples/kotlin/tablesdb/create-row.md index c500fa8..1e84ebd 100644 --- a/docs/examples/kotlin/databases/decrement-document-attribute.md +++ b/docs/examples/kotlin/tablesdb/create-row.md @@ -1,18 +1,17 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Databases +import io.appwrite.services.TablesDb val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -val databases = Databases(client) +val tablesDb = TablesDb(client) -val result = databases.decrementDocumentAttribute( +val result = tablesDb.createRow( databaseId = "", - collectionId = "", - documentId = "", - attribute = "", - value = 0, // (optional) - min = 0, // (optional) + tableId = "", + rowId = "", + data = mapOf( "a" to "b" ), + permissions = listOf("read("any")"), // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/increment-document-attribute.md b/docs/examples/kotlin/tablesdb/delete-row.md similarity index 50% rename from docs/examples/kotlin/databases/increment-document-attribute.md rename to docs/examples/kotlin/tablesdb/delete-row.md index 0ae6b02..af6f5f5 100644 --- a/docs/examples/kotlin/databases/increment-document-attribute.md +++ b/docs/examples/kotlin/tablesdb/delete-row.md @@ -1,18 +1,15 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Databases +import io.appwrite.services.TablesDb val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -val databases = Databases(client) +val tablesDb = TablesDb(client) -val result = databases.incrementDocumentAttribute( +val result = tablesDb.deleteRow( databaseId = "", - collectionId = "", - documentId = "", - attribute = "", - value = 0, // (optional) - max = 0, // (optional) + tableId = "", + rowId = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/tablesdb/get-row.md b/docs/examples/kotlin/tablesdb/get-row.md new file mode 100644 index 0000000..3408f1d --- /dev/null +++ b/docs/examples/kotlin/tablesdb/get-row.md @@ -0,0 +1,16 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.TablesDb + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val tablesDb = TablesDb(client) + +val result = tablesDb.getRow( + databaseId = "", + tableId = "", + rowId = "", + queries = listOf(), // (optional) +) \ No newline at end of file diff --git a/docs/examples/kotlin/tablesdb/list-rows.md b/docs/examples/kotlin/tablesdb/list-rows.md new file mode 100644 index 0000000..b5bc755 --- /dev/null +++ b/docs/examples/kotlin/tablesdb/list-rows.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.TablesDb + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val tablesDb = TablesDb(client) + +val result = tablesDb.listRows( + databaseId = "", + tableId = "", + queries = listOf(), // (optional) +) \ No newline at end of file diff --git a/docs/examples/kotlin/tablesdb/update-row.md b/docs/examples/kotlin/tablesdb/update-row.md new file mode 100644 index 0000000..cc83763 --- /dev/null +++ b/docs/examples/kotlin/tablesdb/update-row.md @@ -0,0 +1,17 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.TablesDb + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val tablesDb = TablesDb(client) + +val result = tablesDb.updateRow( + databaseId = "", + tableId = "", + rowId = "", + data = mapOf( "a" to "b" ), // (optional) + permissions = listOf("read("any")"), // (optional) +) \ No newline at end of file diff --git a/docs/examples/kotlin/tablesdb/upsert-row.md b/docs/examples/kotlin/tablesdb/upsert-row.md new file mode 100644 index 0000000..f9f165e --- /dev/null +++ b/docs/examples/kotlin/tablesdb/upsert-row.md @@ -0,0 +1,17 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.TablesDb + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val tablesDb = TablesDb(client) + +val result = tablesDb.upsertRow( + databaseId = "", + tableId = "", + rowId = "", + data = mapOf( "a" to "b" ), // (optional) + permissions = listOf("read("any")"), // (optional) +) \ 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 1dbeda8..10f9255 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -87,8 +87,8 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "8.2.2", - "x-appwrite-response-format" to "1.7.0" + "x-sdk-version" to "9.0.0", + "x-appwrite-response-format" to "1.8.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/Query.kt b/library/src/main/java/io/appwrite/Query.kt index e326335..39798f3 100644 --- a/library/src/main/java/io/appwrite/Query.kt +++ b/library/src/main/java/io/appwrite/Query.kt @@ -192,6 +192,84 @@ class Query( */ fun contains(attribute: String, value: Any) = Query("contains", attribute, parseValue(value)).toJson() + /** + * Filter resources where attribute does not contain the specified value. + * + * @param attribute The attribute to filter on. + * @param value The value to compare against. + * @returns The query string. + */ + fun notContains(attribute: String, value: Any) = Query("notContains", attribute, parseValue(value)).toJson() + + /** + * Filter resources by searching attribute for value (inverse of search). + * + * @param attribute The attribute to filter on. + * @param value The search value to match against. + * @returns The query string. + */ + fun notSearch(attribute: String, value: String) = Query("notSearch", attribute, listOf(value)).toJson() + + /** + * Filter resources where attribute is not between start and end (exclusive). + * + * @param attribute The attribute to filter on. + * @param start The start value of the range. + * @param end The end value of the range. + * @returns The query string. + */ + fun notBetween(attribute: String, start: Any, end: Any) = Query("notBetween", attribute, listOf(start, end)).toJson() + + /** + * Filter resources where attribute does not start with value. + * + * @param attribute The attribute to filter on. + * @param value The value to compare against. + * @returns The query string. + */ + fun notStartsWith(attribute: String, value: String) = Query("notStartsWith", attribute, listOf(value)).toJson() + + /** + * Filter resources where attribute does not end with value. + * + * @param attribute The attribute to filter on. + * @param value The value to compare against. + * @returns The query string. + */ + fun notEndsWith(attribute: String, value: String) = Query("notEndsWith", attribute, listOf(value)).toJson() + + /** + * Filter resources where document was created before date. + * + * @param value The date value to compare against. + * @returns The query string. + */ + fun createdBefore(value: String) = Query("createdBefore", null, listOf(value)).toJson() + + /** + * Filter resources where document was created after date. + * + * @param value The date value to compare against. + * @returns The query string. + */ + fun createdAfter(value: String) = Query("createdAfter", null, listOf(value)).toJson() + + /** + * Filter resources where document was updated before date. + * + * @param value The date value to compare against. + * @returns The query string. + */ + fun updatedBefore(value: String) = Query("updatedBefore", null, listOf(value)).toJson() + + /** + * Filter resources where document was updated after date. + * + * @param value The date value to compare against. + * @returns The query string. + */ + fun updatedAfter(value: String) = Query("updatedAfter", null, listOf(value)).toJson() + /** * Combine multiple queries using logical OR operator. * diff --git a/library/src/main/java/io/appwrite/models/ContinentList.kt b/library/src/main/java/io/appwrite/models/ContinentList.kt index fdd490a..a6ec310 100644 --- a/library/src/main/java/io/appwrite/models/ContinentList.kt +++ b/library/src/main/java/io/appwrite/models/ContinentList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class ContinentList( /** - * Total number of continents documents that matched your query. + * Total number of continents rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/CountryList.kt b/library/src/main/java/io/appwrite/models/CountryList.kt index 350a894..546cf73 100644 --- a/library/src/main/java/io/appwrite/models/CountryList.kt +++ b/library/src/main/java/io/appwrite/models/CountryList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class CountryList( /** - * Total number of countries documents that matched your query. + * Total number of countries rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/CurrencyList.kt b/library/src/main/java/io/appwrite/models/CurrencyList.kt index fe1e001..95dec92 100644 --- a/library/src/main/java/io/appwrite/models/CurrencyList.kt +++ b/library/src/main/java/io/appwrite/models/CurrencyList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class CurrencyList( /** - * Total number of currencies documents that matched your query. + * Total number of currencies rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/DocumentList.kt b/library/src/main/java/io/appwrite/models/DocumentList.kt index fa3dd20..6f40579 100644 --- a/library/src/main/java/io/appwrite/models/DocumentList.kt +++ b/library/src/main/java/io/appwrite/models/DocumentList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class DocumentList( /** - * Total number of documents documents that matched your query. + * Total number of documents rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/ExecutionList.kt b/library/src/main/java/io/appwrite/models/ExecutionList.kt index 322aeee..ac11e4f 100644 --- a/library/src/main/java/io/appwrite/models/ExecutionList.kt +++ b/library/src/main/java/io/appwrite/models/ExecutionList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class ExecutionList( /** - * Total number of executions documents that matched your query. + * Total number of executions rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/FileList.kt b/library/src/main/java/io/appwrite/models/FileList.kt index 5af18f1..ba69ea8 100644 --- a/library/src/main/java/io/appwrite/models/FileList.kt +++ b/library/src/main/java/io/appwrite/models/FileList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class FileList( /** - * Total number of files documents that matched your query. + * Total number of files rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/IdentityList.kt b/library/src/main/java/io/appwrite/models/IdentityList.kt index 1cbb07d..2e1a33a 100644 --- a/library/src/main/java/io/appwrite/models/IdentityList.kt +++ b/library/src/main/java/io/appwrite/models/IdentityList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class IdentityList( /** - * Total number of identities documents that matched your query. + * Total number of identities rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/LanguageList.kt b/library/src/main/java/io/appwrite/models/LanguageList.kt index 07559b9..ab78452 100644 --- a/library/src/main/java/io/appwrite/models/LanguageList.kt +++ b/library/src/main/java/io/appwrite/models/LanguageList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class LanguageList( /** - * Total number of languages documents that matched your query. + * Total number of languages rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/LocaleCodeList.kt b/library/src/main/java/io/appwrite/models/LocaleCodeList.kt index 3973a03..6f47333 100644 --- a/library/src/main/java/io/appwrite/models/LocaleCodeList.kt +++ b/library/src/main/java/io/appwrite/models/LocaleCodeList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class LocaleCodeList( /** - * Total number of localeCodes documents that matched your query. + * Total number of localeCodes rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/LogList.kt b/library/src/main/java/io/appwrite/models/LogList.kt index b9f381c..d2e0b00 100644 --- a/library/src/main/java/io/appwrite/models/LogList.kt +++ b/library/src/main/java/io/appwrite/models/LogList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class LogList( /** - * Total number of logs documents that matched your query. + * Total number of logs rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/MembershipList.kt b/library/src/main/java/io/appwrite/models/MembershipList.kt index 7feaaaa..efcffc4 100644 --- a/library/src/main/java/io/appwrite/models/MembershipList.kt +++ b/library/src/main/java/io/appwrite/models/MembershipList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class MembershipList( /** - * Total number of memberships documents that matched your query. + * Total number of memberships rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/PhoneList.kt b/library/src/main/java/io/appwrite/models/PhoneList.kt index b17de4f..675295f 100644 --- a/library/src/main/java/io/appwrite/models/PhoneList.kt +++ b/library/src/main/java/io/appwrite/models/PhoneList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class PhoneList( /** - * Total number of phones documents that matched your query. + * Total number of phones rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/Row.kt b/library/src/main/java/io/appwrite/models/Row.kt new file mode 100644 index 0000000..bb5c14f --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Row.kt @@ -0,0 +1,105 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Row + */ +data class Row( + /** + * Row ID. + */ + @SerializedName("\$id") + val id: String, + + /** + * Row automatically incrementing ID. + */ + @SerializedName("\$sequence") + val sequence: Long, + + /** + * Table ID. + */ + @SerializedName("\$tableId") + val tableId: String, + + /** + * Database ID. + */ + @SerializedName("\$databaseId") + val databaseId: String, + + /** + * Row creation date in ISO 8601 format. + */ + @SerializedName("\$createdAt") + val createdAt: String, + + /** + * Row update date in ISO 8601 format. + */ + @SerializedName("\$updatedAt") + val updatedAt: String, + + /** + * Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + @SerializedName("\$permissions") + val permissions: List, + + /** + * Additional properties + */ + @SerializedName("data") + val data: T +) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$sequence" to sequence as Any, + "\$tableId" to tableId as Any, + "\$databaseId" to databaseId as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "\$permissions" to permissions as Any, + "data" to data!!.jsonCast(to = Map::class.java) + ) + + companion object { + operator fun invoke( + id: String, + sequence: Long, + tableId: String, + databaseId: String, + createdAt: String, + updatedAt: String, + permissions: List, + data: Map + ) = Row>( + id, + sequence, + tableId, + databaseId, + createdAt, + updatedAt, + permissions, + data + ) + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + nestedType: Class + ) = Row( + id = map["\$id"] as String, + sequence = (map["\$sequence"] as Number).toLong(), + tableId = map["\$tableId"] 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/RowList.kt b/library/src/main/java/io/appwrite/models/RowList.kt new file mode 100644 index 0000000..289f39b --- /dev/null +++ b/library/src/main/java/io/appwrite/models/RowList.kt @@ -0,0 +1,46 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Rows List + */ +data class RowList( + /** + * Total number of rows rows that matched your query. + */ + @SerializedName("total") + val total: Long, + + /** + * List of rows. + */ + @SerializedName("rows") + val rows: List>, + +) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "rows" to rows.map { it.toMap() } as Any, + ) + + companion object { + operator fun invoke( + total: Long, + rows: List>>, + ) = RowList>( + total, + rows, + ) + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + nestedType: Class + ) = RowList( + total = (map["total"] as Number).toLong(), + rows = (map["rows"] as List>).map { Row.from(map = it, nestedType) }, + ) + } +} \ 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 c7080e6..13e0c36 100644 --- a/library/src/main/java/io/appwrite/models/SessionList.kt +++ b/library/src/main/java/io/appwrite/models/SessionList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class SessionList( /** - * Total number of sessions documents that matched your query. + * Total number of sessions rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/TeamList.kt b/library/src/main/java/io/appwrite/models/TeamList.kt index 17ccd6b..f1a1968 100644 --- a/library/src/main/java/io/appwrite/models/TeamList.kt +++ b/library/src/main/java/io/appwrite/models/TeamList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class TeamList( /** - * Total number of teams documents that matched your query. + * Total number of teams rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index f50f074..bebf4db 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -1067,6 +1067,9 @@ class Account(client: Client) : Service(client) { * @param secret Valid verification token. * @return [io.appwrite.models.Session] */ + @Deprecated( + message = "This API has been deprecated." + ) suspend fun updateMagicURLSession( userId: String, secret: String, @@ -1174,6 +1177,9 @@ class Account(client: Client) : Service(client) { * @param secret Valid verification token. * @return [io.appwrite.models.Session] */ + @Deprecated( + message = "This API has been deprecated." + ) suspend fun updatePhoneSession( userId: String, secret: String, diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index edc10f5..b9a6241 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -23,6 +23,11 @@ class Databases(client: Client) : Service(client) { * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.DocumentList] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `TablesDb.listRows` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDb.listRows"), + since = "1.8.0" + ) @JvmOverloads suspend fun listDocuments( databaseId: String, @@ -61,6 +66,11 @@ class Databases(client: Client) : Service(client) { * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.DocumentList] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `TablesDb.listRows` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDb.listRows"), + since = "1.8.0" + ) @JvmOverloads @Throws(AppwriteException::class) suspend fun listDocuments( @@ -84,6 +94,11 @@ class Databases(client: Client) : Service(client) { * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `TablesDb.createRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDb.createRow"), + since = "1.8.0" + ) @JvmOverloads suspend fun createDocument( databaseId: String, @@ -129,6 +144,11 @@ class Databases(client: Client) : Service(client) { * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `TablesDb.createRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDb.createRow"), + since = "1.8.0" + ) @JvmOverloads @Throws(AppwriteException::class) suspend fun createDocument( @@ -155,6 +175,11 @@ class Databases(client: Client) : Service(client) { * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.Document] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `TablesDb.getRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDb.getRow"), + since = "1.8.0" + ) @JvmOverloads suspend fun getDocument( databaseId: String, @@ -196,6 +221,11 @@ class Databases(client: Client) : Service(client) { * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.Document] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `TablesDb.getRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDb.getRow"), + since = "1.8.0" + ) @JvmOverloads @Throws(AppwriteException::class) suspend fun getDocument( @@ -212,7 +242,7 @@ class Databases(client: Client) : Service(client) { ) /** - * **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. * * @param databaseId Database ID. * @param collectionId Collection ID. @@ -221,6 +251,11 @@ class Databases(client: Client) : Service(client) { * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `TablesDb.upsertRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDb.upsertRow"), + since = "1.8.0" + ) @JvmOverloads suspend fun upsertDocument( databaseId: String, @@ -257,7 +292,7 @@ class Databases(client: Client) : Service(client) { } /** - * **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. * * @param databaseId Database ID. * @param collectionId Collection ID. @@ -266,6 +301,11 @@ class Databases(client: Client) : Service(client) { * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `TablesDb.upsertRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDb.upsertRow"), + since = "1.8.0" + ) @JvmOverloads @Throws(AppwriteException::class) suspend fun upsertDocument( @@ -293,6 +333,11 @@ class Databases(client: Client) : Service(client) { * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `TablesDb.updateRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDb.updateRow"), + since = "1.8.0" + ) @JvmOverloads suspend fun updateDocument( databaseId: String, @@ -338,6 +383,11 @@ class Databases(client: Client) : Service(client) { * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). * @return [io.appwrite.models.Document] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `TablesDb.updateRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDb.updateRow"), + since = "1.8.0" + ) @JvmOverloads @Throws(AppwriteException::class) suspend fun updateDocument( @@ -363,6 +413,11 @@ class Databases(client: Client) : Service(client) { * @param documentId Document ID. * @return [Any] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `TablesDb.deleteRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDb.deleteRow"), + since = "1.8.0" + ) suspend fun deleteDocument( databaseId: String, collectionId: String, @@ -388,160 +443,4 @@ class Databases(client: Client) : Service(client) { } - /** - * Decrement a specific attribute of a document by a given value. - * - * @param databaseId Database ID. - * @param collectionId Collection ID. - * @param documentId Document ID. - * @param attribute Attribute key. - * @param value Value to decrement the attribute by. The value must be a number. - * @param min Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. - * @return [io.appwrite.models.Document] - */ - @JvmOverloads - suspend fun decrementDocumentAttribute( - databaseId: String, - collectionId: String, - documentId: String, - attribute: String, - value: Double? = null, - min: Double? = null, - nestedType: Class, - ): io.appwrite.models.Document { - val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement" - .replace("{databaseId}", databaseId) - .replace("{collectionId}", collectionId) - .replace("{documentId}", documentId) - .replace("{attribute}", attribute) - - val apiParams = mutableMapOf( - "value" to value, - "min" to min, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Document = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.Document.from(map = it as Map, nestedType) - } - return client.call( - "PATCH", - apiPath, - apiHeaders, - apiParams, - responseType = classOf(), - converter, - ) - } - - /** - * Decrement a specific attribute of a document by a given value. - * - * @param databaseId Database ID. - * @param collectionId Collection ID. - * @param documentId Document ID. - * @param attribute Attribute key. - * @param value Value to decrement the attribute by. The value must be a number. - * @param min Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. - * @return [io.appwrite.models.Document] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun decrementDocumentAttribute( - databaseId: String, - collectionId: String, - documentId: String, - attribute: String, - value: Double? = null, - min: Double? = null, - ): io.appwrite.models.Document> = decrementDocumentAttribute( - databaseId, - collectionId, - documentId, - attribute, - value, - min, - nestedType = classOf(), - ) - - /** - * Increment a specific attribute of a document by a given value. - * - * @param databaseId Database ID. - * @param collectionId Collection ID. - * @param documentId Document ID. - * @param attribute Attribute key. - * @param value Value to increment the attribute by. The value must be a number. - * @param max Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. - * @return [io.appwrite.models.Document] - */ - @JvmOverloads - suspend fun incrementDocumentAttribute( - databaseId: String, - collectionId: String, - documentId: String, - attribute: String, - value: Double? = null, - max: Double? = null, - nestedType: Class, - ): io.appwrite.models.Document { - val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment" - .replace("{databaseId}", databaseId) - .replace("{collectionId}", collectionId) - .replace("{documentId}", documentId) - .replace("{attribute}", attribute) - - val apiParams = mutableMapOf( - "value" to value, - "max" to max, - ) - val apiHeaders = mutableMapOf( - "content-type" to "application/json", - ) - val converter: (Any) -> io.appwrite.models.Document = { - @Suppress("UNCHECKED_CAST") - io.appwrite.models.Document.from(map = it as Map, nestedType) - } - return client.call( - "PATCH", - apiPath, - apiHeaders, - apiParams, - responseType = classOf(), - converter, - ) - } - - /** - * Increment a specific attribute of a document by a given value. - * - * @param databaseId Database ID. - * @param collectionId Collection ID. - * @param documentId Document ID. - * @param attribute Attribute key. - * @param value Value to increment the attribute by. The value must be a number. - * @param max Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. - * @return [io.appwrite.models.Document] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun incrementDocumentAttribute( - databaseId: String, - collectionId: String, - documentId: String, - attribute: String, - value: Double? = null, - max: Double? = null, - ): io.appwrite.models.Document> = incrementDocumentAttribute( - databaseId, - collectionId, - documentId, - attribute, - value, - max, - nestedType = classOf(), - ) - } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/TablesDb.kt b/library/src/main/java/io/appwrite/services/TablesDb.kt new file mode 100644 index 0000000..d7b25fa --- /dev/null +++ b/library/src/main/java/io/appwrite/services/TablesDb.kt @@ -0,0 +1,391 @@ +package io.appwrite.services + +import android.net.Uri +import io.appwrite.Client +import io.appwrite.Service +import io.appwrite.models.* +import io.appwrite.enums.* +import io.appwrite.exceptions.AppwriteException +import io.appwrite.extensions.classOf +import okhttp3.Cookie +import java.io.File + +/** + * +**/ +class TablesDb(client: Client) : Service(client) { + + /** + * Get a list of all the user's rows in a given table. You can use the query params to filter your results. + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @return [io.appwrite.models.RowList] + */ + @JvmOverloads + suspend fun listRows( + databaseId: String, + tableId: String, + queries: List? = null, + nestedType: Class, + ): io.appwrite.models.RowList { + val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows" + .replace("{databaseId}", databaseId) + .replace("{tableId}", tableId) + + val apiParams = mutableMapOf( + "queries" to queries, + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.RowList = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.RowList.from(map = it as Map, nestedType) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Get a list of all the user's rows in a given table. You can use the query params to filter your results. + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @return [io.appwrite.models.RowList] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun listRows( + databaseId: String, + tableId: String, + queries: List? = null, + ): io.appwrite.models.RowList> = listRows( + databaseId, + tableId, + queries, + nestedType = classOf(), + ) + + /** + * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). Make sure to define columns before creating rows. + * @param rowId Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 Row data as JSON object. + * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @return [io.appwrite.models.Row] + */ + @JvmOverloads + suspend fun createRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any, + permissions: List? = null, + nestedType: Class, + ): io.appwrite.models.Row { + val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows" + .replace("{databaseId}", databaseId) + .replace("{tableId}", tableId) + + val apiParams = mutableMapOf( + "rowId" to rowId, + "data" to data, + "permissions" to permissions, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Row = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Row.from(map = it as Map, nestedType) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). Make sure to define columns before creating rows. + * @param rowId Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 Row data as JSON object. + * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @return [io.appwrite.models.Row] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any, + permissions: List? = null, + ): io.appwrite.models.Row> = createRow( + databaseId, + tableId, + rowId, + data, + permissions, + nestedType = classOf(), + ) + + /** + * Get a row by its unique ID. This endpoint response returns a JSON object with the row data. + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). + * @param rowId Row ID. + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @return [io.appwrite.models.Row] + */ + @JvmOverloads + suspend fun getRow( + databaseId: String, + tableId: String, + rowId: String, + queries: List? = null, + nestedType: Class, + ): io.appwrite.models.Row { + val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" + .replace("{databaseId}", databaseId) + .replace("{tableId}", tableId) + .replace("{rowId}", rowId) + + val apiParams = mutableMapOf( + "queries" to queries, + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.Row = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Row.from(map = it as Map, nestedType) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Get a row by its unique ID. This endpoint response returns a JSON object with the row data. + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). + * @param rowId Row ID. + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @return [io.appwrite.models.Row] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun getRow( + databaseId: String, + tableId: String, + rowId: String, + queries: List? = null, + ): io.appwrite.models.Row> = getRow( + databaseId, + tableId, + rowId, + queries, + nestedType = classOf(), + ) + + /** + * Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. + * + * @param databaseId Database ID. + * @param tableId Table ID. + * @param rowId Row ID. + * @param data Row data as JSON object. Include all required columns of the row to be created or updated. + * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @return [io.appwrite.models.Row] + */ + @JvmOverloads + suspend fun upsertRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any? = null, + permissions: List? = null, + nestedType: Class, + ): io.appwrite.models.Row { + val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" + .replace("{databaseId}", databaseId) + .replace("{tableId}", tableId) + .replace("{rowId}", rowId) + + val apiParams = mutableMapOf( + "data" to data, + "permissions" to permissions, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Row = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Row.from(map = it as Map, nestedType) + } + return client.call( + "PUT", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. + * + * @param databaseId Database ID. + * @param tableId Table ID. + * @param rowId Row ID. + * @param data Row data as JSON object. Include all required columns of the row to be created or updated. + * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @return [io.appwrite.models.Row] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun upsertRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any? = null, + permissions: List? = null, + ): io.appwrite.models.Row> = upsertRow( + databaseId, + tableId, + rowId, + data, + permissions, + nestedType = classOf(), + ) + + /** + * Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. + * + * @param databaseId Database ID. + * @param tableId Table ID. + * @param rowId Row ID. + * @param data Row data as JSON object. Include only columns and value pairs to be updated. + * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @return [io.appwrite.models.Row] + */ + @JvmOverloads + suspend fun updateRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any? = null, + permissions: List? = null, + nestedType: Class, + ): io.appwrite.models.Row { + val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" + .replace("{databaseId}", databaseId) + .replace("{tableId}", tableId) + .replace("{rowId}", rowId) + + val apiParams = mutableMapOf( + "data" to data, + "permissions" to permissions, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Row = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Row.from(map = it as Map, nestedType) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. + * + * @param databaseId Database ID. + * @param tableId Table ID. + * @param rowId Row ID. + * @param data Row data as JSON object. Include only columns and value pairs to be updated. + * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @return [io.appwrite.models.Row] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updateRow( + databaseId: String, + tableId: String, + rowId: String, + data: Any? = null, + permissions: List? = null, + ): io.appwrite.models.Row> = updateRow( + databaseId, + tableId, + rowId, + data, + permissions, + nestedType = classOf(), + ) + + /** + * Delete a row by its unique ID. + * + * @param databaseId Database ID. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). + * @param rowId Row ID. + * @return [Any] + */ + suspend fun deleteRow( + databaseId: String, + tableId: String, + rowId: String, + ): Any { + val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" + .replace("{databaseId}", databaseId) + .replace("{tableId}", tableId) + .replace("{rowId}", rowId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = Any::class.java, + ) + } + + +} \ No newline at end of file From bbe7107fde56f976a5605267b10f00f550a0bef4 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 20 Aug 2025 19:17:51 +1200 Subject: [PATCH 113/118] Add 1.8.x support --- .../databases/decrement-document-attribute.md | 27 +++ .../databases/increment-document-attribute.md | 27 +++ .../java/tablesdb/decrement-row-column.md | 27 +++ .../java/tablesdb/increment-row-column.md | 27 +++ .../databases/decrement-document-attribute.md | 18 ++ .../databases/increment-document-attribute.md | 18 ++ .../kotlin/tablesdb/decrement-row-column.md | 18 ++ .../kotlin/tablesdb/increment-row-column.md | 18 ++ .../java/io/appwrite/services/Databases.kt | 176 ++++++++++++++++++ .../java/io/appwrite/services/TablesDb.kt | 156 ++++++++++++++++ 10 files changed, 512 insertions(+) create mode 100644 docs/examples/java/databases/decrement-document-attribute.md create mode 100644 docs/examples/java/databases/increment-document-attribute.md create mode 100644 docs/examples/java/tablesdb/decrement-row-column.md create mode 100644 docs/examples/java/tablesdb/increment-row-column.md create mode 100644 docs/examples/kotlin/databases/decrement-document-attribute.md create mode 100644 docs/examples/kotlin/databases/increment-document-attribute.md create mode 100644 docs/examples/kotlin/tablesdb/decrement-row-column.md create mode 100644 docs/examples/kotlin/tablesdb/increment-row-column.md diff --git a/docs/examples/java/databases/decrement-document-attribute.md b/docs/examples/java/databases/decrement-document-attribute.md new file mode 100644 index 0000000..de6a4ab --- /dev/null +++ b/docs/examples/java/databases/decrement-document-attribute.md @@ -0,0 +1,27 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Databases databases = new Databases(client); + +databases.decrementDocumentAttribute( + "", // databaseId + "", // collectionId + "", // documentId + "", // attribute + 0, // value (optional) + 0, // min (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/databases/increment-document-attribute.md b/docs/examples/java/databases/increment-document-attribute.md new file mode 100644 index 0000000..94ffa9d --- /dev/null +++ b/docs/examples/java/databases/increment-document-attribute.md @@ -0,0 +1,27 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Databases databases = new Databases(client); + +databases.incrementDocumentAttribute( + "", // databaseId + "", // collectionId + "", // documentId + "", // attribute + 0, // value (optional) + 0, // max (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/tablesdb/decrement-row-column.md b/docs/examples/java/tablesdb/decrement-row-column.md new file mode 100644 index 0000000..67f3601 --- /dev/null +++ b/docs/examples/java/tablesdb/decrement-row-column.md @@ -0,0 +1,27 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.TablesDb; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +TablesDb tablesDb = new TablesDb(client); + +tablesDb.decrementRowColumn( + "", // databaseId + "", // tableId + "", // rowId + "", // column + 0, // value (optional) + 0, // min (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/tablesdb/increment-row-column.md b/docs/examples/java/tablesdb/increment-row-column.md new file mode 100644 index 0000000..b3d1c54 --- /dev/null +++ b/docs/examples/java/tablesdb/increment-row-column.md @@ -0,0 +1,27 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.TablesDb; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +TablesDb tablesDb = new TablesDb(client); + +tablesDb.incrementRowColumn( + "", // databaseId + "", // tableId + "", // rowId + "", // column + 0, // value (optional) + 0, // max (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/kotlin/databases/decrement-document-attribute.md b/docs/examples/kotlin/databases/decrement-document-attribute.md new file mode 100644 index 0000000..c500fa8 --- /dev/null +++ b/docs/examples/kotlin/databases/decrement-document-attribute.md @@ -0,0 +1,18 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val databases = Databases(client) + +val result = databases.decrementDocumentAttribute( + databaseId = "", + collectionId = "", + documentId = "", + attribute = "", + value = 0, // (optional) + min = 0, // (optional) +) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/increment-document-attribute.md b/docs/examples/kotlin/databases/increment-document-attribute.md new file mode 100644 index 0000000..0ae6b02 --- /dev/null +++ b/docs/examples/kotlin/databases/increment-document-attribute.md @@ -0,0 +1,18 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val databases = Databases(client) + +val result = databases.incrementDocumentAttribute( + databaseId = "", + collectionId = "", + documentId = "", + attribute = "", + value = 0, // (optional) + max = 0, // (optional) +) \ No newline at end of file diff --git a/docs/examples/kotlin/tablesdb/decrement-row-column.md b/docs/examples/kotlin/tablesdb/decrement-row-column.md new file mode 100644 index 0000000..29c2547 --- /dev/null +++ b/docs/examples/kotlin/tablesdb/decrement-row-column.md @@ -0,0 +1,18 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.TablesDb + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val tablesDb = TablesDb(client) + +val result = tablesDb.decrementRowColumn( + databaseId = "", + tableId = "", + rowId = "", + column = "", + value = 0, // (optional) + min = 0, // (optional) +) \ No newline at end of file diff --git a/docs/examples/kotlin/tablesdb/increment-row-column.md b/docs/examples/kotlin/tablesdb/increment-row-column.md new file mode 100644 index 0000000..7640be0 --- /dev/null +++ b/docs/examples/kotlin/tablesdb/increment-row-column.md @@ -0,0 +1,18 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.TablesDb + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val tablesDb = TablesDb(client) + +val result = tablesDb.incrementRowColumn( + databaseId = "", + tableId = "", + rowId = "", + column = "", + value = 0, // (optional) + max = 0, // (optional) +) \ 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 b9a6241..9a6fc37 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -443,4 +443,180 @@ class Databases(client: Client) : Service(client) { } + /** + * Decrement a specific attribute of a document by a given value. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. + * @param documentId Document ID. + * @param attribute Attribute key. + * @param value Value to increment the attribute by. The value must be a number. + * @param min Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @return [io.appwrite.models.Document] + */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `TablesDb.decrementRowColumn` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDb.decrementRowColumn"), + since = "1.8.0" + ) + @JvmOverloads + suspend fun decrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = null, + min: Double? = null, + nestedType: Class, + ): io.appwrite.models.Document { + val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + .replace("{documentId}", documentId) + .replace("{attribute}", attribute) + + val apiParams = mutableMapOf( + "value" to value, + "min" to min, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Document = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Document.from(map = it as Map, nestedType) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Decrement a specific attribute of a document by a given value. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. + * @param documentId Document ID. + * @param attribute Attribute key. + * @param value Value to increment the attribute by. The value must be a number. + * @param min Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @return [io.appwrite.models.Document] + */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `TablesDb.decrementRowColumn` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDb.decrementRowColumn"), + since = "1.8.0" + ) + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun decrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = null, + min: Double? = null, + ): io.appwrite.models.Document> = decrementDocumentAttribute( + databaseId, + collectionId, + documentId, + attribute, + value, + min, + nestedType = classOf(), + ) + + /** + * Increment a specific attribute of a document by a given value. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. + * @param documentId Document ID. + * @param attribute Attribute key. + * @param value Value to increment the attribute by. The value must be a number. + * @param max Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @return [io.appwrite.models.Document] + */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `TablesDb.incrementRowColumn` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDb.incrementRowColumn"), + since = "1.8.0" + ) + @JvmOverloads + suspend fun incrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = null, + max: Double? = null, + nestedType: Class, + ): io.appwrite.models.Document { + val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + .replace("{documentId}", documentId) + .replace("{attribute}", attribute) + + val apiParams = mutableMapOf( + "value" to value, + "max" to max, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Document = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Document.from(map = it as Map, nestedType) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Increment a specific attribute of a document by a given value. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. + * @param documentId Document ID. + * @param attribute Attribute key. + * @param value Value to increment the attribute by. The value must be a number. + * @param max Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @return [io.appwrite.models.Document] + */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `TablesDb.incrementRowColumn` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDb.incrementRowColumn"), + since = "1.8.0" + ) + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun incrementDocumentAttribute( + databaseId: String, + collectionId: String, + documentId: String, + attribute: String, + value: Double? = null, + max: Double? = null, + ): io.appwrite.models.Document> = incrementDocumentAttribute( + databaseId, + collectionId, + documentId, + attribute, + value, + max, + nestedType = classOf(), + ) + } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/TablesDb.kt b/library/src/main/java/io/appwrite/services/TablesDb.kt index d7b25fa..825f18d 100644 --- a/library/src/main/java/io/appwrite/services/TablesDb.kt +++ b/library/src/main/java/io/appwrite/services/TablesDb.kt @@ -388,4 +388,160 @@ class TablesDb(client: Client) : Service(client) { } + /** + * Decrement a specific column of a row by a given value. + * + * @param databaseId Database ID. + * @param tableId Table ID. + * @param rowId Row ID. + * @param column Column key. + * @param value Value to increment the column by. The value must be a number. + * @param min Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. + * @return [io.appwrite.models.Row] + */ + @JvmOverloads + suspend fun decrementRowColumn( + databaseId: String, + tableId: String, + rowId: String, + column: String, + value: Double? = null, + min: Double? = null, + nestedType: Class, + ): io.appwrite.models.Row { + val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement" + .replace("{databaseId}", databaseId) + .replace("{tableId}", tableId) + .replace("{rowId}", rowId) + .replace("{column}", column) + + val apiParams = mutableMapOf( + "value" to value, + "min" to min, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Row = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Row.from(map = it as Map, nestedType) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Decrement a specific column of a row by a given value. + * + * @param databaseId Database ID. + * @param tableId Table ID. + * @param rowId Row ID. + * @param column Column key. + * @param value Value to increment the column by. The value must be a number. + * @param min Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. + * @return [io.appwrite.models.Row] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun decrementRowColumn( + databaseId: String, + tableId: String, + rowId: String, + column: String, + value: Double? = null, + min: Double? = null, + ): io.appwrite.models.Row> = decrementRowColumn( + databaseId, + tableId, + rowId, + column, + value, + min, + nestedType = classOf(), + ) + + /** + * Increment a specific column of a row by a given value. + * + * @param databaseId Database ID. + * @param tableId Table ID. + * @param rowId Row ID. + * @param column Column key. + * @param value Value to increment the column by. The value must be a number. + * @param max Maximum value for the column. If the current value is greater than this value, an error will be thrown. + * @return [io.appwrite.models.Row] + */ + @JvmOverloads + suspend fun incrementRowColumn( + databaseId: String, + tableId: String, + rowId: String, + column: String, + value: Double? = null, + max: Double? = null, + nestedType: Class, + ): io.appwrite.models.Row { + val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment" + .replace("{databaseId}", databaseId) + .replace("{tableId}", tableId) + .replace("{rowId}", rowId) + .replace("{column}", column) + + val apiParams = mutableMapOf( + "value" to value, + "max" to max, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Row = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Row.from(map = it as Map, nestedType) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Increment a specific column of a row by a given value. + * + * @param databaseId Database ID. + * @param tableId Table ID. + * @param rowId Row ID. + * @param column Column key. + * @param value Value to increment the column by. The value must be a number. + * @param max Maximum value for the column. If the current value is greater than this value, an error will be thrown. + * @return [io.appwrite.models.Row] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun incrementRowColumn( + databaseId: String, + tableId: String, + rowId: String, + column: String, + value: Double? = null, + max: Double? = null, + ): io.appwrite.models.Row> = incrementRowColumn( + databaseId, + tableId, + rowId, + column, + value, + max, + nestedType = classOf(), + ) + } \ No newline at end of file From 07bf470d9c1b35a3fc360faba3924f2eaa82aa6c Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 21 Aug 2025 22:16:00 +1200 Subject: [PATCH 114/118] Fix casing --- .../account/create-m-f-a-authenticator.md | 23 + .../java/account/create-m-f-a-challenge.md | 23 + .../account/create-m-f-a-recovery-codes.md | 18 + .../account/delete-m-f-a-authenticator.md | 23 + .../java/account/get-m-f-a-recovery-codes.md | 18 + .../java/account/list-m-f-a-factors.md | 18 + .../account/update-m-f-a-authenticator.md | 24 ++ .../java/account/update-m-f-a-challenge.md | 23 + .../account/update-m-f-a-recovery-codes.md | 18 + docs/examples/java/tablesdb/create-row.md | 6 +- .../java/tablesdb/decrement-row-column.md | 6 +- docs/examples/java/tablesdb/delete-row.md | 6 +- docs/examples/java/tablesdb/get-row.md | 6 +- .../java/tablesdb/increment-row-column.md | 6 +- docs/examples/java/tablesdb/list-rows.md | 6 +- docs/examples/java/tablesdb/update-row.md | 6 +- docs/examples/java/tablesdb/upsert-row.md | 6 +- .../account/create-m-f-a-authenticator.md | 14 + .../kotlin/account/create-m-f-a-challenge.md | 14 + .../account/create-m-f-a-recovery-codes.md | 11 + .../account/delete-m-f-a-authenticator.md | 14 + .../account/get-m-f-a-recovery-codes.md | 11 + .../kotlin/account/list-m-f-a-factors.md | 11 + .../account/update-m-f-a-authenticator.md | 15 + .../kotlin/account/update-m-f-a-challenge.md | 14 + .../account/update-m-f-a-recovery-codes.md | 11 + docs/examples/kotlin/tablesdb/create-row.md | 6 +- .../kotlin/tablesdb/decrement-row-column.md | 6 +- docs/examples/kotlin/tablesdb/delete-row.md | 6 +- docs/examples/kotlin/tablesdb/get-row.md | 6 +- .../kotlin/tablesdb/increment-row-column.md | 6 +- docs/examples/kotlin/tablesdb/list-rows.md | 6 +- docs/examples/kotlin/tablesdb/update-row.md | 6 +- docs/examples/kotlin/tablesdb/upsert-row.md | 6 +- .../java/io/appwrite/models/ContinentList.kt | 2 +- .../java/io/appwrite/models/CountryList.kt | 2 +- .../java/io/appwrite/models/CurrencyList.kt | 2 +- .../java/io/appwrite/models/DocumentList.kt | 2 +- .../java/io/appwrite/models/ExecutionList.kt | 2 +- .../main/java/io/appwrite/models/FileList.kt | 2 +- .../java/io/appwrite/models/IdentityList.kt | 2 +- .../java/io/appwrite/models/LanguageList.kt | 2 +- .../java/io/appwrite/models/LocaleCodeList.kt | 2 +- .../main/java/io/appwrite/models/LogList.kt | 2 +- .../java/io/appwrite/models/MembershipList.kt | 2 +- .../main/java/io/appwrite/models/PhoneList.kt | 2 +- .../main/java/io/appwrite/models/RowList.kt | 2 +- .../java/io/appwrite/models/SessionList.kt | 2 +- .../main/java/io/appwrite/models/TeamList.kt | 2 +- .../main/java/io/appwrite/services/Account.kt | 403 +++++++++++++++++- .../main/java/io/appwrite/services/Avatars.kt | 32 +- .../java/io/appwrite/services/Databases.kt | 62 +-- .../main/java/io/appwrite/services/Locale.kt | 6 +- .../main/java/io/appwrite/services/Storage.kt | 13 +- .../java/io/appwrite/services/TablesDb.kt | 26 +- .../main/java/io/appwrite/services/Teams.kt | 23 +- 56 files changed, 852 insertions(+), 142 deletions(-) create mode 100644 docs/examples/java/account/create-m-f-a-authenticator.md create mode 100644 docs/examples/java/account/create-m-f-a-challenge.md create mode 100644 docs/examples/java/account/create-m-f-a-recovery-codes.md create mode 100644 docs/examples/java/account/delete-m-f-a-authenticator.md create mode 100644 docs/examples/java/account/get-m-f-a-recovery-codes.md create mode 100644 docs/examples/java/account/list-m-f-a-factors.md create mode 100644 docs/examples/java/account/update-m-f-a-authenticator.md create mode 100644 docs/examples/java/account/update-m-f-a-challenge.md create mode 100644 docs/examples/java/account/update-m-f-a-recovery-codes.md create mode 100644 docs/examples/kotlin/account/create-m-f-a-authenticator.md create mode 100644 docs/examples/kotlin/account/create-m-f-a-challenge.md create mode 100644 docs/examples/kotlin/account/create-m-f-a-recovery-codes.md create mode 100644 docs/examples/kotlin/account/delete-m-f-a-authenticator.md create mode 100644 docs/examples/kotlin/account/get-m-f-a-recovery-codes.md create mode 100644 docs/examples/kotlin/account/list-m-f-a-factors.md create mode 100644 docs/examples/kotlin/account/update-m-f-a-authenticator.md create mode 100644 docs/examples/kotlin/account/update-m-f-a-challenge.md create mode 100644 docs/examples/kotlin/account/update-m-f-a-recovery-codes.md diff --git a/docs/examples/java/account/create-m-f-a-authenticator.md b/docs/examples/java/account/create-m-f-a-authenticator.md new file mode 100644 index 0000000..d236f46 --- /dev/null +++ b/docs/examples/java/account/create-m-f-a-authenticator.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; +import io.appwrite.enums.AuthenticatorType; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Account account = new Account(client); + +account.createMFAAuthenticator( + AuthenticatorType.TOTP, // type + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/account/create-m-f-a-challenge.md b/docs/examples/java/account/create-m-f-a-challenge.md new file mode 100644 index 0000000..222c0bd --- /dev/null +++ b/docs/examples/java/account/create-m-f-a-challenge.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; +import io.appwrite.enums.AuthenticationFactor; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Account account = new Account(client); + +account.createMFAChallenge( + AuthenticationFactor.EMAIL, // factor + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/account/create-m-f-a-recovery-codes.md b/docs/examples/java/account/create-m-f-a-recovery-codes.md new file mode 100644 index 0000000..792e086 --- /dev/null +++ b/docs/examples/java/account/create-m-f-a-recovery-codes.md @@ -0,0 +1,18 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Account account = new Account(client); + +account.createMFARecoveryCodes(new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/account/delete-m-f-a-authenticator.md b/docs/examples/java/account/delete-m-f-a-authenticator.md new file mode 100644 index 0000000..b5ff26c --- /dev/null +++ b/docs/examples/java/account/delete-m-f-a-authenticator.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; +import io.appwrite.enums.AuthenticatorType; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Account account = new Account(client); + +account.deleteMFAAuthenticator( + AuthenticatorType.TOTP, // type + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/account/get-m-f-a-recovery-codes.md b/docs/examples/java/account/get-m-f-a-recovery-codes.md new file mode 100644 index 0000000..22bc1c1 --- /dev/null +++ b/docs/examples/java/account/get-m-f-a-recovery-codes.md @@ -0,0 +1,18 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Account account = new Account(client); + +account.getMFARecoveryCodes(new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/account/list-m-f-a-factors.md b/docs/examples/java/account/list-m-f-a-factors.md new file mode 100644 index 0000000..06f20e1 --- /dev/null +++ b/docs/examples/java/account/list-m-f-a-factors.md @@ -0,0 +1,18 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Account account = new Account(client); + +account.listMFAFactors(new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/account/update-m-f-a-authenticator.md b/docs/examples/java/account/update-m-f-a-authenticator.md new file mode 100644 index 0000000..00ddd46 --- /dev/null +++ b/docs/examples/java/account/update-m-f-a-authenticator.md @@ -0,0 +1,24 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; +import io.appwrite.enums.AuthenticatorType; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Account account = new Account(client); + +account.updateMFAAuthenticator( + AuthenticatorType.TOTP, // type + "", // otp + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/account/update-m-f-a-challenge.md b/docs/examples/java/account/update-m-f-a-challenge.md new file mode 100644 index 0000000..10b5db4 --- /dev/null +++ b/docs/examples/java/account/update-m-f-a-challenge.md @@ -0,0 +1,23 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Account account = new Account(client); + +account.updateMFAChallenge( + "", // challengeId + "", // otp + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/account/update-m-f-a-recovery-codes.md b/docs/examples/java/account/update-m-f-a-recovery-codes.md new file mode 100644 index 0000000..c0d6c69 --- /dev/null +++ b/docs/examples/java/account/update-m-f-a-recovery-codes.md @@ -0,0 +1,18 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Account; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Account account = new Account(client); + +account.updateMFARecoveryCodes(new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); +})); diff --git a/docs/examples/java/tablesdb/create-row.md b/docs/examples/java/tablesdb/create-row.md index 4c7d10d..12d1680 100644 --- a/docs/examples/java/tablesdb/create-row.md +++ b/docs/examples/java/tablesdb/create-row.md @@ -1,14 +1,14 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.TablesDb; +import io.appwrite.services.TablesDB; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID -TablesDb tablesDb = new TablesDb(client); +TablesDB tablesDB = new TablesDB(client); -tablesDb.createRow( +tablesDB.createRow( "", // databaseId "", // tableId "", // rowId diff --git a/docs/examples/java/tablesdb/decrement-row-column.md b/docs/examples/java/tablesdb/decrement-row-column.md index 67f3601..73f2128 100644 --- a/docs/examples/java/tablesdb/decrement-row-column.md +++ b/docs/examples/java/tablesdb/decrement-row-column.md @@ -1,14 +1,14 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.TablesDb; +import io.appwrite.services.TablesDB; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID -TablesDb tablesDb = new TablesDb(client); +TablesDB tablesDB = new TablesDB(client); -tablesDb.decrementRowColumn( +tablesDB.decrementRowColumn( "", // databaseId "", // tableId "", // rowId diff --git a/docs/examples/java/tablesdb/delete-row.md b/docs/examples/java/tablesdb/delete-row.md index 776f6bd..d4c351b 100644 --- a/docs/examples/java/tablesdb/delete-row.md +++ b/docs/examples/java/tablesdb/delete-row.md @@ -1,14 +1,14 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.TablesDb; +import io.appwrite.services.TablesDB; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID -TablesDb tablesDb = new TablesDb(client); +TablesDB tablesDB = new TablesDB(client); -tablesDb.deleteRow( +tablesDB.deleteRow( "", // databaseId "", // tableId "", // rowId diff --git a/docs/examples/java/tablesdb/get-row.md b/docs/examples/java/tablesdb/get-row.md index a0e20a3..191fc89 100644 --- a/docs/examples/java/tablesdb/get-row.md +++ b/docs/examples/java/tablesdb/get-row.md @@ -1,14 +1,14 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.TablesDb; +import io.appwrite.services.TablesDB; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID -TablesDb tablesDb = new TablesDb(client); +TablesDB tablesDB = new TablesDB(client); -tablesDb.getRow( +tablesDB.getRow( "", // databaseId "", // tableId "", // rowId diff --git a/docs/examples/java/tablesdb/increment-row-column.md b/docs/examples/java/tablesdb/increment-row-column.md index b3d1c54..dc2120e 100644 --- a/docs/examples/java/tablesdb/increment-row-column.md +++ b/docs/examples/java/tablesdb/increment-row-column.md @@ -1,14 +1,14 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.TablesDb; +import io.appwrite.services.TablesDB; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID -TablesDb tablesDb = new TablesDb(client); +TablesDB tablesDB = new TablesDB(client); -tablesDb.incrementRowColumn( +tablesDB.incrementRowColumn( "", // databaseId "", // tableId "", // rowId diff --git a/docs/examples/java/tablesdb/list-rows.md b/docs/examples/java/tablesdb/list-rows.md index 9bd6f6d..dc50574 100644 --- a/docs/examples/java/tablesdb/list-rows.md +++ b/docs/examples/java/tablesdb/list-rows.md @@ -1,14 +1,14 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.TablesDb; +import io.appwrite.services.TablesDB; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID -TablesDb tablesDb = new TablesDb(client); +TablesDB tablesDB = new TablesDB(client); -tablesDb.listRows( +tablesDB.listRows( "", // databaseId "", // tableId listOf(), // queries (optional) diff --git a/docs/examples/java/tablesdb/update-row.md b/docs/examples/java/tablesdb/update-row.md index fdcd8ac..0f1fabc 100644 --- a/docs/examples/java/tablesdb/update-row.md +++ b/docs/examples/java/tablesdb/update-row.md @@ -1,14 +1,14 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.TablesDb; +import io.appwrite.services.TablesDB; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID -TablesDb tablesDb = new TablesDb(client); +TablesDB tablesDB = new TablesDB(client); -tablesDb.updateRow( +tablesDB.updateRow( "", // databaseId "", // tableId "", // rowId diff --git a/docs/examples/java/tablesdb/upsert-row.md b/docs/examples/java/tablesdb/upsert-row.md index 6c60b9c..22c0e94 100644 --- a/docs/examples/java/tablesdb/upsert-row.md +++ b/docs/examples/java/tablesdb/upsert-row.md @@ -1,14 +1,14 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.TablesDb; +import io.appwrite.services.TablesDB; Client client = new Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject(""); // Your project ID -TablesDb tablesDb = new TablesDb(client); +TablesDB tablesDB = new TablesDB(client); -tablesDb.upsertRow( +tablesDB.upsertRow( "", // databaseId "", // tableId "", // rowId diff --git a/docs/examples/kotlin/account/create-m-f-a-authenticator.md b/docs/examples/kotlin/account/create-m-f-a-authenticator.md new file mode 100644 index 0000000..934de1c --- /dev/null +++ b/docs/examples/kotlin/account/create-m-f-a-authenticator.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account +import io.appwrite.enums.AuthenticatorType + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val account = Account(client) + +val result = account.createMFAAuthenticator( + type = AuthenticatorType.TOTP, +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-m-f-a-challenge.md b/docs/examples/kotlin/account/create-m-f-a-challenge.md new file mode 100644 index 0000000..f79c498 --- /dev/null +++ b/docs/examples/kotlin/account/create-m-f-a-challenge.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account +import io.appwrite.enums.AuthenticationFactor + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val account = Account(client) + +val result = account.createMFAChallenge( + factor = AuthenticationFactor.EMAIL, +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-m-f-a-recovery-codes.md b/docs/examples/kotlin/account/create-m-f-a-recovery-codes.md new file mode 100644 index 0000000..cc56966 --- /dev/null +++ b/docs/examples/kotlin/account/create-m-f-a-recovery-codes.md @@ -0,0 +1,11 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val account = Account(client) + +val result = account.createMFARecoveryCodes() diff --git a/docs/examples/kotlin/account/delete-m-f-a-authenticator.md b/docs/examples/kotlin/account/delete-m-f-a-authenticator.md new file mode 100644 index 0000000..b140a11 --- /dev/null +++ b/docs/examples/kotlin/account/delete-m-f-a-authenticator.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account +import io.appwrite.enums.AuthenticatorType + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val account = Account(client) + +val result = account.deleteMFAAuthenticator( + type = AuthenticatorType.TOTP, +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/get-m-f-a-recovery-codes.md b/docs/examples/kotlin/account/get-m-f-a-recovery-codes.md new file mode 100644 index 0000000..f9d3612 --- /dev/null +++ b/docs/examples/kotlin/account/get-m-f-a-recovery-codes.md @@ -0,0 +1,11 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val account = Account(client) + +val result = account.getMFARecoveryCodes() diff --git a/docs/examples/kotlin/account/list-m-f-a-factors.md b/docs/examples/kotlin/account/list-m-f-a-factors.md new file mode 100644 index 0000000..56d1c4d --- /dev/null +++ b/docs/examples/kotlin/account/list-m-f-a-factors.md @@ -0,0 +1,11 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val account = Account(client) + +val result = account.listMFAFactors() diff --git a/docs/examples/kotlin/account/update-m-f-a-authenticator.md b/docs/examples/kotlin/account/update-m-f-a-authenticator.md new file mode 100644 index 0000000..4f6ecd7 --- /dev/null +++ b/docs/examples/kotlin/account/update-m-f-a-authenticator.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account +import io.appwrite.enums.AuthenticatorType + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val account = Account(client) + +val result = account.updateMFAAuthenticator( + type = AuthenticatorType.TOTP, + otp = "", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-m-f-a-challenge.md b/docs/examples/kotlin/account/update-m-f-a-challenge.md new file mode 100644 index 0000000..d5cbc1f --- /dev/null +++ b/docs/examples/kotlin/account/update-m-f-a-challenge.md @@ -0,0 +1,14 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val account = Account(client) + +val result = account.updateMFAChallenge( + challengeId = "", + otp = "", +) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-m-f-a-recovery-codes.md b/docs/examples/kotlin/account/update-m-f-a-recovery-codes.md new file mode 100644 index 0000000..0277ca7 --- /dev/null +++ b/docs/examples/kotlin/account/update-m-f-a-recovery-codes.md @@ -0,0 +1,11 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Account + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val account = Account(client) + +val result = account.updateMFARecoveryCodes() diff --git a/docs/examples/kotlin/tablesdb/create-row.md b/docs/examples/kotlin/tablesdb/create-row.md index 1e84ebd..1a9cbdb 100644 --- a/docs/examples/kotlin/tablesdb/create-row.md +++ b/docs/examples/kotlin/tablesdb/create-row.md @@ -1,14 +1,14 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.TablesDb +import io.appwrite.services.TablesDB val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -val tablesDb = TablesDb(client) +val tablesDB = TablesDB(client) -val result = tablesDb.createRow( +val result = tablesDB.createRow( databaseId = "", tableId = "", rowId = "", diff --git a/docs/examples/kotlin/tablesdb/decrement-row-column.md b/docs/examples/kotlin/tablesdb/decrement-row-column.md index 29c2547..645e9f4 100644 --- a/docs/examples/kotlin/tablesdb/decrement-row-column.md +++ b/docs/examples/kotlin/tablesdb/decrement-row-column.md @@ -1,14 +1,14 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.TablesDb +import io.appwrite.services.TablesDB val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -val tablesDb = TablesDb(client) +val tablesDB = TablesDB(client) -val result = tablesDb.decrementRowColumn( +val result = tablesDB.decrementRowColumn( databaseId = "", tableId = "", rowId = "", diff --git a/docs/examples/kotlin/tablesdb/delete-row.md b/docs/examples/kotlin/tablesdb/delete-row.md index af6f5f5..3fcd409 100644 --- a/docs/examples/kotlin/tablesdb/delete-row.md +++ b/docs/examples/kotlin/tablesdb/delete-row.md @@ -1,14 +1,14 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.TablesDb +import io.appwrite.services.TablesDB val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -val tablesDb = TablesDb(client) +val tablesDB = TablesDB(client) -val result = tablesDb.deleteRow( +val result = tablesDB.deleteRow( databaseId = "", tableId = "", rowId = "", diff --git a/docs/examples/kotlin/tablesdb/get-row.md b/docs/examples/kotlin/tablesdb/get-row.md index 3408f1d..b754cba 100644 --- a/docs/examples/kotlin/tablesdb/get-row.md +++ b/docs/examples/kotlin/tablesdb/get-row.md @@ -1,14 +1,14 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.TablesDb +import io.appwrite.services.TablesDB val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -val tablesDb = TablesDb(client) +val tablesDB = TablesDB(client) -val result = tablesDb.getRow( +val result = tablesDB.getRow( databaseId = "", tableId = "", rowId = "", diff --git a/docs/examples/kotlin/tablesdb/increment-row-column.md b/docs/examples/kotlin/tablesdb/increment-row-column.md index 7640be0..230408a 100644 --- a/docs/examples/kotlin/tablesdb/increment-row-column.md +++ b/docs/examples/kotlin/tablesdb/increment-row-column.md @@ -1,14 +1,14 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.TablesDb +import io.appwrite.services.TablesDB val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -val tablesDb = TablesDb(client) +val tablesDB = TablesDB(client) -val result = tablesDb.incrementRowColumn( +val result = tablesDB.incrementRowColumn( databaseId = "", tableId = "", rowId = "", diff --git a/docs/examples/kotlin/tablesdb/list-rows.md b/docs/examples/kotlin/tablesdb/list-rows.md index b5bc755..05d9ca3 100644 --- a/docs/examples/kotlin/tablesdb/list-rows.md +++ b/docs/examples/kotlin/tablesdb/list-rows.md @@ -1,14 +1,14 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.TablesDb +import io.appwrite.services.TablesDB val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -val tablesDb = TablesDb(client) +val tablesDB = TablesDB(client) -val result = tablesDb.listRows( +val result = tablesDB.listRows( databaseId = "", tableId = "", queries = listOf(), // (optional) diff --git a/docs/examples/kotlin/tablesdb/update-row.md b/docs/examples/kotlin/tablesdb/update-row.md index cc83763..f99f8f2 100644 --- a/docs/examples/kotlin/tablesdb/update-row.md +++ b/docs/examples/kotlin/tablesdb/update-row.md @@ -1,14 +1,14 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.TablesDb +import io.appwrite.services.TablesDB val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -val tablesDb = TablesDb(client) +val tablesDB = TablesDB(client) -val result = tablesDb.updateRow( +val result = tablesDB.updateRow( databaseId = "", tableId = "", rowId = "", diff --git a/docs/examples/kotlin/tablesdb/upsert-row.md b/docs/examples/kotlin/tablesdb/upsert-row.md index f9f165e..d82406a 100644 --- a/docs/examples/kotlin/tablesdb/upsert-row.md +++ b/docs/examples/kotlin/tablesdb/upsert-row.md @@ -1,14 +1,14 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.TablesDb +import io.appwrite.services.TablesDB val client = Client(context) .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint .setProject("") // Your project ID -val tablesDb = TablesDb(client) +val tablesDB = TablesDB(client) -val result = tablesDb.upsertRow( +val result = tablesDB.upsertRow( databaseId = "", tableId = "", rowId = "", diff --git a/library/src/main/java/io/appwrite/models/ContinentList.kt b/library/src/main/java/io/appwrite/models/ContinentList.kt index a6ec310..789acff 100644 --- a/library/src/main/java/io/appwrite/models/ContinentList.kt +++ b/library/src/main/java/io/appwrite/models/ContinentList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class ContinentList( /** - * Total number of continents rows that matched your query. + * Total number of continents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/CountryList.kt b/library/src/main/java/io/appwrite/models/CountryList.kt index 546cf73..47c0e72 100644 --- a/library/src/main/java/io/appwrite/models/CountryList.kt +++ b/library/src/main/java/io/appwrite/models/CountryList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class CountryList( /** - * Total number of countries rows that matched your query. + * Total number of countries that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/CurrencyList.kt b/library/src/main/java/io/appwrite/models/CurrencyList.kt index 95dec92..5a57a02 100644 --- a/library/src/main/java/io/appwrite/models/CurrencyList.kt +++ b/library/src/main/java/io/appwrite/models/CurrencyList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class CurrencyList( /** - * Total number of currencies rows that matched your query. + * Total number of currencies that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/DocumentList.kt b/library/src/main/java/io/appwrite/models/DocumentList.kt index 6f40579..c26cd26 100644 --- a/library/src/main/java/io/appwrite/models/DocumentList.kt +++ b/library/src/main/java/io/appwrite/models/DocumentList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class DocumentList( /** - * Total number of documents rows that matched your query. + * Total number of documents that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/ExecutionList.kt b/library/src/main/java/io/appwrite/models/ExecutionList.kt index ac11e4f..a976e78 100644 --- a/library/src/main/java/io/appwrite/models/ExecutionList.kt +++ b/library/src/main/java/io/appwrite/models/ExecutionList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class ExecutionList( /** - * Total number of executions rows that matched your query. + * Total number of executions that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/FileList.kt b/library/src/main/java/io/appwrite/models/FileList.kt index ba69ea8..dfdd212 100644 --- a/library/src/main/java/io/appwrite/models/FileList.kt +++ b/library/src/main/java/io/appwrite/models/FileList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class FileList( /** - * Total number of files rows that matched your query. + * Total number of files that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/IdentityList.kt b/library/src/main/java/io/appwrite/models/IdentityList.kt index 2e1a33a..49c3346 100644 --- a/library/src/main/java/io/appwrite/models/IdentityList.kt +++ b/library/src/main/java/io/appwrite/models/IdentityList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class IdentityList( /** - * Total number of identities rows that matched your query. + * Total number of identities that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/LanguageList.kt b/library/src/main/java/io/appwrite/models/LanguageList.kt index ab78452..1aac2f7 100644 --- a/library/src/main/java/io/appwrite/models/LanguageList.kt +++ b/library/src/main/java/io/appwrite/models/LanguageList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class LanguageList( /** - * Total number of languages rows that matched your query. + * Total number of languages that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/LocaleCodeList.kt b/library/src/main/java/io/appwrite/models/LocaleCodeList.kt index 6f47333..7949b57 100644 --- a/library/src/main/java/io/appwrite/models/LocaleCodeList.kt +++ b/library/src/main/java/io/appwrite/models/LocaleCodeList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class LocaleCodeList( /** - * Total number of localeCodes rows that matched your query. + * Total number of localeCodes that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/LogList.kt b/library/src/main/java/io/appwrite/models/LogList.kt index d2e0b00..c88451c 100644 --- a/library/src/main/java/io/appwrite/models/LogList.kt +++ b/library/src/main/java/io/appwrite/models/LogList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class LogList( /** - * Total number of logs rows that matched your query. + * Total number of logs that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/MembershipList.kt b/library/src/main/java/io/appwrite/models/MembershipList.kt index efcffc4..b2bea4e 100644 --- a/library/src/main/java/io/appwrite/models/MembershipList.kt +++ b/library/src/main/java/io/appwrite/models/MembershipList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class MembershipList( /** - * Total number of memberships rows that matched your query. + * Total number of memberships that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/PhoneList.kt b/library/src/main/java/io/appwrite/models/PhoneList.kt index 675295f..5f7c22f 100644 --- a/library/src/main/java/io/appwrite/models/PhoneList.kt +++ b/library/src/main/java/io/appwrite/models/PhoneList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class PhoneList( /** - * Total number of phones rows that matched your query. + * Total number of phones that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/RowList.kt b/library/src/main/java/io/appwrite/models/RowList.kt index 289f39b..5e99cd7 100644 --- a/library/src/main/java/io/appwrite/models/RowList.kt +++ b/library/src/main/java/io/appwrite/models/RowList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class RowList( /** - * Total number of rows rows that matched your query. + * Total number of rows that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/SessionList.kt b/library/src/main/java/io/appwrite/models/SessionList.kt index 13e0c36..22fba69 100644 --- a/library/src/main/java/io/appwrite/models/SessionList.kt +++ b/library/src/main/java/io/appwrite/models/SessionList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class SessionList( /** - * Total number of sessions rows that matched your query. + * Total number of sessions that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/models/TeamList.kt b/library/src/main/java/io/appwrite/models/TeamList.kt index f1a1968..c95cc56 100644 --- a/library/src/main/java/io/appwrite/models/TeamList.kt +++ b/library/src/main/java/io/appwrite/models/TeamList.kt @@ -8,7 +8,7 @@ import io.appwrite.extensions.jsonCast */ data class TeamList( /** - * Total number of teams rows that matched your query. + * Total number of teams that matched your query. */ @SerializedName("total") val total: Long, diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index bebf4db..3a042ba 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -125,7 +125,9 @@ class Account(client: Client) : Service(client) { ) /** - * 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. + * 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. @@ -348,6 +350,11 @@ class Account(client: Client) : Service(client) { * @param type Type of authenticator. Must be `totp` * @return [io.appwrite.models.MfaType] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `CreateMFAAuthenticator` instead.", + replaceWith = ReplaceWith("io.appwrite.services.CreateMFAAuthenticator"), + since = "1.8.0" + ) suspend fun createMfaAuthenticator( type: io.appwrite.enums.AuthenticatorType, ): io.appwrite.models.MfaType { @@ -374,6 +381,38 @@ class Account(client: Client) : Service(client) { } + /** + * Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. + * + * @param type Type of authenticator. Must be `totp` + * @return [io.appwrite.models.MfaType] + */ + suspend fun createMFAAuthenticator( + type: io.appwrite.enums.AuthenticatorType, + ): io.appwrite.models.MfaType { + val apiPath = "/account/mfa/authenticators/{type}" + .replace("{type}", type.value) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.MfaType = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.MfaType.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.MfaType::class.java, + converter, + ) + } + + /** * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. * @@ -381,6 +420,11 @@ class Account(client: Client) : Service(client) { * @param otp Valid verification token. * @return [io.appwrite.models.User] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `UpdateMFAAuthenticator` instead.", + replaceWith = ReplaceWith("io.appwrite.services.UpdateMFAAuthenticator"), + since = "1.8.0" + ) suspend fun updateMfaAuthenticator( type: io.appwrite.enums.AuthenticatorType, otp: String, @@ -416,6 +460,11 @@ class Account(client: Client) : Service(client) { * @param otp Valid verification token. * @return [io.appwrite.models.User] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `UpdateMFAAuthenticator` instead.", + replaceWith = ReplaceWith("io.appwrite.services.UpdateMFAAuthenticator"), + since = "1.8.0" + ) @Throws(AppwriteException::class) suspend fun updateMfaAuthenticator( type: io.appwrite.enums.AuthenticatorType, @@ -426,12 +475,69 @@ class Account(client: Client) : Service(client) { nestedType = classOf(), ) + /** + * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. + * + * @param type Type of authenticator. + * @param otp Valid verification token. + * @return [io.appwrite.models.User] + */ + suspend fun updateMFAAuthenticator( + type: io.appwrite.enums.AuthenticatorType, + otp: String, + nestedType: Class, + ): io.appwrite.models.User { + val apiPath = "/account/mfa/authenticators/{type}" + .replace("{type}", type.value) + + val apiParams = mutableMapOf( + "otp" to otp, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.User = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.User.from(map = it as Map, nestedType) + } + return client.call( + "PUT", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. + * + * @param type Type of authenticator. + * @param otp Valid verification token. + * @return [io.appwrite.models.User] + */ + @Throws(AppwriteException::class) + suspend fun updateMFAAuthenticator( + type: io.appwrite.enums.AuthenticatorType, + otp: String, + ): io.appwrite.models.User> = updateMFAAuthenticator( + type, + otp, + nestedType = classOf(), + ) + /** * Delete an authenticator for a user by ID. * * @param type Type of authenticator. * @return [Any] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `DeleteMFAAuthenticator` instead.", + replaceWith = ReplaceWith("io.appwrite.services.DeleteMFAAuthenticator"), + since = "1.8.0" + ) suspend fun deleteMfaAuthenticator( type: io.appwrite.enums.AuthenticatorType, ): Any { @@ -453,12 +559,44 @@ class Account(client: Client) : Service(client) { } + /** + * Delete an authenticator for a user by ID. + * + * @param type Type of authenticator. + * @return [Any] + */ + suspend fun deleteMFAAuthenticator( + type: io.appwrite.enums.AuthenticatorType, + ): Any { + val apiPath = "/account/mfa/authenticators/{type}" + .replace("{type}", type.value) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = Any::class.java, + ) + } + + /** * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. * * @param factor Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`. * @return [io.appwrite.models.MfaChallenge] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `CreateMFAChallenge` instead.", + replaceWith = ReplaceWith("io.appwrite.services.CreateMFAChallenge"), + since = "1.8.0" + ) suspend fun createMfaChallenge( factor: io.appwrite.enums.AuthenticationFactor, ): io.appwrite.models.MfaChallenge { @@ -485,6 +623,38 @@ class Account(client: Client) : Service(client) { } + /** + * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. + * + * @param factor Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`. + * @return [io.appwrite.models.MfaChallenge] + */ + suspend fun createMFAChallenge( + factor: io.appwrite.enums.AuthenticationFactor, + ): io.appwrite.models.MfaChallenge { + val apiPath = "/account/mfa/challenge" + + val apiParams = mutableMapOf( + "factor" to factor, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.MfaChallenge = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.MfaChallenge.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.MfaChallenge::class.java, + converter, + ) + } + + /** * Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. * @@ -492,6 +662,11 @@ class Account(client: Client) : Service(client) { * @param otp Valid verification token. * @return [io.appwrite.models.Session] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `UpdateMFAChallenge` instead.", + replaceWith = ReplaceWith("io.appwrite.services.UpdateMFAChallenge"), + since = "1.8.0" + ) suspend fun updateMfaChallenge( challengeId: String, otp: String, @@ -520,11 +695,51 @@ class Account(client: Client) : Service(client) { } + /** + * Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. + * + * @param challengeId ID of the challenge. + * @param otp Valid verification token. + * @return [io.appwrite.models.Session] + */ + suspend fun updateMFAChallenge( + challengeId: String, + otp: String, + ): io.appwrite.models.Session { + val apiPath = "/account/mfa/challenge" + + val apiParams = mutableMapOf( + "challengeId" to challengeId, + "otp" to otp, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Session = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Session.from(map = it as Map) + } + return client.call( + "PUT", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Session::class.java, + converter, + ) + } + + /** * List the factors available on the account to be used as a MFA challange. * * @return [io.appwrite.models.MfaFactors] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `ListMFAFactors` instead.", + replaceWith = ReplaceWith("io.appwrite.services.ListMFAFactors"), + since = "1.8.0" + ) suspend fun listMfaFactors( ): io.appwrite.models.MfaFactors { val apiPath = "/account/mfa/factors" @@ -548,11 +763,44 @@ class Account(client: Client) : Service(client) { } + /** + * List the factors available on the account to be used as a MFA challange. + * + * @return [io.appwrite.models.MfaFactors] + */ + suspend fun listMFAFactors( + ): io.appwrite.models.MfaFactors { + val apiPath = "/account/mfa/factors" + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.MfaFactors = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.MfaFactors.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.MfaFactors::class.java, + converter, + ) + } + + /** * Get recovery codes that can be used as backup for MFA flow. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to read recovery codes. * * @return [io.appwrite.models.MfaRecoveryCodes] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `GetMFARecoveryCodes` instead.", + replaceWith = ReplaceWith("io.appwrite.services.GetMFARecoveryCodes"), + since = "1.8.0" + ) suspend fun getMfaRecoveryCodes( ): io.appwrite.models.MfaRecoveryCodes { val apiPath = "/account/mfa/recovery-codes" @@ -577,10 +825,43 @@ class Account(client: Client) : Service(client) { /** - * Generate recovery codes as backup for MFA flow. It's recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. + * Get recovery codes that can be used as backup for MFA flow. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to read recovery codes. * * @return [io.appwrite.models.MfaRecoveryCodes] */ + suspend fun getMFARecoveryCodes( + ): io.appwrite.models.MfaRecoveryCodes { + val apiPath = "/account/mfa/recovery-codes" + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.MfaRecoveryCodes = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.MfaRecoveryCodes.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.MfaRecoveryCodes::class.java, + converter, + ) + } + + + /** + * Generate recovery codes as backup for MFA flow. It's recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. + * + * @return [io.appwrite.models.MfaRecoveryCodes] + */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `CreateMFARecoveryCodes` instead.", + replaceWith = ReplaceWith("io.appwrite.services.CreateMFARecoveryCodes"), + since = "1.8.0" + ) suspend fun createMfaRecoveryCodes( ): io.appwrite.models.MfaRecoveryCodes { val apiPath = "/account/mfa/recovery-codes" @@ -605,11 +886,45 @@ class Account(client: Client) : Service(client) { } + /** + * Generate recovery codes as backup for MFA flow. It's recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. + * + * @return [io.appwrite.models.MfaRecoveryCodes] + */ + suspend fun createMFARecoveryCodes( + ): io.appwrite.models.MfaRecoveryCodes { + val apiPath = "/account/mfa/recovery-codes" + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.MfaRecoveryCodes = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.MfaRecoveryCodes.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.MfaRecoveryCodes::class.java, + converter, + ) + } + + /** * Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes. * * @return [io.appwrite.models.MfaRecoveryCodes] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `UpdateMFARecoveryCodes` instead.", + replaceWith = ReplaceWith("io.appwrite.services.UpdateMFARecoveryCodes"), + since = "1.8.0" + ) suspend fun updateMfaRecoveryCodes( ): io.appwrite.models.MfaRecoveryCodes { val apiPath = "/account/mfa/recovery-codes" @@ -634,6 +949,35 @@ class Account(client: Client) : Service(client) { } + /** + * Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes. + * + * @return [io.appwrite.models.MfaRecoveryCodes] + */ + suspend fun updateMFARecoveryCodes( + ): io.appwrite.models.MfaRecoveryCodes { + val apiPath = "/account/mfa/recovery-codes" + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.MfaRecoveryCodes = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.MfaRecoveryCodes.from(map = it as Map) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.MfaRecoveryCodes::class.java, + converter, + ) + } + + /** * Update currently logged in user account name. * @@ -735,7 +1079,7 @@ class Account(client: Client) : Service(client) { ) /** - * 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](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) endpoint to send a confirmation SMS. + * 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](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) 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. @@ -872,7 +1216,7 @@ class Account(client: Client) : Service(client) { ) /** - * 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](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) 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](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) 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. @@ -907,7 +1251,9 @@ class Account(client: Client) : Service(client) { /** - * 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](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) 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](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) 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. @@ -1026,7 +1372,9 @@ class Account(client: Client) : Service(client) { /** - * Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user. + * + * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * @param email User email. * @param password User password. Must be at least 8 chars. @@ -1099,7 +1447,12 @@ class Account(client: Client) : Service(client) { /** - * 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](https://appwrite.io/docs/authentication-security#limits). + * 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](https://appwrite.io/docs/authentication-security#limits). + * * * @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom. * @param success URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's 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. @@ -1244,7 +1597,7 @@ class Account(client: Client) : Service(client) { /** - * 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] @@ -1275,7 +1628,7 @@ class Account(client: Client) : Service(client) { /** - * Use this endpoint to extend a session's length. Extending a session is useful when session expiry is short. If the session was created using an OAuth provider, this endpoint refreshes the access token from the provider. + * Use this endpoint to extend a session's length. Extending a session is useful when session expiry is short. If the session was created using an OAuth provider, this endpoint refreshes the access token from the provider. * * @param sessionId Session ID. Use the string 'current' to update the current device session. * @return [io.appwrite.models.Session] @@ -1307,7 +1660,7 @@ class Account(client: Client) : Service(client) { /** - * Logout the user. Use 'current' as the session ID to logout on this device, use a session ID to logout on another device. If you're looking to logout the user on all devices, use [Delete Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) instead. + * Logout the user. Use 'current' as the session ID to logout on this device, use a session ID to logout on another device. If you're looking to logout the user on all devices, use [Delete Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) instead. * * @param sessionId Session ID. Use the string 'current' to delete the current device session. * @return [Any] @@ -1413,7 +1766,7 @@ class Account(client: Client) : Service(client) { /** - * Update the currently logged in user's push notification target. You can modify the target's identifier (device token) and provider ID (token, email, phone etc.). The target must exist and belong to the current user. If you change the provider ID, notifications will be sent through the new messaging provider instead. + * Update the currently logged in user's push notification target. You can modify the target's identifier (device token) and provider ID (token, email, phone etc.). The target must exist and belong to the current user. If you change the provider ID, notifications will be sent through the new messaging provider instead. * * @param targetId Target ID. * @param identifier The target identifier (token, email, phone etc.) @@ -1475,7 +1828,9 @@ class Account(client: Client) : Service(client) { /** - * Sends the user an email with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's email is valid for 15 minutes.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * Sends the user an email with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's email is valid for 15 minutes. + * + * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * @param userId User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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. @@ -1514,7 +1869,10 @@ class Account(client: Client) : Service(client) { /** - * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. + * + * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * * * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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. @@ -1556,7 +1914,11 @@ class Account(client: Client) : Service(client) { /** - * Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. + * + * If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint. + * + * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom. * @param success URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's 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. @@ -1628,7 +1990,9 @@ class Account(client: Client) : Service(client) { /** - * Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes.A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes. + * + * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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. @@ -1663,7 +2027,10 @@ class Account(client: Client) : Service(client) { /** - * 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](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). 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](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). 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] @@ -1730,7 +2097,7 @@ class Account(client: Client) : Service(client) { /** - * 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](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone) endpoint. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification). 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](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone) endpoint. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification). The verification code sent to the user's phone number is valid for 15 minutes. * * @return [io.appwrite.models.Token] */ @@ -1759,7 +2126,7 @@ class Account(client: Client) : Service(client) { /** - * 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. diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt index 55406cc..4741d10 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -18,7 +18,9 @@ import java.io.File class Avatars(client: Client) : Service(client) { /** - * 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](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) 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](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) 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. @@ -52,7 +54,10 @@ class Avatars(client: Client) : Service(client) { /** - * 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, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro, rupay. * @param width Image width. Pass an integer between 0 to 2000. Defaults to 100. @@ -86,7 +91,9 @@ class Avatars(client: Client) : Service(client) { /** - * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote website URL.This endpoint does not follow HTTP redirects. + * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote website URL. + * + * This endpoint does not follow HTTP redirects. * * @param url Website URL which you want to fetch the favicon from. * @return [ByteArray] @@ -110,7 +117,10 @@ class Avatars(client: Client) : Service(client) { /** - * 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](https://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](https://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. @@ -144,7 +154,11 @@ class Avatars(client: Client) : Service(client) { /** - * 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.This endpoint does not follow HTTP redirects. + * 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. + * + * This endpoint does not follow HTTP redirects. * * @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. @@ -175,7 +189,12 @@ class Avatars(client: Client) : Service(client) { /** - * 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. @@ -210,6 +229,7 @@ class Avatars(client: Client) : Service(client) { /** * 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. diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index 9a6fc37..059ce2b 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -16,7 +16,7 @@ import java.io.File class Databases(client: Client) : Service(client) { /** - * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. + * 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). @@ -24,8 +24,8 @@ class Databases(client: Client) : Service(client) { * @return [io.appwrite.models.DocumentList] */ @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `TablesDb.listRows` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDb.listRows"), + message = "This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.listRows"), since = "1.8.0" ) @JvmOverloads @@ -67,8 +67,8 @@ class Databases(client: Client) : Service(client) { * @return [io.appwrite.models.DocumentList] */ @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `TablesDb.listRows` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDb.listRows"), + message = "This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.listRows"), since = "1.8.0" ) @JvmOverloads @@ -95,8 +95,8 @@ class Databases(client: Client) : Service(client) { * @return [io.appwrite.models.Document] */ @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `TablesDb.createRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDb.createRow"), + message = "This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.createRow"), since = "1.8.0" ) @JvmOverloads @@ -145,8 +145,8 @@ class Databases(client: Client) : Service(client) { * @return [io.appwrite.models.Document] */ @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `TablesDb.createRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDb.createRow"), + message = "This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.createRow"), since = "1.8.0" ) @JvmOverloads @@ -176,8 +176,8 @@ class Databases(client: Client) : Service(client) { * @return [io.appwrite.models.Document] */ @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `TablesDb.getRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDb.getRow"), + message = "This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.getRow"), since = "1.8.0" ) @JvmOverloads @@ -222,8 +222,8 @@ class Databases(client: Client) : Service(client) { * @return [io.appwrite.models.Document] */ @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `TablesDb.getRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDb.getRow"), + message = "This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.getRow"), since = "1.8.0" ) @JvmOverloads @@ -252,8 +252,8 @@ class Databases(client: Client) : Service(client) { * @return [io.appwrite.models.Document] */ @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `TablesDb.upsertRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDb.upsertRow"), + message = "This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.upsertRow"), since = "1.8.0" ) @JvmOverloads @@ -302,8 +302,8 @@ class Databases(client: Client) : Service(client) { * @return [io.appwrite.models.Document] */ @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `TablesDb.upsertRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDb.upsertRow"), + message = "This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.upsertRow"), since = "1.8.0" ) @JvmOverloads @@ -334,8 +334,8 @@ class Databases(client: Client) : Service(client) { * @return [io.appwrite.models.Document] */ @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `TablesDb.updateRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDb.updateRow"), + message = "This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.updateRow"), since = "1.8.0" ) @JvmOverloads @@ -384,8 +384,8 @@ class Databases(client: Client) : Service(client) { * @return [io.appwrite.models.Document] */ @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `TablesDb.updateRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDb.updateRow"), + message = "This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.updateRow"), since = "1.8.0" ) @JvmOverloads @@ -414,8 +414,8 @@ class Databases(client: Client) : Service(client) { * @return [Any] */ @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `TablesDb.deleteRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDb.deleteRow"), + message = "This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.deleteRow"), since = "1.8.0" ) suspend fun deleteDocument( @@ -455,8 +455,8 @@ class Databases(client: Client) : Service(client) { * @return [io.appwrite.models.Document] */ @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `TablesDb.decrementRowColumn` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDb.decrementRowColumn"), + message = "This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.decrementRowColumn"), since = "1.8.0" ) @JvmOverloads @@ -508,8 +508,8 @@ class Databases(client: Client) : Service(client) { * @return [io.appwrite.models.Document] */ @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `TablesDb.decrementRowColumn` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDb.decrementRowColumn"), + message = "This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.decrementRowColumn"), since = "1.8.0" ) @JvmOverloads @@ -543,8 +543,8 @@ class Databases(client: Client) : Service(client) { * @return [io.appwrite.models.Document] */ @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `TablesDb.incrementRowColumn` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDb.incrementRowColumn"), + message = "This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.incrementRowColumn"), since = "1.8.0" ) @JvmOverloads @@ -596,8 +596,8 @@ class Databases(client: Client) : Service(client) { * @return [io.appwrite.models.Document] */ @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `TablesDb.incrementRowColumn` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDb.incrementRowColumn"), + message = "This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.incrementRowColumn"), since = "1.8.0" ) @JvmOverloads diff --git a/library/src/main/java/io/appwrite/services/Locale.kt b/library/src/main/java/io/appwrite/services/Locale.kt index a6319b6..bc48d1b 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -11,12 +11,14 @@ import okhttp3.Cookie import java.io.File /** - * The Locale service allows you to customize your app based on your users' location. + * The Locale service allows you to customize your app based on your users' location. **/ class Locale(client: Client) : Service(client) { /** - * 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] */ diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index 3b0323a..df24488 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -56,7 +56,14 @@ class Storage(client: Client) : Service(client) { /** - * Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](https://appwrite.io/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](https://appwrite.io/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](https://appwrite.io/docs/server/storage#createBucket). * @param fileId File ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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. @@ -209,7 +216,7 @@ class Storage(client: Client) : Service(client) { /** - * 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](https://appwrite.io/docs/server/storage#createBucket). * @param fileId File ID. @@ -304,7 +311,7 @@ class Storage(client: Client) : Service(client) { /** - * 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](https://appwrite.io/docs/server/storage#createBucket). * @param fileId File ID. diff --git a/library/src/main/java/io/appwrite/services/TablesDb.kt b/library/src/main/java/io/appwrite/services/TablesDb.kt index 825f18d..73e0342 100644 --- a/library/src/main/java/io/appwrite/services/TablesDb.kt +++ b/library/src/main/java/io/appwrite/services/TablesDb.kt @@ -13,13 +13,13 @@ import java.io.File /** * **/ -class TablesDb(client: Client) : Service(client) { +class TablesDB(client: Client) : Service(client) { /** - * Get a list of all the user's rows in a given table. You can use the query params to filter your results. + * Get a list of all the user's rows in a given table. You can use the query params to filter your results. * * @param databaseId Database ID. - * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). + * @param tableId Table ID. You can create a new table using the TableDB service [server integration](https://appwrite.io/docs/server/tablesdbdb#tablesdbCreate). * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.RowList] */ @@ -57,7 +57,7 @@ class TablesDb(client: Client) : Service(client) { * Get a list of all the user's rows in a given table. You can use the query params to filter your results. * * @param databaseId Database ID. - * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). + * @param tableId Table ID. You can create a new table using the TableDB service [server integration](https://appwrite.io/docs/server/tablesdbdb#tablesdbCreate). * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.RowList] */ @@ -75,10 +75,10 @@ class TablesDb(client: Client) : Service(client) { ) /** - * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. + * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. * * @param databaseId Database ID. - * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). Make sure to define columns before creating rows. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows. * @param rowId Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 Row data as JSON object. * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). @@ -120,10 +120,10 @@ class TablesDb(client: Client) : Service(client) { } /** - * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. + * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. * * @param databaseId Database ID. - * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). Make sure to define columns before creating rows. + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows. * @param rowId Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 Row data as JSON object. * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). @@ -150,7 +150,7 @@ class TablesDb(client: Client) : Service(client) { * Get a row by its unique ID. This endpoint response returns a JSON object with the row data. * * @param databaseId Database ID. - * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). * @param rowId Row ID. * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.Row] @@ -191,7 +191,7 @@ class TablesDb(client: Client) : Service(client) { * Get a row by its unique ID. This endpoint response returns a JSON object with the row data. * * @param databaseId Database ID. - * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). * @param rowId Row ID. * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.Row] @@ -212,7 +212,7 @@ class TablesDb(client: Client) : Service(client) { ) /** - * Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. + * Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. * * @param databaseId Database ID. * @param tableId Table ID. @@ -257,7 +257,7 @@ class TablesDb(client: Client) : Service(client) { } /** - * Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. + * Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console. * * @param databaseId Database ID. * @param tableId Table ID. @@ -359,7 +359,7 @@ class TablesDb(client: Client) : Service(client) { * Delete a row by its unique ID. * * @param databaseId Database ID. - * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). + * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). * @param rowId Row ID. * @return [Any] */ diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 2756a5a..0ca03cb 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -174,7 +174,7 @@ class Teams(client: Client) : Service(client) { ) /** - * Update the team's name by its unique ID. + * Update the team's name by its unique ID. * * @param teamId Team ID. * @param name New team name. Max length: 128 chars. @@ -253,7 +253,7 @@ class Teams(client: Client) : Service(client) { /** - * Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint. Hide sensitive attributes from the response by toggling membership privacy in the Console. + * Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint. Hide sensitive attributes from the response by toggling membership privacy in the Console. * * @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/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm, roles @@ -291,7 +291,14 @@ class Teams(client: Client) : Service(client) { /** - * Invite a new member to join your team. Provide an ID for existing users, or invite unregistered users using an email or phone number. If initiated from a Client SDK, Appwrite will send an email or sms with a link to join the team to the invited user, and an account will be created for them if one doesn't exist. If initiated from a Server SDK, the new member will be added automatically to the team.You only need to provide one of a user ID, email, or phone number. Appwrite will prioritize accepting the user ID > email > phone number if you provide more than one of these parameters.Use the `url` parameter to redirect the user from the invitation email to your app. After the user is redirected, use the [Update Team Membership Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) 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) Appwrite will accept the only redirect URLs under the domains you have added as a platform on the Appwrite Console. + * Invite a new member to join your team. Provide an ID for existing users, or invite unregistered users using an email or phone number. If initiated from a Client SDK, Appwrite will send an email or sms with a link to join the team to the invited user, and an account will be created for them if one doesn't exist. If initiated from a Server SDK, the new member will be added automatically to the team. + * + * You only need to provide one of a user ID, email, or phone number. Appwrite will prioritize accepting the user ID > email > phone number if you provide more than one of these parameters. + * + * Use the `url` parameter to redirect the user from the invitation email to your app. After the user is redirected, use the [Update Team Membership Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) 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) Appwrite will accept the only redirect URLs under the domains you have added as a platform on the Appwrite Console. + * * * @param teamId Team ID. * @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](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. @@ -377,6 +384,7 @@ class Teams(client: Client) : Service(client) { /** * 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](https://appwrite.io/docs/permissions). + * * * @param teamId Team ID. * @param membershipId Membership ID. @@ -444,7 +452,10 @@ class Teams(client: Client) : Service(client) { /** - * 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. @@ -485,7 +496,7 @@ class Teams(client: Client) : Service(client) { /** - * Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in [user preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). + * Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in [user preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). * * @param teamId Team ID. * @return [io.appwrite.models.Preferences] @@ -530,7 +541,7 @@ class Teams(client: Client) : Service(client) { ) /** - * Update the team's preferences by its unique ID. The object you pass is stored as is and replaces any previous value. The maximum allowed prefs size is 64kB and throws an error if exceeded. + * Update the team's preferences by its unique ID. The object you pass is stored as is and replaces any previous value. The maximum allowed prefs size is 64kB and throws an error if exceeded. * * @param teamId Team ID. * @param prefs Prefs key-value JSON object. From 0542a8a638d7800aa4a62bfd0fd6c4d1024fa4fb Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Sat, 23 Aug 2025 20:09:11 +1200 Subject: [PATCH 115/118] Add 1.8.x support --- library/src/main/java/io/appwrite/models/Execution.kt | 8 ++++++++ library/src/main/java/io/appwrite/services/Account.kt | 9 +++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/library/src/main/java/io/appwrite/models/Execution.kt b/library/src/main/java/io/appwrite/models/Execution.kt index 216e146..c1525bc 100644 --- a/library/src/main/java/io/appwrite/models/Execution.kt +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -37,6 +37,12 @@ data class Execution( @SerializedName("functionId") val functionId: String, + /** + * Function's deployment ID used to create the execution. + */ + @SerializedName("deploymentId") + val deploymentId: String, + /** * The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. */ @@ -116,6 +122,7 @@ data class Execution( "\$updatedAt" to updatedAt as Any, "\$permissions" to permissions as Any, "functionId" to functionId as Any, + "deploymentId" to deploymentId as Any, "trigger" to trigger as Any, "status" to status as Any, "requestMethod" to requestMethod as Any, @@ -141,6 +148,7 @@ data class Execution( updatedAt = map["\$updatedAt"] as String, permissions = map["\$permissions"] as List, functionId = map["functionId"] as String, + deploymentId = map["deploymentId"] as String, trigger = map["trigger"] as String, status = map["status"] as String, requestMethod = map["requestMethod"] as String, diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 3a042ba..0af63c7 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -1828,11 +1828,12 @@ class Account(client: Client) : Service(client) { /** - * Sends the user an email with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's email is valid for 15 minutes. + * Sends the user an email with a secret key for creating a session. If the email address has never been used, a **new account is created** using the provided `userId`. Otherwise, if the email address is already attached to an account, the **user ID is ignored**. Then, the user will receive an email with the one-time password. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's email is valid for 15 minutes. * * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * * - * @param userId User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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 User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored. * @param email User email. * @param phrase Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. * @return [io.appwrite.models.Token] @@ -1874,7 +1875,7 @@ class Account(client: Client) : Service(client) { * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * - * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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 a custom ID or generate a random ID with `ID.unique()`. 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. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored. * @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. * @param phrase Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. @@ -1994,7 +1995,7 @@ class Account(client: Client) : Service(client) { * * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * - * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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 a custom ID or generate a random ID with `ID.unique()`. 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. If the phone number has never been used, a new account is created using the provided userId. Otherwise, if the phone number is already attached to an account, the user ID is ignored. * @param phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. * @return [io.appwrite.models.Token] */ From a769fb1fbbf421ec12f1a2efeae53a7a1a89c541 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Sat, 23 Aug 2025 22:14:55 +1200 Subject: [PATCH 116/118] Add 1.8.x support --- .../main/java/io/appwrite/models/Execution.kt | 4 +- .../main/java/io/appwrite/models/Locale.kt | 2 +- .../main/java/io/appwrite/services/Account.kt | 100 +++++++++--------- .../main/java/io/appwrite/services/Avatars.kt | 42 ++++---- .../java/io/appwrite/services/Databases.kt | 4 +- .../java/io/appwrite/services/Functions.kt | 2 +- .../main/java/io/appwrite/services/Graphql.kt | 2 +- .../main/java/io/appwrite/services/Locale.kt | 6 +- .../java/io/appwrite/services/Messaging.kt | 2 +- .../main/java/io/appwrite/services/Storage.kt | 16 +-- .../java/io/appwrite/services/TablesDb.kt | 4 +- .../main/java/io/appwrite/services/Teams.kt | 30 +++--- 12 files changed, 108 insertions(+), 106 deletions(-) diff --git a/library/src/main/java/io/appwrite/models/Execution.kt b/library/src/main/java/io/appwrite/models/Execution.kt index c1525bc..8b395c6 100644 --- a/library/src/main/java/io/appwrite/models/Execution.kt +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -20,7 +20,7 @@ data class Execution( val createdAt: String, /** - * Execution upate date in ISO 8601 format. + * Execution update date in ISO 8601 format. */ @SerializedName("\$updatedAt") val updatedAt: String, @@ -38,7 +38,7 @@ data class Execution( val functionId: String, /** - * Function's deployment ID used to create the execution. + * Function's deployment ID used to create the execution. */ @SerializedName("deploymentId") val deploymentId: String, diff --git a/library/src/main/java/io/appwrite/models/Locale.kt b/library/src/main/java/io/appwrite/models/Locale.kt index abe4a0e..93d28d4 100644 --- a/library/src/main/java/io/appwrite/models/Locale.kt +++ b/library/src/main/java/io/appwrite/models/Locale.kt @@ -26,7 +26,7 @@ data class Locale( 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. + * 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, diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 0af63c7..1c3509d 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -16,7 +16,7 @@ import java.io.File /** * The Account service allows you to authenticate and manage a user account. -**/ + */ class Account(client: Client) : Service(client) { /** @@ -126,8 +126,8 @@ class Account(client: Client) : Service(client) { /** * 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. - * + * 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. @@ -162,7 +162,9 @@ class Account(client: Client) : Service(client) { } /** - * 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. + * 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. @@ -351,8 +353,8 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.MfaType] */ @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `CreateMFAAuthenticator` instead.", - replaceWith = ReplaceWith("io.appwrite.services.CreateMFAAuthenticator"), + message = "This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Account.createMFAAuthenticator"), since = "1.8.0" ) suspend fun createMfaAuthenticator( @@ -421,8 +423,8 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.User] */ @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `UpdateMFAAuthenticator` instead.", - replaceWith = ReplaceWith("io.appwrite.services.UpdateMFAAuthenticator"), + message = "This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Account.updateMFAAuthenticator"), since = "1.8.0" ) suspend fun updateMfaAuthenticator( @@ -461,8 +463,8 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.User] */ @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `UpdateMFAAuthenticator` instead.", - replaceWith = ReplaceWith("io.appwrite.services.UpdateMFAAuthenticator"), + message = "This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Account.updateMFAAuthenticator"), since = "1.8.0" ) @Throws(AppwriteException::class) @@ -534,8 +536,8 @@ class Account(client: Client) : Service(client) { * @return [Any] */ @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `DeleteMFAAuthenticator` instead.", - replaceWith = ReplaceWith("io.appwrite.services.DeleteMFAAuthenticator"), + message = "This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Account.deleteMFAAuthenticator"), since = "1.8.0" ) suspend fun deleteMfaAuthenticator( @@ -593,8 +595,8 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.MfaChallenge] */ @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `CreateMFAChallenge` instead.", - replaceWith = ReplaceWith("io.appwrite.services.CreateMFAChallenge"), + message = "This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Account.createMFAChallenge"), since = "1.8.0" ) suspend fun createMfaChallenge( @@ -663,8 +665,8 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.Session] */ @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `UpdateMFAChallenge` instead.", - replaceWith = ReplaceWith("io.appwrite.services.UpdateMFAChallenge"), + message = "This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Account.updateMFAChallenge"), since = "1.8.0" ) suspend fun updateMfaChallenge( @@ -736,8 +738,8 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.MfaFactors] */ @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `ListMFAFactors` instead.", - replaceWith = ReplaceWith("io.appwrite.services.ListMFAFactors"), + message = "This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Account.listMFAFactors"), since = "1.8.0" ) suspend fun listMfaFactors( @@ -797,8 +799,8 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.MfaRecoveryCodes] */ @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `GetMFARecoveryCodes` instead.", - replaceWith = ReplaceWith("io.appwrite.services.GetMFARecoveryCodes"), + message = "This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Account.getMFARecoveryCodes"), since = "1.8.0" ) suspend fun getMfaRecoveryCodes( @@ -858,8 +860,8 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.MfaRecoveryCodes] */ @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `CreateMFARecoveryCodes` instead.", - replaceWith = ReplaceWith("io.appwrite.services.CreateMFARecoveryCodes"), + message = "This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Account.createMFARecoveryCodes"), since = "1.8.0" ) suspend fun createMfaRecoveryCodes( @@ -921,8 +923,8 @@ class Account(client: Client) : Service(client) { * @return [io.appwrite.models.MfaRecoveryCodes] */ @Deprecated( - message = "This API has been deprecated since 1.8.0. Please use `UpdateMFARecoveryCodes` instead.", - replaceWith = ReplaceWith("io.appwrite.services.UpdateMFARecoveryCodes"), + message = "This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Account.updateMFARecoveryCodes"), since = "1.8.0" ) suspend fun updateMfaRecoveryCodes( @@ -1114,7 +1116,7 @@ class Account(client: Client) : Service(client) { } /** - * 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](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) endpoint to send a confirmation SMS. + * 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](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) 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. @@ -1252,8 +1254,8 @@ class Account(client: Client) : Service(client) { /** * 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](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) 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. + * + * 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. @@ -1373,8 +1375,8 @@ class Account(client: Client) : Service(client) { /** * Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user. - * - * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * + * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * @param email User email. * @param password User password. Must be at least 8 chars. @@ -1448,11 +1450,11 @@ class Account(client: Client) : Service(client) { /** * 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](https://appwrite.io/docs/authentication-security#limits). - * + * + * 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](https://appwrite.io/docs/authentication-security#limits). + * * * @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom. * @param success URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's 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. @@ -1829,9 +1831,9 @@ class Account(client: Client) : Service(client) { /** * Sends the user an email with a secret key for creating a session. If the email address has never been used, a **new account is created** using the provided `userId`. Otherwise, if the email address is already attached to an account, the **user ID is ignored**. Then, the user will receive an email with the one-time password. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's email is valid for 15 minutes. - * - * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). - * + * + * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * * * @param userId User ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored. * @param email User email. @@ -1871,9 +1873,9 @@ class Account(client: Client) : Service(client) { /** * Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. - * - * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). - * + * + * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * * * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored. * @param email User email. @@ -1916,10 +1918,10 @@ class Account(client: Client) : Service(client) { /** * Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. - * - * If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint. - * - * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * + * If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint. + * + * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom. * @param success URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's 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. @@ -1992,8 +1994,8 @@ class Account(client: Client) : Service(client) { /** * Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes. - * - * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). + * + * A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). * * @param userId Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. 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. If the phone number has never been used, a new account is created using the provided userId. Otherwise, if the phone number is already attached to an account, the user ID is ignored. * @param phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. @@ -2029,9 +2031,9 @@ class Account(client: Client) : Service(client) { /** * 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](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). 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. - * + * + * 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] diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt index 4741d10..ed7e7fa 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -14,13 +14,13 @@ import java.io.File /** * The Avatars service aims to help you complete everyday tasks related to your app image, icons, and avatars. -**/ + */ class Avatars(client: Client) : Service(client) { /** * 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](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) 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. + * + * 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. @@ -55,9 +55,9 @@ class Avatars(client: Client) : Service(client) { /** * 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. - * + * + * 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, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro, rupay. * @param width Image width. Pass an integer between 0 to 2000. Defaults to 100. @@ -92,8 +92,8 @@ class Avatars(client: Client) : Service(client) { /** * Use this endpoint to fetch the favorite icon (AKA favicon) of any remote website URL. - * - * This endpoint does not follow HTTP redirects. + * + * This endpoint does not follow HTTP redirects. * * @param url Website URL which you want to fetch the favicon from. * @return [ByteArray] @@ -118,9 +118,9 @@ class Avatars(client: Client) : Service(client) { /** * 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](https://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. - * + * + * 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. @@ -155,10 +155,10 @@ class Avatars(client: Client) : Service(client) { /** * 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. - * - * This endpoint does not follow HTTP redirects. + * + * 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. + * + * This endpoint does not follow HTTP redirects. * * @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. @@ -190,11 +190,11 @@ class Avatars(client: Client) : Service(client) { /** * 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. - * + * + * 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. @@ -229,7 +229,7 @@ class Avatars(client: Client) : Service(client) { /** * 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. diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index 059ce2b..c8a7c92 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -12,7 +12,7 @@ import java.io.File /** * The Databases service allows you to create structured collections of documents, query and filter lists of documents -**/ + */ class Databases(client: Client) : Service(client) { /** @@ -59,7 +59,7 @@ class Databases(client: Client) : Service(client) { } /** - * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. + * 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). diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index b370448..b938581 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -12,7 +12,7 @@ import java.io.File /** * The Functions Service allows you view, create and manage your Cloud Functions. -**/ + */ class Functions(client: Client) : Service(client) { /** diff --git a/library/src/main/java/io/appwrite/services/Graphql.kt b/library/src/main/java/io/appwrite/services/Graphql.kt index fbb4f7d..895b9d6 100644 --- a/library/src/main/java/io/appwrite/services/Graphql.kt +++ b/library/src/main/java/io/appwrite/services/Graphql.kt @@ -12,7 +12,7 @@ import java.io.File /** * The GraphQL API allows you to query and mutate your Appwrite server using GraphQL. -**/ + */ class Graphql(client: Client) : Service(client) { /** diff --git a/library/src/main/java/io/appwrite/services/Locale.kt b/library/src/main/java/io/appwrite/services/Locale.kt index bc48d1b..aecc83a 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -12,13 +12,13 @@ import java.io.File /** * The Locale service allows you to customize your app based on your users' location. -**/ + */ class Locale(client: Client) : Service(client) { /** * 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)) + * + * ([IP Geolocation by DB-IP](https://db-ip.com)) * * @return [io.appwrite.models.Locale] */ diff --git a/library/src/main/java/io/appwrite/services/Messaging.kt b/library/src/main/java/io/appwrite/services/Messaging.kt index 8efd1a4..148618e 100644 --- a/library/src/main/java/io/appwrite/services/Messaging.kt +++ b/library/src/main/java/io/appwrite/services/Messaging.kt @@ -12,7 +12,7 @@ import java.io.File /** * The Messaging service allows you to send messages to any provider type (SMTP, push notification, SMS, etc.). -**/ + */ class Messaging(client: Client) : Service(client) { /** diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index df24488..daa79a4 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -14,7 +14,7 @@ import java.io.File /** * The Storage service allows you to manage your project files. -**/ + */ class Storage(client: Client) : Service(client) { /** @@ -57,13 +57,13 @@ class Storage(client: Client) : Service(client) { /** * Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](https://appwrite.io/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. - * + * + * 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](https://appwrite.io/docs/server/storage#createBucket). * @param fileId File ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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. diff --git a/library/src/main/java/io/appwrite/services/TablesDb.kt b/library/src/main/java/io/appwrite/services/TablesDb.kt index 73e0342..2cc40e3 100644 --- a/library/src/main/java/io/appwrite/services/TablesDb.kt +++ b/library/src/main/java/io/appwrite/services/TablesDb.kt @@ -12,7 +12,7 @@ import java.io.File /** * -**/ + */ class TablesDB(client: Client) : Service(client) { /** @@ -54,7 +54,7 @@ class TablesDB(client: Client) : Service(client) { } /** - * Get a list of all the user's rows in a given table. You can use the query params to filter your results. + * Get a list of all the user's rows in a given table. You can use the query params to filter your results. * * @param databaseId Database ID. * @param tableId Table ID. You can create a new table using the TableDB service [server integration](https://appwrite.io/docs/server/tablesdbdb#tablesdbCreate). diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 0ca03cb..54dcc3b 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -12,7 +12,7 @@ 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(client: Client) : Service(client) { /** @@ -209,7 +209,7 @@ class Teams(client: Client) : Service(client) { } /** - * Update the team's name by its unique ID. + * Update the team's name by its unique ID. * * @param teamId Team ID. * @param name New team name. Max length: 128 chars. @@ -292,13 +292,13 @@ class Teams(client: Client) : Service(client) { /** * Invite a new member to join your team. Provide an ID for existing users, or invite unregistered users using an email or phone number. If initiated from a Client SDK, Appwrite will send an email or sms with a link to join the team to the invited user, and an account will be created for them if one doesn't exist. If initiated from a Server SDK, the new member will be added automatically to the team. - * - * You only need to provide one of a user ID, email, or phone number. Appwrite will prioritize accepting the user ID > email > phone number if you provide more than one of these parameters. - * - * Use the `url` parameter to redirect the user from the invitation email to your app. After the user is redirected, use the [Update Team Membership Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) 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) Appwrite will accept the only redirect URLs under the domains you have added as a platform on the Appwrite Console. - * + * + * You only need to provide one of a user ID, email, or phone number. Appwrite will prioritize accepting the user ID > email > phone number if you provide more than one of these parameters. + * + * Use the `url` parameter to redirect the user from the invitation email to your app. After the user is redirected, use the [Update Team Membership Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) 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) Appwrite will accept the only redirect URLs under the domains you have added as a platform on the Appwrite Console. + * * * @param teamId Team ID. * @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](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. @@ -384,7 +384,7 @@ class Teams(client: Client) : Service(client) { /** * 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](https://appwrite.io/docs/permissions). - * + * * * @param teamId Team ID. * @param membershipId Membership ID. @@ -453,9 +453,9 @@ class Teams(client: Client) : Service(client) { /** * 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. - * + * + * If the request is successful, a session for the user is automatically created. + * * * @param teamId Team ID. * @param membershipId Membership ID. @@ -527,7 +527,7 @@ class Teams(client: Client) : Service(client) { } /** - * Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in [user preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). + * Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in [user preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs). * * @param teamId Team ID. * @return [io.appwrite.models.Preferences] @@ -576,7 +576,7 @@ class Teams(client: Client) : Service(client) { } /** - * Update the team's preferences by its unique ID. The object you pass is stored as is and replaces any previous value. The maximum allowed prefs size is 64kB and throws an error if exceeded. + * Update the team's preferences by its unique ID. The object you pass is stored as is and replaces any previous value. The maximum allowed prefs size is 64kB and throws an error if exceeded. * * @param teamId Team ID. * @param prefs Prefs key-value JSON object. From 2e63e5167d4f172ee087653ddc09c00a5bfcfdc6 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 26 Aug 2025 04:22:49 +1200 Subject: [PATCH 117/118] Fix docs --- .../{create-j-w-t.md => create-jwt.md} | 0 .../account/create-m-f-a-authenticator.md | 23 ------------------ .../java/account/create-m-f-a-challenge.md | 23 ------------------ .../account/create-m-f-a-recovery-codes.md | 18 -------------- ...r-l-token.md => create-magic-url-token.md} | 0 .../java/account/create-mfa-authenticator.md | 2 +- .../java/account/create-mfa-challenge.md | 2 +- .../java/account/create-mfa-recovery-codes.md | 2 +- ...2session.md => create-o-auth-2-session.md} | 0 ...auth2token.md => create-o-auth-2-token.md} | 0 .../account/delete-m-f-a-authenticator.md | 23 ------------------ .../java/account/delete-mfa-authenticator.md | 2 +- .../java/account/get-m-f-a-recovery-codes.md | 18 -------------- .../java/account/get-mfa-recovery-codes.md | 2 +- .../java/account/list-m-f-a-factors.md | 18 -------------- .../examples/java/account/list-mfa-factors.md | 2 +- .../account/update-m-f-a-authenticator.md | 24 ------------------- .../java/account/update-m-f-a-challenge.md | 23 ------------------ .../account/update-m-f-a-recovery-codes.md | 18 -------------- ...session.md => update-magic-url-session.md} | 0 .../java/account/update-mfa-authenticator.md | 2 +- .../java/account/update-mfa-challenge.md | 2 +- .../java/account/update-mfa-recovery-codes.md | 2 +- .../{update-m-f-a.md => update-mfa.md} | 0 .../java/avatars/{get-q-r.md => get-qr.md} | 0 ...-countries-e-u.md => list-countries-eu.md} | 0 .../{create-j-w-t.md => create-jwt.md} | 0 .../account/create-m-f-a-authenticator.md | 14 ----------- .../kotlin/account/create-m-f-a-challenge.md | 14 ----------- .../account/create-m-f-a-recovery-codes.md | 11 --------- ...r-l-token.md => create-magic-url-token.md} | 0 .../account/create-mfa-authenticator.md | 2 +- .../kotlin/account/create-mfa-challenge.md | 2 +- .../account/create-mfa-recovery-codes.md | 2 +- ...2session.md => create-o-auth-2-session.md} | 0 ...auth2token.md => create-o-auth-2-token.md} | 0 .../account/delete-m-f-a-authenticator.md | 14 ----------- .../account/delete-mfa-authenticator.md | 2 +- .../account/get-m-f-a-recovery-codes.md | 11 --------- .../kotlin/account/get-mfa-recovery-codes.md | 2 +- .../kotlin/account/list-m-f-a-factors.md | 11 --------- .../kotlin/account/list-mfa-factors.md | 2 +- .../account/update-m-f-a-authenticator.md | 15 ------------ .../kotlin/account/update-m-f-a-challenge.md | 14 ----------- .../account/update-m-f-a-recovery-codes.md | 11 --------- ...session.md => update-magic-url-session.md} | 0 .../account/update-mfa-authenticator.md | 2 +- .../kotlin/account/update-mfa-challenge.md | 2 +- .../account/update-mfa-recovery-codes.md | 2 +- .../{update-m-f-a.md => update-mfa.md} | 0 .../kotlin/avatars/{get-q-r.md => get-qr.md} | 0 ...-countries-e-u.md => list-countries-eu.md} | 0 52 files changed, 18 insertions(+), 321 deletions(-) rename docs/examples/java/account/{create-j-w-t.md => create-jwt.md} (100%) delete mode 100644 docs/examples/java/account/create-m-f-a-authenticator.md delete mode 100644 docs/examples/java/account/create-m-f-a-challenge.md delete mode 100644 docs/examples/java/account/create-m-f-a-recovery-codes.md rename docs/examples/java/account/{create-magic-u-r-l-token.md => create-magic-url-token.md} (100%) rename docs/examples/java/account/{create-o-auth2session.md => create-o-auth-2-session.md} (100%) rename docs/examples/java/account/{create-o-auth2token.md => create-o-auth-2-token.md} (100%) delete mode 100644 docs/examples/java/account/delete-m-f-a-authenticator.md delete mode 100644 docs/examples/java/account/get-m-f-a-recovery-codes.md delete mode 100644 docs/examples/java/account/list-m-f-a-factors.md delete mode 100644 docs/examples/java/account/update-m-f-a-authenticator.md delete mode 100644 docs/examples/java/account/update-m-f-a-challenge.md delete mode 100644 docs/examples/java/account/update-m-f-a-recovery-codes.md rename docs/examples/java/account/{update-magic-u-r-l-session.md => update-magic-url-session.md} (100%) rename docs/examples/java/account/{update-m-f-a.md => update-mfa.md} (100%) rename docs/examples/java/avatars/{get-q-r.md => get-qr.md} (100%) rename docs/examples/java/locale/{list-countries-e-u.md => list-countries-eu.md} (100%) rename docs/examples/kotlin/account/{create-j-w-t.md => create-jwt.md} (100%) delete mode 100644 docs/examples/kotlin/account/create-m-f-a-authenticator.md delete mode 100644 docs/examples/kotlin/account/create-m-f-a-challenge.md delete mode 100644 docs/examples/kotlin/account/create-m-f-a-recovery-codes.md rename docs/examples/kotlin/account/{create-magic-u-r-l-token.md => create-magic-url-token.md} (100%) rename docs/examples/kotlin/account/{create-o-auth2session.md => create-o-auth-2-session.md} (100%) rename docs/examples/kotlin/account/{create-o-auth2token.md => create-o-auth-2-token.md} (100%) delete mode 100644 docs/examples/kotlin/account/delete-m-f-a-authenticator.md delete mode 100644 docs/examples/kotlin/account/get-m-f-a-recovery-codes.md delete mode 100644 docs/examples/kotlin/account/list-m-f-a-factors.md delete mode 100644 docs/examples/kotlin/account/update-m-f-a-authenticator.md delete mode 100644 docs/examples/kotlin/account/update-m-f-a-challenge.md delete mode 100644 docs/examples/kotlin/account/update-m-f-a-recovery-codes.md rename docs/examples/kotlin/account/{update-magic-u-r-l-session.md => update-magic-url-session.md} (100%) rename docs/examples/kotlin/account/{update-m-f-a.md => update-mfa.md} (100%) rename docs/examples/kotlin/avatars/{get-q-r.md => get-qr.md} (100%) rename docs/examples/kotlin/locale/{list-countries-e-u.md => list-countries-eu.md} (100%) diff --git a/docs/examples/java/account/create-j-w-t.md b/docs/examples/java/account/create-jwt.md similarity index 100% rename from docs/examples/java/account/create-j-w-t.md rename to docs/examples/java/account/create-jwt.md diff --git a/docs/examples/java/account/create-m-f-a-authenticator.md b/docs/examples/java/account/create-m-f-a-authenticator.md deleted file mode 100644 index d236f46..0000000 --- a/docs/examples/java/account/create-m-f-a-authenticator.md +++ /dev/null @@ -1,23 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Account; -import io.appwrite.enums.AuthenticatorType; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Account account = new Account(client); - -account.createMFAAuthenticator( - AuthenticatorType.TOTP, // type - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - diff --git a/docs/examples/java/account/create-m-f-a-challenge.md b/docs/examples/java/account/create-m-f-a-challenge.md deleted file mode 100644 index 222c0bd..0000000 --- a/docs/examples/java/account/create-m-f-a-challenge.md +++ /dev/null @@ -1,23 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Account; -import io.appwrite.enums.AuthenticationFactor; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Account account = new Account(client); - -account.createMFAChallenge( - AuthenticationFactor.EMAIL, // factor - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - diff --git a/docs/examples/java/account/create-m-f-a-recovery-codes.md b/docs/examples/java/account/create-m-f-a-recovery-codes.md deleted file mode 100644 index 792e086..0000000 --- a/docs/examples/java/account/create-m-f-a-recovery-codes.md +++ /dev/null @@ -1,18 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Account; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Account account = new Account(client); - -account.createMFARecoveryCodes(new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); -})); diff --git a/docs/examples/java/account/create-magic-u-r-l-token.md b/docs/examples/java/account/create-magic-url-token.md similarity index 100% rename from docs/examples/java/account/create-magic-u-r-l-token.md rename to docs/examples/java/account/create-magic-url-token.md diff --git a/docs/examples/java/account/create-mfa-authenticator.md b/docs/examples/java/account/create-mfa-authenticator.md index 54781f2..d236f46 100644 --- a/docs/examples/java/account/create-mfa-authenticator.md +++ b/docs/examples/java/account/create-mfa-authenticator.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); -account.createMfaAuthenticator( +account.createMFAAuthenticator( AuthenticatorType.TOTP, // type new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/account/create-mfa-challenge.md b/docs/examples/java/account/create-mfa-challenge.md index 87a56fe..222c0bd 100644 --- a/docs/examples/java/account/create-mfa-challenge.md +++ b/docs/examples/java/account/create-mfa-challenge.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); -account.createMfaChallenge( +account.createMFAChallenge( AuthenticationFactor.EMAIL, // factor new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/account/create-mfa-recovery-codes.md b/docs/examples/java/account/create-mfa-recovery-codes.md index ab50734..792e086 100644 --- a/docs/examples/java/account/create-mfa-recovery-codes.md +++ b/docs/examples/java/account/create-mfa-recovery-codes.md @@ -8,7 +8,7 @@ Client client = new Client(context) Account account = new Account(client); -account.createMfaRecoveryCodes(new CoroutineCallback<>((result, error) -> { +account.createMFARecoveryCodes(new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); return; diff --git a/docs/examples/java/account/create-o-auth2session.md b/docs/examples/java/account/create-o-auth-2-session.md similarity index 100% rename from docs/examples/java/account/create-o-auth2session.md rename to docs/examples/java/account/create-o-auth-2-session.md diff --git a/docs/examples/java/account/create-o-auth2token.md b/docs/examples/java/account/create-o-auth-2-token.md similarity index 100% rename from docs/examples/java/account/create-o-auth2token.md rename to docs/examples/java/account/create-o-auth-2-token.md diff --git a/docs/examples/java/account/delete-m-f-a-authenticator.md b/docs/examples/java/account/delete-m-f-a-authenticator.md deleted file mode 100644 index b5ff26c..0000000 --- a/docs/examples/java/account/delete-m-f-a-authenticator.md +++ /dev/null @@ -1,23 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Account; -import io.appwrite.enums.AuthenticatorType; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Account account = new Account(client); - -account.deleteMFAAuthenticator( - AuthenticatorType.TOTP, // type - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - diff --git a/docs/examples/java/account/delete-mfa-authenticator.md b/docs/examples/java/account/delete-mfa-authenticator.md index 4a9693b..b5ff26c 100644 --- a/docs/examples/java/account/delete-mfa-authenticator.md +++ b/docs/examples/java/account/delete-mfa-authenticator.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); -account.deleteMfaAuthenticator( +account.deleteMFAAuthenticator( AuthenticatorType.TOTP, // type new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/account/get-m-f-a-recovery-codes.md b/docs/examples/java/account/get-m-f-a-recovery-codes.md deleted file mode 100644 index 22bc1c1..0000000 --- a/docs/examples/java/account/get-m-f-a-recovery-codes.md +++ /dev/null @@ -1,18 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Account; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Account account = new Account(client); - -account.getMFARecoveryCodes(new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); -})); diff --git a/docs/examples/java/account/get-mfa-recovery-codes.md b/docs/examples/java/account/get-mfa-recovery-codes.md index 8274bb3..22bc1c1 100644 --- a/docs/examples/java/account/get-mfa-recovery-codes.md +++ b/docs/examples/java/account/get-mfa-recovery-codes.md @@ -8,7 +8,7 @@ Client client = new Client(context) Account account = new Account(client); -account.getMfaRecoveryCodes(new CoroutineCallback<>((result, error) -> { +account.getMFARecoveryCodes(new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); return; diff --git a/docs/examples/java/account/list-m-f-a-factors.md b/docs/examples/java/account/list-m-f-a-factors.md deleted file mode 100644 index 06f20e1..0000000 --- a/docs/examples/java/account/list-m-f-a-factors.md +++ /dev/null @@ -1,18 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Account; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Account account = new Account(client); - -account.listMFAFactors(new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); -})); diff --git a/docs/examples/java/account/list-mfa-factors.md b/docs/examples/java/account/list-mfa-factors.md index 9ea8331..06f20e1 100644 --- a/docs/examples/java/account/list-mfa-factors.md +++ b/docs/examples/java/account/list-mfa-factors.md @@ -8,7 +8,7 @@ Client client = new Client(context) Account account = new Account(client); -account.listMfaFactors(new CoroutineCallback<>((result, error) -> { +account.listMFAFactors(new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); return; diff --git a/docs/examples/java/account/update-m-f-a-authenticator.md b/docs/examples/java/account/update-m-f-a-authenticator.md deleted file mode 100644 index 00ddd46..0000000 --- a/docs/examples/java/account/update-m-f-a-authenticator.md +++ /dev/null @@ -1,24 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Account; -import io.appwrite.enums.AuthenticatorType; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Account account = new Account(client); - -account.updateMFAAuthenticator( - AuthenticatorType.TOTP, // type - "", // otp - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - diff --git a/docs/examples/java/account/update-m-f-a-challenge.md b/docs/examples/java/account/update-m-f-a-challenge.md deleted file mode 100644 index 10b5db4..0000000 --- a/docs/examples/java/account/update-m-f-a-challenge.md +++ /dev/null @@ -1,23 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Account; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Account account = new Account(client); - -account.updateMFAChallenge( - "", // challengeId - "", // otp - new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - Log.d("Appwrite", result.toString()); - }) -); - diff --git a/docs/examples/java/account/update-m-f-a-recovery-codes.md b/docs/examples/java/account/update-m-f-a-recovery-codes.md deleted file mode 100644 index c0d6c69..0000000 --- a/docs/examples/java/account/update-m-f-a-recovery-codes.md +++ /dev/null @@ -1,18 +0,0 @@ -import io.appwrite.Client; -import io.appwrite.coroutines.CoroutineCallback; -import io.appwrite.services.Account; - -Client client = new Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject(""); // Your project ID - -Account account = new Account(client); - -account.updateMFARecoveryCodes(new CoroutineCallback<>((result, error) -> { - if (error != null) { - error.printStackTrace(); - return; - } - - 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-url-session.md similarity index 100% rename from docs/examples/java/account/update-magic-u-r-l-session.md rename to docs/examples/java/account/update-magic-url-session.md diff --git a/docs/examples/java/account/update-mfa-authenticator.md b/docs/examples/java/account/update-mfa-authenticator.md index b8016e7..00ddd46 100644 --- a/docs/examples/java/account/update-mfa-authenticator.md +++ b/docs/examples/java/account/update-mfa-authenticator.md @@ -9,7 +9,7 @@ Client client = new Client(context) Account account = new Account(client); -account.updateMfaAuthenticator( +account.updateMFAAuthenticator( AuthenticatorType.TOTP, // type "", // otp new CoroutineCallback<>((result, error) -> { diff --git a/docs/examples/java/account/update-mfa-challenge.md b/docs/examples/java/account/update-mfa-challenge.md index c640150..10b5db4 100644 --- a/docs/examples/java/account/update-mfa-challenge.md +++ b/docs/examples/java/account/update-mfa-challenge.md @@ -8,7 +8,7 @@ Client client = new Client(context) Account account = new Account(client); -account.updateMfaChallenge( +account.updateMFAChallenge( "", // challengeId "", // otp new CoroutineCallback<>((result, error) -> { diff --git a/docs/examples/java/account/update-mfa-recovery-codes.md b/docs/examples/java/account/update-mfa-recovery-codes.md index 650ae24..c0d6c69 100644 --- a/docs/examples/java/account/update-mfa-recovery-codes.md +++ b/docs/examples/java/account/update-mfa-recovery-codes.md @@ -8,7 +8,7 @@ Client client = new Client(context) Account account = new Account(client); -account.updateMfaRecoveryCodes(new CoroutineCallback<>((result, error) -> { +account.updateMFARecoveryCodes(new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); return; diff --git a/docs/examples/java/account/update-m-f-a.md b/docs/examples/java/account/update-mfa.md similarity index 100% rename from docs/examples/java/account/update-m-f-a.md rename to docs/examples/java/account/update-mfa.md diff --git a/docs/examples/java/avatars/get-q-r.md b/docs/examples/java/avatars/get-qr.md similarity index 100% rename from docs/examples/java/avatars/get-q-r.md rename to docs/examples/java/avatars/get-qr.md diff --git a/docs/examples/java/locale/list-countries-e-u.md b/docs/examples/java/locale/list-countries-eu.md similarity index 100% rename from docs/examples/java/locale/list-countries-e-u.md rename to docs/examples/java/locale/list-countries-eu.md diff --git a/docs/examples/kotlin/account/create-j-w-t.md b/docs/examples/kotlin/account/create-jwt.md similarity index 100% rename from docs/examples/kotlin/account/create-j-w-t.md rename to docs/examples/kotlin/account/create-jwt.md diff --git a/docs/examples/kotlin/account/create-m-f-a-authenticator.md b/docs/examples/kotlin/account/create-m-f-a-authenticator.md deleted file mode 100644 index 934de1c..0000000 --- a/docs/examples/kotlin/account/create-m-f-a-authenticator.md +++ /dev/null @@ -1,14 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Account -import io.appwrite.enums.AuthenticatorType - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val account = Account(client) - -val result = account.createMFAAuthenticator( - type = AuthenticatorType.TOTP, -) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-m-f-a-challenge.md b/docs/examples/kotlin/account/create-m-f-a-challenge.md deleted file mode 100644 index f79c498..0000000 --- a/docs/examples/kotlin/account/create-m-f-a-challenge.md +++ /dev/null @@ -1,14 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Account -import io.appwrite.enums.AuthenticationFactor - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val account = Account(client) - -val result = account.createMFAChallenge( - factor = AuthenticationFactor.EMAIL, -) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-m-f-a-recovery-codes.md b/docs/examples/kotlin/account/create-m-f-a-recovery-codes.md deleted file mode 100644 index cc56966..0000000 --- a/docs/examples/kotlin/account/create-m-f-a-recovery-codes.md +++ /dev/null @@ -1,11 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Account - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val account = Account(client) - -val result = account.createMFARecoveryCodes() diff --git a/docs/examples/kotlin/account/create-magic-u-r-l-token.md b/docs/examples/kotlin/account/create-magic-url-token.md similarity index 100% rename from docs/examples/kotlin/account/create-magic-u-r-l-token.md rename to docs/examples/kotlin/account/create-magic-url-token.md diff --git a/docs/examples/kotlin/account/create-mfa-authenticator.md b/docs/examples/kotlin/account/create-mfa-authenticator.md index ffb2f2f..934de1c 100644 --- a/docs/examples/kotlin/account/create-mfa-authenticator.md +++ b/docs/examples/kotlin/account/create-mfa-authenticator.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) -val result = account.createMfaAuthenticator( +val result = account.createMFAAuthenticator( type = AuthenticatorType.TOTP, ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-mfa-challenge.md b/docs/examples/kotlin/account/create-mfa-challenge.md index 36b12d3..f79c498 100644 --- a/docs/examples/kotlin/account/create-mfa-challenge.md +++ b/docs/examples/kotlin/account/create-mfa-challenge.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) -val result = account.createMfaChallenge( +val result = account.createMFAChallenge( factor = AuthenticationFactor.EMAIL, ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-mfa-recovery-codes.md b/docs/examples/kotlin/account/create-mfa-recovery-codes.md index 974c8f2..cc56966 100644 --- a/docs/examples/kotlin/account/create-mfa-recovery-codes.md +++ b/docs/examples/kotlin/account/create-mfa-recovery-codes.md @@ -8,4 +8,4 @@ val client = Client(context) val account = Account(client) -val result = account.createMfaRecoveryCodes() +val result = account.createMFARecoveryCodes() diff --git a/docs/examples/kotlin/account/create-o-auth2session.md b/docs/examples/kotlin/account/create-o-auth-2-session.md similarity index 100% rename from docs/examples/kotlin/account/create-o-auth2session.md rename to docs/examples/kotlin/account/create-o-auth-2-session.md diff --git a/docs/examples/kotlin/account/create-o-auth2token.md b/docs/examples/kotlin/account/create-o-auth-2-token.md similarity index 100% rename from docs/examples/kotlin/account/create-o-auth2token.md rename to docs/examples/kotlin/account/create-o-auth-2-token.md diff --git a/docs/examples/kotlin/account/delete-m-f-a-authenticator.md b/docs/examples/kotlin/account/delete-m-f-a-authenticator.md deleted file mode 100644 index b140a11..0000000 --- a/docs/examples/kotlin/account/delete-m-f-a-authenticator.md +++ /dev/null @@ -1,14 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Account -import io.appwrite.enums.AuthenticatorType - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val account = Account(client) - -val result = account.deleteMFAAuthenticator( - type = AuthenticatorType.TOTP, -) \ No newline at end of file diff --git a/docs/examples/kotlin/account/delete-mfa-authenticator.md b/docs/examples/kotlin/account/delete-mfa-authenticator.md index 057e021..b140a11 100644 --- a/docs/examples/kotlin/account/delete-mfa-authenticator.md +++ b/docs/examples/kotlin/account/delete-mfa-authenticator.md @@ -9,6 +9,6 @@ val client = Client(context) val account = Account(client) -val result = account.deleteMfaAuthenticator( +val result = account.deleteMFAAuthenticator( type = AuthenticatorType.TOTP, ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/get-m-f-a-recovery-codes.md b/docs/examples/kotlin/account/get-m-f-a-recovery-codes.md deleted file mode 100644 index f9d3612..0000000 --- a/docs/examples/kotlin/account/get-m-f-a-recovery-codes.md +++ /dev/null @@ -1,11 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Account - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val account = Account(client) - -val result = account.getMFARecoveryCodes() diff --git a/docs/examples/kotlin/account/get-mfa-recovery-codes.md b/docs/examples/kotlin/account/get-mfa-recovery-codes.md index 6201658..f9d3612 100644 --- a/docs/examples/kotlin/account/get-mfa-recovery-codes.md +++ b/docs/examples/kotlin/account/get-mfa-recovery-codes.md @@ -8,4 +8,4 @@ val client = Client(context) val account = Account(client) -val result = account.getMfaRecoveryCodes() +val result = account.getMFARecoveryCodes() diff --git a/docs/examples/kotlin/account/list-m-f-a-factors.md b/docs/examples/kotlin/account/list-m-f-a-factors.md deleted file mode 100644 index 56d1c4d..0000000 --- a/docs/examples/kotlin/account/list-m-f-a-factors.md +++ /dev/null @@ -1,11 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Account - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val account = Account(client) - -val result = account.listMFAFactors() diff --git a/docs/examples/kotlin/account/list-mfa-factors.md b/docs/examples/kotlin/account/list-mfa-factors.md index 09119ab..56d1c4d 100644 --- a/docs/examples/kotlin/account/list-mfa-factors.md +++ b/docs/examples/kotlin/account/list-mfa-factors.md @@ -8,4 +8,4 @@ val client = Client(context) val account = Account(client) -val result = account.listMfaFactors() +val result = account.listMFAFactors() diff --git a/docs/examples/kotlin/account/update-m-f-a-authenticator.md b/docs/examples/kotlin/account/update-m-f-a-authenticator.md deleted file mode 100644 index 4f6ecd7..0000000 --- a/docs/examples/kotlin/account/update-m-f-a-authenticator.md +++ /dev/null @@ -1,15 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Account -import io.appwrite.enums.AuthenticatorType - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val account = Account(client) - -val result = account.updateMFAAuthenticator( - type = AuthenticatorType.TOTP, - otp = "", -) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-m-f-a-challenge.md b/docs/examples/kotlin/account/update-m-f-a-challenge.md deleted file mode 100644 index d5cbc1f..0000000 --- a/docs/examples/kotlin/account/update-m-f-a-challenge.md +++ /dev/null @@ -1,14 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Account - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val account = Account(client) - -val result = account.updateMFAChallenge( - challengeId = "", - otp = "", -) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-m-f-a-recovery-codes.md b/docs/examples/kotlin/account/update-m-f-a-recovery-codes.md deleted file mode 100644 index 0277ca7..0000000 --- a/docs/examples/kotlin/account/update-m-f-a-recovery-codes.md +++ /dev/null @@ -1,11 +0,0 @@ -import io.appwrite.Client -import io.appwrite.coroutines.CoroutineCallback -import io.appwrite.services.Account - -val client = Client(context) - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - -val account = Account(client) - -val result = account.updateMFARecoveryCodes() diff --git a/docs/examples/kotlin/account/update-magic-u-r-l-session.md b/docs/examples/kotlin/account/update-magic-url-session.md similarity index 100% rename from docs/examples/kotlin/account/update-magic-u-r-l-session.md rename to docs/examples/kotlin/account/update-magic-url-session.md diff --git a/docs/examples/kotlin/account/update-mfa-authenticator.md b/docs/examples/kotlin/account/update-mfa-authenticator.md index 987825e..4f6ecd7 100644 --- a/docs/examples/kotlin/account/update-mfa-authenticator.md +++ b/docs/examples/kotlin/account/update-mfa-authenticator.md @@ -9,7 +9,7 @@ val client = Client(context) val account = Account(client) -val result = account.updateMfaAuthenticator( +val result = account.updateMFAAuthenticator( type = AuthenticatorType.TOTP, otp = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-mfa-challenge.md b/docs/examples/kotlin/account/update-mfa-challenge.md index c7f8139..d5cbc1f 100644 --- a/docs/examples/kotlin/account/update-mfa-challenge.md +++ b/docs/examples/kotlin/account/update-mfa-challenge.md @@ -8,7 +8,7 @@ val client = Client(context) val account = Account(client) -val result = account.updateMfaChallenge( +val result = account.updateMFAChallenge( challengeId = "", otp = "", ) \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-mfa-recovery-codes.md b/docs/examples/kotlin/account/update-mfa-recovery-codes.md index c0ee3c3..0277ca7 100644 --- a/docs/examples/kotlin/account/update-mfa-recovery-codes.md +++ b/docs/examples/kotlin/account/update-mfa-recovery-codes.md @@ -8,4 +8,4 @@ val client = Client(context) val account = Account(client) -val result = account.updateMfaRecoveryCodes() +val result = account.updateMFARecoveryCodes() diff --git a/docs/examples/kotlin/account/update-m-f-a.md b/docs/examples/kotlin/account/update-mfa.md similarity index 100% rename from docs/examples/kotlin/account/update-m-f-a.md rename to docs/examples/kotlin/account/update-mfa.md diff --git a/docs/examples/kotlin/avatars/get-q-r.md b/docs/examples/kotlin/avatars/get-qr.md similarity index 100% rename from docs/examples/kotlin/avatars/get-q-r.md rename to docs/examples/kotlin/avatars/get-qr.md diff --git a/docs/examples/kotlin/locale/list-countries-e-u.md b/docs/examples/kotlin/locale/list-countries-eu.md similarity index 100% rename from docs/examples/kotlin/locale/list-countries-e-u.md rename to docs/examples/kotlin/locale/list-countries-eu.md From dc6ded9a8c219872f7508a5785a7e91769ffc360 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 26 Aug 2025 21:04:31 +1200 Subject: [PATCH 118/118] Fix deprecations --- .../main/java/io/appwrite/services/Account.kt | 30 +++++-------- .../java/io/appwrite/services/Databases.kt | 45 +++++++------------ 2 files changed, 25 insertions(+), 50 deletions(-) diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 1c3509d..d5ed63a 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -354,8 +354,7 @@ class Account(client: Client) : Service(client) { */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `Account.createMFAAuthenticator` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Account.createMFAAuthenticator"), - since = "1.8.0" + replaceWith = ReplaceWith("io.appwrite.services.Account.createMFAAuthenticator") ) suspend fun createMfaAuthenticator( type: io.appwrite.enums.AuthenticatorType, @@ -424,8 +423,7 @@ class Account(client: Client) : Service(client) { */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Account.updateMFAAuthenticator"), - since = "1.8.0" + replaceWith = ReplaceWith("io.appwrite.services.Account.updateMFAAuthenticator") ) suspend fun updateMfaAuthenticator( type: io.appwrite.enums.AuthenticatorType, @@ -464,8 +462,7 @@ class Account(client: Client) : Service(client) { */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `Account.updateMFAAuthenticator` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Account.updateMFAAuthenticator"), - since = "1.8.0" + replaceWith = ReplaceWith("io.appwrite.services.Account.updateMFAAuthenticator") ) @Throws(AppwriteException::class) suspend fun updateMfaAuthenticator( @@ -537,8 +534,7 @@ class Account(client: Client) : Service(client) { */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `Account.deleteMFAAuthenticator` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Account.deleteMFAAuthenticator"), - since = "1.8.0" + replaceWith = ReplaceWith("io.appwrite.services.Account.deleteMFAAuthenticator") ) suspend fun deleteMfaAuthenticator( type: io.appwrite.enums.AuthenticatorType, @@ -596,8 +592,7 @@ class Account(client: Client) : Service(client) { */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `Account.createMFAChallenge` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Account.createMFAChallenge"), - since = "1.8.0" + replaceWith = ReplaceWith("io.appwrite.services.Account.createMFAChallenge") ) suspend fun createMfaChallenge( factor: io.appwrite.enums.AuthenticationFactor, @@ -666,8 +661,7 @@ class Account(client: Client) : Service(client) { */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `Account.updateMFAChallenge` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Account.updateMFAChallenge"), - since = "1.8.0" + replaceWith = ReplaceWith("io.appwrite.services.Account.updateMFAChallenge") ) suspend fun updateMfaChallenge( challengeId: String, @@ -739,8 +733,7 @@ class Account(client: Client) : Service(client) { */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `Account.listMFAFactors` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Account.listMFAFactors"), - since = "1.8.0" + replaceWith = ReplaceWith("io.appwrite.services.Account.listMFAFactors") ) suspend fun listMfaFactors( ): io.appwrite.models.MfaFactors { @@ -800,8 +793,7 @@ class Account(client: Client) : Service(client) { */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `Account.getMFARecoveryCodes` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Account.getMFARecoveryCodes"), - since = "1.8.0" + replaceWith = ReplaceWith("io.appwrite.services.Account.getMFARecoveryCodes") ) suspend fun getMfaRecoveryCodes( ): io.appwrite.models.MfaRecoveryCodes { @@ -861,8 +853,7 @@ class Account(client: Client) : Service(client) { */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `Account.createMFARecoveryCodes` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Account.createMFARecoveryCodes"), - since = "1.8.0" + replaceWith = ReplaceWith("io.appwrite.services.Account.createMFARecoveryCodes") ) suspend fun createMfaRecoveryCodes( ): io.appwrite.models.MfaRecoveryCodes { @@ -924,8 +915,7 @@ class Account(client: Client) : Service(client) { */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `Account.updateMFARecoveryCodes` instead.", - replaceWith = ReplaceWith("io.appwrite.services.Account.updateMFARecoveryCodes"), - since = "1.8.0" + replaceWith = ReplaceWith("io.appwrite.services.Account.updateMFARecoveryCodes") ) suspend fun updateMfaRecoveryCodes( ): io.appwrite.models.MfaRecoveryCodes { diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index c8a7c92..9be75a3 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -25,8 +25,7 @@ class Databases(client: Client) : Service(client) { */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDB.listRows"), - since = "1.8.0" + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.listRows") ) @JvmOverloads suspend fun listDocuments( @@ -68,8 +67,7 @@ class Databases(client: Client) : Service(client) { */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDB.listRows"), - since = "1.8.0" + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.listRows") ) @JvmOverloads @Throws(AppwriteException::class) @@ -96,8 +94,7 @@ class Databases(client: Client) : Service(client) { */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDB.createRow"), - since = "1.8.0" + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.createRow") ) @JvmOverloads suspend fun createDocument( @@ -146,8 +143,7 @@ class Databases(client: Client) : Service(client) { */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDB.createRow"), - since = "1.8.0" + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.createRow") ) @JvmOverloads @Throws(AppwriteException::class) @@ -177,8 +173,7 @@ class Databases(client: Client) : Service(client) { */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDB.getRow"), - since = "1.8.0" + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.getRow") ) @JvmOverloads suspend fun getDocument( @@ -223,8 +218,7 @@ class Databases(client: Client) : Service(client) { */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDB.getRow"), - since = "1.8.0" + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.getRow") ) @JvmOverloads @Throws(AppwriteException::class) @@ -253,8 +247,7 @@ class Databases(client: Client) : Service(client) { */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDB.upsertRow"), - since = "1.8.0" + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.upsertRow") ) @JvmOverloads suspend fun upsertDocument( @@ -303,8 +296,7 @@ class Databases(client: Client) : Service(client) { */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDB.upsertRow"), - since = "1.8.0" + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.upsertRow") ) @JvmOverloads @Throws(AppwriteException::class) @@ -335,8 +327,7 @@ class Databases(client: Client) : Service(client) { */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDB.updateRow"), - since = "1.8.0" + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.updateRow") ) @JvmOverloads suspend fun updateDocument( @@ -385,8 +376,7 @@ class Databases(client: Client) : Service(client) { */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `TablesDB.updateRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDB.updateRow"), - since = "1.8.0" + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.updateRow") ) @JvmOverloads @Throws(AppwriteException::class) @@ -415,8 +405,7 @@ class Databases(client: Client) : Service(client) { */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDB.deleteRow"), - since = "1.8.0" + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.deleteRow") ) suspend fun deleteDocument( databaseId: String, @@ -456,8 +445,7 @@ class Databases(client: Client) : Service(client) { */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDB.decrementRowColumn"), - since = "1.8.0" + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.decrementRowColumn") ) @JvmOverloads suspend fun decrementDocumentAttribute( @@ -509,8 +497,7 @@ class Databases(client: Client) : Service(client) { */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `TablesDB.decrementRowColumn` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDB.decrementRowColumn"), - since = "1.8.0" + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.decrementRowColumn") ) @JvmOverloads @Throws(AppwriteException::class) @@ -544,8 +531,7 @@ class Databases(client: Client) : Service(client) { */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDB.incrementRowColumn"), - since = "1.8.0" + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.incrementRowColumn") ) @JvmOverloads suspend fun incrementDocumentAttribute( @@ -597,8 +583,7 @@ class Databases(client: Client) : Service(client) { */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `TablesDB.incrementRowColumn` instead.", - replaceWith = ReplaceWith("io.appwrite.services.TablesDB.incrementRowColumn"), - since = "1.8.0" + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.incrementRowColumn") ) @JvmOverloads @Throws(AppwriteException::class)