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/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-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-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-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-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-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/java/tablesdb/create-row.md b/docs/examples/java/tablesdb/create-row.md new file mode 100644 index 0000000..12d1680 --- /dev/null +++ b/docs/examples/java/tablesdb/create-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.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/tablesdb/decrement-row-column.md b/docs/examples/java/tablesdb/decrement-row-column.md new file mode 100644 index 0000000..73f2128 --- /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/delete-row.md b/docs/examples/java/tablesdb/delete-row.md new file mode 100644 index 0000000..d4c351b --- /dev/null +++ b/docs/examples/java/tablesdb/delete-row.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.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/tablesdb/get-row.md b/docs/examples/java/tablesdb/get-row.md new file mode 100644 index 0000000..191fc89 --- /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/increment-row-column.md b/docs/examples/java/tablesdb/increment-row-column.md new file mode 100644 index 0000000..dc2120e --- /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/java/tablesdb/list-rows.md b/docs/examples/java/tablesdb/list-rows.md new file mode 100644 index 0000000..dc50574 --- /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..0f1fabc --- /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..22c0e94 --- /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/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-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-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-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-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-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 diff --git a/docs/examples/kotlin/tablesdb/create-row.md b/docs/examples/kotlin/tablesdb/create-row.md new file mode 100644 index 0000000..1a9cbdb --- /dev/null +++ b/docs/examples/kotlin/tablesdb/create-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.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/tablesdb/decrement-row-column.md b/docs/examples/kotlin/tablesdb/decrement-row-column.md new file mode 100644 index 0000000..645e9f4 --- /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/delete-row.md b/docs/examples/kotlin/tablesdb/delete-row.md new file mode 100644 index 0000000..3fcd409 --- /dev/null +++ b/docs/examples/kotlin/tablesdb/delete-row.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.deleteRow( + databaseId = "", + 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..b754cba --- /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/increment-row-column.md b/docs/examples/kotlin/tablesdb/increment-row-column.md new file mode 100644 index 0000000..230408a --- /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/docs/examples/kotlin/tablesdb/list-rows.md b/docs/examples/kotlin/tablesdb/list-rows.md new file mode 100644 index 0000000..05d9ca3 --- /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..f99f8f2 --- /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..d82406a --- /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..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 documents 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 350a894..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 documents 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 fe1e001..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 documents 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 fa3dd20..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 documents 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/Execution.kt b/library/src/main/java/io/appwrite/models/Execution.kt index 216e146..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, @@ -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/models/ExecutionList.kt b/library/src/main/java/io/appwrite/models/ExecutionList.kt index 322aeee..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 documents 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 5af18f1..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 documents 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 1cbb07d..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 documents 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 07559b9..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 documents 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/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/models/LocaleCodeList.kt b/library/src/main/java/io/appwrite/models/LocaleCodeList.kt index 3973a03..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 documents 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 b9f381c..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 documents 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 7feaaaa..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 documents 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 b17de4f..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 documents 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/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..5e99cd7 --- /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 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..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 documents 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 17ccd6b..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 documents 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 f50f074..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) { /** @@ -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. @@ -160,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. @@ -348,6 +352,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 `Account.createMFAAuthenticator` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Account.createMFAAuthenticator"), + since = "1.8.0" + ) suspend fun createMfaAuthenticator( type: io.appwrite.enums.AuthenticatorType, ): io.appwrite.models.MfaType { @@ -374,6 +383,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 +422,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 `Account.updateMFAAuthenticator` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Account.updateMFAAuthenticator"), + since = "1.8.0" + ) suspend fun updateMfaAuthenticator( type: io.appwrite.enums.AuthenticatorType, otp: String, @@ -416,6 +462,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 `Account.updateMFAAuthenticator` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Account.updateMFAAuthenticator"), + since = "1.8.0" + ) @Throws(AppwriteException::class) suspend fun updateMfaAuthenticator( type: io.appwrite.enums.AuthenticatorType, @@ -426,12 +477,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 `Account.deleteMFAAuthenticator` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Account.deleteMFAAuthenticator"), + since = "1.8.0" + ) suspend fun deleteMfaAuthenticator( type: io.appwrite.enums.AuthenticatorType, ): Any { @@ -453,12 +561,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 `Account.createMFAChallenge` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Account.createMFAChallenge"), + since = "1.8.0" + ) suspend fun createMfaChallenge( factor: io.appwrite.enums.AuthenticationFactor, ): io.appwrite.models.MfaChallenge { @@ -485,6 +625,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 +664,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 `Account.updateMFAChallenge` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Account.updateMFAChallenge"), + since = "1.8.0" + ) suspend fun updateMfaChallenge( challengeId: String, otp: String, @@ -520,11 +697,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 `Account.listMFAFactors` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Account.listMFAFactors"), + since = "1.8.0" + ) suspend fun listMfaFactors( ): io.appwrite.models.MfaFactors { val apiPath = "/account/mfa/factors" @@ -548,11 +765,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 `Account.getMFARecoveryCodes` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Account.getMFARecoveryCodes"), + since = "1.8.0" + ) suspend fun getMfaRecoveryCodes( ): io.appwrite.models.MfaRecoveryCodes { val apiPath = "/account/mfa/recovery-codes" @@ -577,10 +827,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 `Account.createMFARecoveryCodes` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Account.createMFARecoveryCodes"), + since = "1.8.0" + ) suspend fun createMfaRecoveryCodes( ): io.appwrite.models.MfaRecoveryCodes { val apiPath = "/account/mfa/recovery-codes" @@ -605,11 +888,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 `Account.updateMFARecoveryCodes` instead.", + replaceWith = ReplaceWith("io.appwrite.services.Account.updateMFARecoveryCodes"), + since = "1.8.0" + ) suspend fun updateMfaRecoveryCodes( ): io.appwrite.models.MfaRecoveryCodes { val apiPath = "/account/mfa/recovery-codes" @@ -634,6 +951,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 +1081,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. @@ -770,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. @@ -872,7 +1218,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 +1253,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 +1374,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. @@ -1067,6 +1417,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, @@ -1096,7 +1449,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. @@ -1174,6 +1532,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, @@ -1238,7 +1599,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] @@ -1269,7 +1630,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] @@ -1301,7 +1662,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] @@ -1407,7 +1768,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.) @@ -1469,9 +1830,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.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 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] @@ -1508,9 +1872,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 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 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. @@ -1550,7 +1917,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. @@ -1622,9 +1993,11 @@ 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 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] */ @@ -1657,7 +2030,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] @@ -1724,7 +2100,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] */ @@ -1753,7 +2129,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..ed7e7fa 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -14,11 +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. + * 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 edc10f5..c8a7c92 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -12,17 +12,22 @@ 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) { /** - * 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). * @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, @@ -54,13 +59,18 @@ 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). * @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, @@ -395,10 +450,15 @@ class Databases(client: Client) : Service(client) { * @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 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, @@ -443,10 +503,15 @@ class Databases(client: Client) : Service(client) { * @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 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( @@ -477,6 +542,11 @@ class Databases(client: Client) : Service(client) { * @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, @@ -525,6 +595,11 @@ class Databases(client: Client) : Service(client) { * @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( 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 a6319b6..aecc83a 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/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 3b0323a..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) { /** @@ -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 new file mode 100644 index 0000000..2cc40e3 --- /dev/null +++ b/library/src/main/java/io/appwrite/services/TablesDb.kt @@ -0,0 +1,547 @@ +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 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] + */ + @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 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] + */ + @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/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/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). + * @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/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/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). + * @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/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] + */ + @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/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] + */ + @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/tablesdb#tablesDBCreateTable) 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/tablesdb#tablesDBCreateTable) 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/tablesdb#tablesDBCreate). + * @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, + ) + } + + + /** + * 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 diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 2756a5a..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) { /** @@ -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. @@ -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. @@ -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] @@ -516,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] @@ -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. @@ -565,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.