diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c5be330..ae9090b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -51,4 +51,4 @@ jobs: SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }} SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} - SDK_VERSION: ${{ github.event.release.tag_name }} \ No newline at end of file + SDK_VERSION: ${{ github.event.release.tag_name }} diff --git a/LICENSE.md b/LICENSE.md index 96201c4..b0761cc 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -9,4 +9,4 @@ Redistribution and use in source and binary forms, with or without modification, 3. Neither the name Appwrite nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/README.md b/README.md index f6ba544..2aa502b 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,12 @@ ![Maven Central](https://img.shields.io/maven-central/v/io.appwrite/sdk-for-android.svg?color=green&style=flat-square) ![License](https://img.shields.io/github/license/appwrite/sdk-for-android.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-0.14.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.0.0-RC1-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 0.14.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).** +**This SDK is compatible with Appwrite server version 1.0.0-RC1. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).** Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Android SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:0.6.1") +implementation("io.appwrite:sdk-for-android:0.8.0-SNAPSHOT") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 0.6.1 + 0.8.0-SNAPSHOT ``` diff --git a/docs/examples/java/account/create-session.md b/docs/examples/java/account/create-email-session.md similarity index 97% rename from docs/examples/java/account/create-session.md rename to docs/examples/java/account/create-email-session.md index 34dfca5..055b828 100644 --- a/docs/examples/java/account/create-session.md +++ b/docs/examples/java/account/create-email-session.md @@ -18,7 +18,7 @@ public class MainActivity extends AppCompatActivity { Account account = new Account(client); - account.createSession( + account.createEmailSession( "email@example.com", "password" new Continuation() { diff --git a/docs/examples/java/account/create-phone-session.md b/docs/examples/java/account/create-phone-session.md new file mode 100644 index 0000000..78be922 --- /dev/null +++ b/docs/examples/java/account/create-phone-session.md @@ -0,0 +1,49 @@ +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch +import io.appwrite.Client +import io.appwrite.services.Account + +public class MainActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + Client client = new Client(getApplicationContext()) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + + Account account = new Account(client); + + account.createPhoneSession( + "[USER_ID]", + "" + new Continuation() { + @NotNull + @Override + public CoroutineContext getContext() { + return EmptyCoroutineContext.INSTANCE; + } + + @Override + public void resumeWith(@NotNull Object o) { + String json = ""; + try { + if (o instanceof Result.Failure) { + Result.Failure failure = (Result.Failure) o; + throw failure.exception; + } else { + Response response = (Response) o; + json = response.body().string(); + } + } catch (Throwable th) { + Log.e("ERROR", th.toString()); + } + } + } + ); + } +} \ No newline at end of file diff --git a/docs/examples/java/account/create-phone-verification.md b/docs/examples/java/account/create-phone-verification.md new file mode 100644 index 0000000..401b942 --- /dev/null +++ b/docs/examples/java/account/create-phone-verification.md @@ -0,0 +1,46 @@ +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch +import io.appwrite.Client +import io.appwrite.services.Account + +public class MainActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + Client client = new Client(getApplicationContext()) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + + Account account = new Account(client); + + account.createPhoneVerification(new Continuation() { + @NotNull + @Override + public CoroutineContext getContext() { + return EmptyCoroutineContext.INSTANCE; + } + + @Override + public void resumeWith(@NotNull Object o) { + String json = ""; + try { + if (o instanceof Result.Failure) { + Result.Failure failure = (Result.Failure) o; + throw failure.exception; + } else { + Response response = (Response) o; + json = response.body().string(); + } + } + } catch (Throwable th) { + Log.e("ERROR", th.toString()); + } + } + }); + } +} \ No newline at end of file diff --git a/docs/examples/java/account/update-phone-session.md b/docs/examples/java/account/update-phone-session.md new file mode 100644 index 0000000..f8d35c7 --- /dev/null +++ b/docs/examples/java/account/update-phone-session.md @@ -0,0 +1,49 @@ +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch +import io.appwrite.Client +import io.appwrite.services.Account + +public class MainActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + Client client = new Client(getApplicationContext()) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + + Account account = new Account(client); + + account.updatePhoneSession( + "[USER_ID]", + "[SECRET]" + new Continuation() { + @NotNull + @Override + public CoroutineContext getContext() { + return EmptyCoroutineContext.INSTANCE; + } + + @Override + public void resumeWith(@NotNull Object o) { + String json = ""; + try { + if (o instanceof Result.Failure) { + Result.Failure failure = (Result.Failure) o; + throw failure.exception; + } else { + Response response = (Response) o; + json = response.body().string(); + } + } catch (Throwable th) { + Log.e("ERROR", th.toString()); + } + } + } + ); + } +} \ No newline at end of file diff --git a/docs/examples/java/account/update-phone-verification.md b/docs/examples/java/account/update-phone-verification.md new file mode 100644 index 0000000..7aec064 --- /dev/null +++ b/docs/examples/java/account/update-phone-verification.md @@ -0,0 +1,49 @@ +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch +import io.appwrite.Client +import io.appwrite.services.Account + +public class MainActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + Client client = new Client(getApplicationContext()) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + + Account account = new Account(client); + + account.updatePhoneVerification( + "[USER_ID]", + "[SECRET]" + new Continuation() { + @NotNull + @Override + public CoroutineContext getContext() { + return EmptyCoroutineContext.INSTANCE; + } + + @Override + public void resumeWith(@NotNull Object o) { + String json = ""; + try { + if (o instanceof Result.Failure) { + Result.Failure failure = (Result.Failure) o; + throw failure.exception; + } else { + Response response = (Response) o; + json = response.body().string(); + } + } catch (Throwable th) { + Log.e("ERROR", th.toString()); + } + } + } + ); + } +} \ No newline at end of file diff --git a/docs/examples/java/account/update-phone.md b/docs/examples/java/account/update-phone.md new file mode 100644 index 0000000..37c54c8 --- /dev/null +++ b/docs/examples/java/account/update-phone.md @@ -0,0 +1,49 @@ +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch +import io.appwrite.Client +import io.appwrite.services.Account + +public class MainActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + Client client = new Client(getApplicationContext()) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2"); // Your project ID + + Account account = new Account(client); + + account.updatePhone( + "", + "password" + new Continuation() { + @NotNull + @Override + public CoroutineContext getContext() { + return EmptyCoroutineContext.INSTANCE; + } + + @Override + public void resumeWith(@NotNull Object o) { + String json = ""; + try { + if (o instanceof Result.Failure) { + Result.Failure failure = (Result.Failure) o; + throw failure.exception; + } else { + Response response = (Response) o; + json = response.body().string(); + } + } catch (Throwable th) { + Log.e("ERROR", th.toString()); + } + } + } + ); + } +} \ No newline at end of file diff --git a/docs/examples/java/database/create-document.md b/docs/examples/java/databases/create-document.md similarity index 91% rename from docs/examples/java/database/create-document.md rename to docs/examples/java/databases/create-document.md index 059a42e..7fc322b 100644 --- a/docs/examples/java/database/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases public class MainActivity extends AppCompatActivity { @@ -16,9 +16,10 @@ public class MainActivity extends AppCompatActivity { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID - Database database = new Database(client); + Databases databases = new Databases(client); - database.createDocument( + databases.createDocument( + "[DATABASE_ID]", "[COLLECTION_ID]", "[DOCUMENT_ID]", mapOf( "a" to "b" ), diff --git a/docs/examples/java/database/delete-document.md b/docs/examples/java/databases/delete-document.md similarity index 91% rename from docs/examples/java/database/delete-document.md rename to docs/examples/java/databases/delete-document.md index 75877c4..f42a09b 100644 --- a/docs/examples/java/database/delete-document.md +++ b/docs/examples/java/databases/delete-document.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases public class MainActivity extends AppCompatActivity { @@ -16,9 +16,10 @@ public class MainActivity extends AppCompatActivity { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID - Database database = new Database(client); + Databases databases = new Databases(client); - database.deleteDocument( + databases.deleteDocument( + "[DATABASE_ID]", "[COLLECTION_ID]", "[DOCUMENT_ID]" new Continuation() { diff --git a/docs/examples/java/database/get-document.md b/docs/examples/java/databases/get-document.md similarity index 91% rename from docs/examples/java/database/get-document.md rename to docs/examples/java/databases/get-document.md index 69aff1d..f1a4d44 100644 --- a/docs/examples/java/database/get-document.md +++ b/docs/examples/java/databases/get-document.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases public class MainActivity extends AppCompatActivity { @@ -16,9 +16,10 @@ public class MainActivity extends AppCompatActivity { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID - Database database = new Database(client); + Databases databases = new Databases(client); - database.getDocument( + databases.getDocument( + "[DATABASE_ID]", "[COLLECTION_ID]", "[DOCUMENT_ID]" new Continuation() { diff --git a/docs/examples/java/database/list-documents.md b/docs/examples/java/databases/list-documents.md similarity index 90% rename from docs/examples/java/database/list-documents.md rename to docs/examples/java/databases/list-documents.md index 711aa41..93d7333 100644 --- a/docs/examples/java/database/list-documents.md +++ b/docs/examples/java/databases/list-documents.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases public class MainActivity extends AppCompatActivity { @@ -16,9 +16,10 @@ public class MainActivity extends AppCompatActivity { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID - Database database = new Database(client); + Databases databases = new Databases(client); - database.listDocuments( + databases.listDocuments( + "[DATABASE_ID]", "[COLLECTION_ID]", new Continuation() { @NotNull diff --git a/docs/examples/java/database/update-document.md b/docs/examples/java/databases/update-document.md similarity index 91% rename from docs/examples/java/database/update-document.md rename to docs/examples/java/databases/update-document.md index a14c91f..81e55d4 100644 --- a/docs/examples/java/database/update-document.md +++ b/docs/examples/java/databases/update-document.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases public class MainActivity extends AppCompatActivity { @@ -16,12 +16,12 @@ public class MainActivity extends AppCompatActivity { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2"); // Your project ID - Database database = new Database(client); + Databases databases = new Databases(client); - database.updateDocument( + databases.updateDocument( + "[DATABASE_ID]", "[COLLECTION_ID]", "[DOCUMENT_ID]", - mapOf( "a" to "b" ), new Continuation() { @NotNull @Override diff --git a/docs/examples/java/storage/create-file.md b/docs/examples/java/storage/create-file.md index 3b7099e..32e0fd0 100644 --- a/docs/examples/java/storage/create-file.md +++ b/docs/examples/java/storage/create-file.md @@ -3,6 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client +import io.appwrite.models.InputFile import io.appwrite.services.Storage public class MainActivity extends AppCompatActivity { @@ -21,7 +22,7 @@ public class MainActivity extends AppCompatActivity { storage.createFile( "[BUCKET_ID]", "[FILE_ID]", - File("file.png"), + InputFile.fromPath("file.png"), new Continuation() { @NotNull @Override diff --git a/docs/examples/kotlin/account/create-session.md b/docs/examples/kotlin/account/create-email-session.md similarity index 93% rename from docs/examples/kotlin/account/create-session.md rename to docs/examples/kotlin/account/create-email-session.md index 4999232..5dcec23 100644 --- a/docs/examples/kotlin/account/create-session.md +++ b/docs/examples/kotlin/account/create-email-session.md @@ -17,7 +17,7 @@ class MainActivity : AppCompatActivity() { val account = Account(client) GlobalScope.launch { - val response = account.createSession( + val response = account.createEmailSession( email = "email@example.com", password = "password" ) diff --git a/docs/examples/kotlin/account/create-phone-session.md b/docs/examples/kotlin/account/create-phone-session.md new file mode 100644 index 0000000..2df83ad --- /dev/null +++ b/docs/examples/kotlin/account/create-phone-session.md @@ -0,0 +1,27 @@ +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch +import io.appwrite.Client +import io.appwrite.services.Account + +class MainActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + val client = Client(applicationContext) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + + val account = Account(client) + + GlobalScope.launch { + val response = account.createPhoneSession( + userId = "[USER_ID]", + phone = "" + ) + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/account/create-phone-verification.md b/docs/examples/kotlin/account/create-phone-verification.md new file mode 100644 index 0000000..ab0eccf --- /dev/null +++ b/docs/examples/kotlin/account/create-phone-verification.md @@ -0,0 +1,24 @@ +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch +import io.appwrite.Client +import io.appwrite.services.Account + +class MainActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + val client = Client(applicationContext) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + + val account = Account(client) + + GlobalScope.launch { + val response = account.createPhoneVerification() + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-phone-session.md b/docs/examples/kotlin/account/update-phone-session.md new file mode 100644 index 0000000..c981991 --- /dev/null +++ b/docs/examples/kotlin/account/update-phone-session.md @@ -0,0 +1,27 @@ +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch +import io.appwrite.Client +import io.appwrite.services.Account + +class MainActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + val client = Client(applicationContext) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + + val account = Account(client) + + GlobalScope.launch { + val response = account.updatePhoneSession( + userId = "[USER_ID]", + secret = "[SECRET]" + ) + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-phone-verification.md b/docs/examples/kotlin/account/update-phone-verification.md new file mode 100644 index 0000000..aa5eea3 --- /dev/null +++ b/docs/examples/kotlin/account/update-phone-verification.md @@ -0,0 +1,27 @@ +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch +import io.appwrite.Client +import io.appwrite.services.Account + +class MainActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + val client = Client(applicationContext) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + + val account = Account(client) + + GlobalScope.launch { + val response = account.updatePhoneVerification( + userId = "[USER_ID]", + secret = "[SECRET]" + ) + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/account/update-phone.md b/docs/examples/kotlin/account/update-phone.md new file mode 100644 index 0000000..8ffef51 --- /dev/null +++ b/docs/examples/kotlin/account/update-phone.md @@ -0,0 +1,27 @@ +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch +import io.appwrite.Client +import io.appwrite.services.Account + +class MainActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + val client = Client(applicationContext) + .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint + .setProject("5df5acd0d48c2") // Your project ID + + val account = Account(client) + + GlobalScope.launch { + val response = account.updatePhone( + phone = "", + password = "password" + ) + val json = response.body?.string() + } + } +} \ No newline at end of file diff --git a/docs/examples/kotlin/database/create-document.md b/docs/examples/kotlin/databases/create-document.md similarity index 81% rename from docs/examples/kotlin/database/create-document.md rename to docs/examples/kotlin/databases/create-document.md index d207383..8a755a2 100644 --- a/docs/examples/kotlin/database/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -14,10 +14,11 @@ class MainActivity : AppCompatActivity() { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID - val database = Database(client) + val databases = Databases(client) GlobalScope.launch { - val response = database.createDocument( + val response = databases.createDocument( + databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", documentId = "[DOCUMENT_ID]", data = mapOf( "a" to "b" ), diff --git a/docs/examples/kotlin/database/delete-document.md b/docs/examples/kotlin/databases/delete-document.md similarity index 80% rename from docs/examples/kotlin/database/delete-document.md rename to docs/examples/kotlin/databases/delete-document.md index 49a85c8..f56293b 100644 --- a/docs/examples/kotlin/database/delete-document.md +++ b/docs/examples/kotlin/databases/delete-document.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -14,10 +14,11 @@ class MainActivity : AppCompatActivity() { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID - val database = Database(client) + val databases = Databases(client) GlobalScope.launch { - val response = database.deleteDocument( + val response = databases.deleteDocument( + databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", documentId = "[DOCUMENT_ID]" ) diff --git a/docs/examples/kotlin/database/get-document.md b/docs/examples/kotlin/databases/get-document.md similarity index 81% rename from docs/examples/kotlin/database/get-document.md rename to docs/examples/kotlin/databases/get-document.md index 3dd65c0..1f5bf29 100644 --- a/docs/examples/kotlin/database/get-document.md +++ b/docs/examples/kotlin/databases/get-document.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -14,10 +14,11 @@ class MainActivity : AppCompatActivity() { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID - val database = Database(client) + val databases = Databases(client) GlobalScope.launch { - val response = database.getDocument( + val response = databases.getDocument( + databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", documentId = "[DOCUMENT_ID]" ) diff --git a/docs/examples/kotlin/database/list-documents.md b/docs/examples/kotlin/databases/list-documents.md similarity index 79% rename from docs/examples/kotlin/database/list-documents.md rename to docs/examples/kotlin/databases/list-documents.md index 6511981..5277b46 100644 --- a/docs/examples/kotlin/database/list-documents.md +++ b/docs/examples/kotlin/databases/list-documents.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -14,10 +14,11 @@ class MainActivity : AppCompatActivity() { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID - val database = Database(client) + val databases = Databases(client) GlobalScope.launch { - val response = database.listDocuments( + val response = databases.listDocuments( + databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", ) val json = response.body?.string() diff --git a/docs/examples/kotlin/database/update-document.md b/docs/examples/kotlin/databases/update-document.md similarity index 80% rename from docs/examples/kotlin/database/update-document.md rename to docs/examples/kotlin/databases/update-document.md index e19ce4a..7807f52 100644 --- a/docs/examples/kotlin/database/update-document.md +++ b/docs/examples/kotlin/databases/update-document.md @@ -3,7 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client -import io.appwrite.services.Database +import io.appwrite.services.Databases class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -14,13 +14,13 @@ class MainActivity : AppCompatActivity() { .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint .setProject("5df5acd0d48c2") // Your project ID - val database = Database(client) + val databases = Databases(client) GlobalScope.launch { - val response = database.updateDocument( + val response = databases.updateDocument( + databaseId = "[DATABASE_ID]", collectionId = "[COLLECTION_ID]", documentId = "[DOCUMENT_ID]", - data = mapOf( "a" to "b" ), ) val json = response.body?.string() } diff --git a/docs/examples/kotlin/storage/create-file.md b/docs/examples/kotlin/storage/create-file.md index c5cc6a3..d3d7c60 100644 --- a/docs/examples/kotlin/storage/create-file.md +++ b/docs/examples/kotlin/storage/create-file.md @@ -3,6 +3,7 @@ import android.os.Bundle import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import io.appwrite.Client +import io.appwrite.models.InputFile import io.appwrite.services.Storage class MainActivity : AppCompatActivity() { @@ -20,7 +21,7 @@ class MainActivity : AppCompatActivity() { val response = storage.createFile( bucketId = "[BUCKET_ID]", fileId = "[FILE_ID]", - file = File("file.png"), + file = InputFile.fromPath("file.png"), ) val json = response.body?.string() } diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 4e5e78f..761fbaa 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -9,6 +9,7 @@ import io.appwrite.cookies.stores.SharedPreferencesCookieStore import io.appwrite.exceptions.AppwriteException import io.appwrite.extensions.fromJson import io.appwrite.json.PreciseNumberAdapter +import io.appwrite.models.InputFile import io.appwrite.models.UploadProgress import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -39,7 +40,7 @@ import kotlin.coroutines.resume class Client @JvmOverloads constructor( context: Context, - var endPoint: String = "https://appwrite.io/v1", + var endPoint: String = "https://HOSTNAME/v1", var endPointRealtime: String? = null, private var selfSigned: Boolean = false ) : CoroutineScope { @@ -84,8 +85,11 @@ class Client @JvmOverloads constructor( "content-type" to "application/json", "origin" to "appwrite-android://${context.packageName}", "user-agent" to "${context.packageName}/${appVersion}, ${System.getProperty("http.agent")}", - "x-sdk-version" to "appwrite:android:${BuildConfig.SDK_VERSION}", - "x-appwrite-response-format" to "0.14.0" + "x-sdk-name" to "Android", + "x-sdk-platform" to "client", + "x-sdk-language" to "android", + "x-sdk-version" to "0.8.0-SNAPSHOT", + "x-appwrite-response-format" to "1.0.0-RC1" ) config = mutableMapOf() @@ -342,14 +346,29 @@ class Client @JvmOverloads constructor( idParamName: String? = null, onProgress: ((UploadProgress) -> Unit)? = null, ): T { - val file = params[paramName] as File - val size = file.length() + var file: RandomAccessFile? = null + val input = params[paramName] as InputFile + val size: Long = when(input.sourceType) { + "path", "file" -> { + file = RandomAccessFile(input.path, "r") + file.length() + } + "bytes" -> { + (input.data as ByteArray).size.toLong() + } + else -> throw UnsupportedOperationException() + } if (size < CHUNK_SIZE) { + val data = when(input.sourceType) { + "file", "path" -> File(input.path).asRequestBody() + "bytes" -> (input.data as ByteArray).toRequestBody(input.mimeType.toMediaType()) + else -> throw UnsupportedOperationException() + } params[paramName] = MultipartBody.Part.createFormData( paramName, - file.name, - file.asRequestBody() + input.filename, + data ) return call( method = "POST", @@ -361,7 +380,6 @@ class Client @JvmOverloads constructor( ) } - val input = RandomAccessFile(file, "r") val buffer = ByteArray(CHUNK_SIZE) var offset = 0L var result: Map<*, *>? = null @@ -380,12 +398,29 @@ class Client @JvmOverloads constructor( } while (offset < size) { - input.seek(offset) - input.read(buffer) + when(input.sourceType) { + "file", "path" -> { + file!!.seek(offset) + file!!.read(buffer) + } + "bytes" -> { + val end = if (offset + CHUNK_SIZE < size) { + offset + CHUNK_SIZE + } else { + size - 1 + } + (input.data as ByteArray).copyInto( + buffer, + startIndex = offset.toInt(), + endIndex = end.toInt() + ) + } + else -> throw UnsupportedOperationException() + } params[paramName] = MultipartBody.Part.createFormData( paramName, - file.name, + input.filename, buffer.toRequestBody() ) diff --git a/library/src/main/java/io/appwrite/ID.kt b/library/src/main/java/io/appwrite/ID.kt new file mode 100644 index 0000000..fe8e656 --- /dev/null +++ b/library/src/main/java/io/appwrite/ID.kt @@ -0,0 +1,10 @@ +package io.appwrite + +class ID { + companion object { + fun custom(id: String): String + = id + fun unique(): String + = "unique()" + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/Permission.kt b/library/src/main/java/io/appwrite/Permission.kt new file mode 100644 index 0000000..a540dcf --- /dev/null +++ b/library/src/main/java/io/appwrite/Permission.kt @@ -0,0 +1,21 @@ +package io.appwrite + +class Permission { + companion object { + fun read(role: String): String { + return "read(\"${role}\")" + } + fun write(role: String): String { + return "write(\"${role}\")" + } + fun create(role: String): String { + return "create(\"${role}\")" + } + fun update(role: String): String { + return "update(\"${role}\")" + } + fun delete(role: String): String { + return "delete(\"${role}\")" + } + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/Query.kt b/library/src/main/java/io/appwrite/Query.kt index b86507b..2d33a02 100644 --- a/library/src/main/java/io/appwrite/Query.kt +++ b/library/src/main/java/io/appwrite/Query.kt @@ -6,20 +6,32 @@ class Query { fun notEqual(attribute: String, value: Any) = Query.addQuery(attribute, "notEqual", value) - fun lesser(attribute: String, value: Any) = Query.addQuery(attribute, "lesser", value) + fun lessThan(attribute: String, value: Any) = Query.addQuery(attribute, "lessThan", value) - fun lesserEqual(attribute: String, value: Any) = Query.addQuery(attribute, "lesserEqual", value) + fun lessThanEqual(attribute: String, value: Any) = Query.addQuery(attribute, "lessThanEqual", value) - fun greater(attribute: String, value: Any) = Query.addQuery(attribute, "greater", value) + fun greaterThan(attribute: String, value: Any) = Query.addQuery(attribute, "greaterThan", value) - fun greaterEqual(attribute: String, value: Any) = Query.addQuery(attribute, "greaterEqual", value) + fun greaterThanEqual(attribute: String, value: Any) = Query.addQuery(attribute, "greaterThanEqual", value) fun search(attribute: String, value: String) = Query.addQuery(attribute, "search", value) - private fun addQuery(attribute: String, oper: String, value: Any): String { + fun orderAsc(attribute: String) = "orderAsc(\"${attribute}\")" + + fun orderDesc(attribute: String) = "orderDesc(\"${attribute}\")" + + fun cursorBefore(documentId: String) = "cursorBefore(\"${documentId}\")" + + fun cursorAfter(documentId: String) = "cursorAfter(\"${documentId}\")" + + fun limit(limit: Int) = "limit(${limit})" + + fun offset(offset: Int) = "offset(${offset})" + + private fun addQuery(attribute: String, method: String, value: Any): String { return when (value) { - is List<*> -> "${attribute}.${oper}(${value.map{it -> parseValues(it!!)}.joinToString(",")})" - else -> "${attribute}.${oper}(${Query.parseValues(value)})" + is List<*> -> "${method}(\"${attribute}\", [${value.map{it -> parseValues(it!!)}.joinToString(",")}])" + else -> "${method}(\"${attribute}\", [${Query.parseValues(value)}])" } } private fun parseValues(value: Any): String { diff --git a/library/src/main/java/io/appwrite/Role.kt b/library/src/main/java/io/appwrite/Role.kt new file mode 100644 index 0000000..1764cc6 --- /dev/null +++ b/library/src/main/java/io/appwrite/Role.kt @@ -0,0 +1,22 @@ +package io.appwrite + +class Role { + companion object { + fun any(): String + = "any" + fun user(id: String): String + = "user:$id" + fun users(): String + = "users" + fun guests(): String + = "guests" + fun team(id: String, role: String = ""): String + = if(role.isEmpty()) { + "team:$id" + } else { + "team:$id/$role" + } + fun status(status: String): String + = "status:$status" + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/User.kt b/library/src/main/java/io/appwrite/models/Account.kt similarity index 57% rename from library/src/main/java/io/appwrite/models/User.kt rename to library/src/main/java/io/appwrite/models/Account.kt index 032391e..5bc87e7 100644 --- a/library/src/main/java/io/appwrite/models/User.kt +++ b/library/src/main/java/io/appwrite/models/Account.kt @@ -3,9 +3,9 @@ package io.appwrite.models import com.google.gson.annotations.SerializedName /** - * User + * Account */ -data class User( +data class Account( /** * User ID. * @@ -13,6 +13,20 @@ data class User( @SerializedName("\$id") val id: String, + /** + * User creation date in Datetime. + * + */ + @SerializedName("\$createdAt") + val createdAt: String, + + /** + * User update date in Datetime. + * + */ + @SerializedName("\$updatedAt") + val updatedAt: String, + /** * User name. * @@ -21,11 +35,11 @@ data class User( val name: String, /** - * User registration date in Unix timestamp. + * User registration date in Datetime. * */ @SerializedName("registration") - val registration: Long, + val registration: String, /** * User status. Pass `true` for enabled and `false` for disabled. @@ -35,11 +49,11 @@ data class User( val status: Boolean, /** - * Unix timestamp of the most recent password update + * Datetime of the most recent password update * */ @SerializedName("passwordUpdate") - val passwordUpdate: Long, + val passwordUpdate: String, /** * User email address. @@ -48,6 +62,13 @@ data class User( @SerializedName("email") val email: String, + /** + * User phone number in E.164 format. + * + */ + @SerializedName("phone") + val phone: String, + /** * Email verification status. * @@ -55,6 +76,13 @@ data class User( @SerializedName("emailVerification") val emailVerification: Boolean, + /** + * Phone verification status. + * + */ + @SerializedName("phoneVerification") + val phoneVerification: Boolean, + /** * User preferences as a key-value object * @@ -64,26 +92,34 @@ data class User( ) { companion object { @Suppress("UNCHECKED_CAST") - fun from(map: Map) = User( + fun from(map: Map) = Account( id = map["\$id"] as String, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, name = map["name"] as String, - registration = (map["registration"] as Number).toLong(), + registration = map["registration"] as String, status = map["status"] as Boolean, - passwordUpdate = (map["passwordUpdate"] as Number).toLong(), + passwordUpdate = map["passwordUpdate"] as String, email = map["email"] as String, + phone = map["phone"] as String, emailVerification = map["emailVerification"] as Boolean, + phoneVerification = map["phoneVerification"] as Boolean, prefs = Preferences.from(map = map["prefs"] as Map) ) } fun toMap(): Map = mapOf( "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, "name" to name as Any, "registration" to registration as Any, "status" to status as Any, "passwordUpdate" to passwordUpdate as Any, "email" to email as Any, + "phone" to phone as Any, "emailVerification" to emailVerification as Any, + "phoneVerification" to phoneVerification as Any, "prefs" to prefs.toMap() as Any ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Document.kt b/library/src/main/java/io/appwrite/models/Document.kt index a83a844..3ffbd5f 100644 --- a/library/src/main/java/io/appwrite/models/Document.kt +++ b/library/src/main/java/io/appwrite/models/Document.kt @@ -21,18 +21,25 @@ data class Document( val collection: String, /** - * Document read permissions. + * Document creation date in Datetime * */ - @SerializedName("\$read") - val read: List, + @SerializedName("\$createdAt") + val createdAt: String, /** - * Document write permissions. + * Document update date in Datetime * */ - @SerializedName("\$write") - val write: List, + @SerializedName("\$updatedAt") + val updatedAt: String, + + /** + * Document permissions. [Learn more about permissions](/docs/permissions). + * + */ + @SerializedName("\$permissions") + val permissions: List, val data: Map ) { @@ -41,8 +48,9 @@ data class Document( fun from(map: Map) = Document( id = map["\$id"] as String, collection = map["\$collection"] as String, - read = map["\$read"] as List, - write = map["\$write"] as List, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, + permissions = map["\$permissions"] as List, data = map ) } @@ -50,8 +58,9 @@ data class Document( fun toMap(): Map = mapOf( "\$id" to id as Any, "\$collection" to collection as Any, - "\$read" to read as Any, - "\$write" to write as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "\$permissions" to permissions as Any, "data" to data ) diff --git a/library/src/main/java/io/appwrite/models/Execution.kt b/library/src/main/java/io/appwrite/models/Execution.kt index 06c2811..52b4d03 100644 --- a/library/src/main/java/io/appwrite/models/Execution.kt +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -14,25 +14,32 @@ data class Execution( val id: String, /** - * Execution read permissions. + * Execution creation date in Datetime * */ - @SerializedName("\$read") - val read: List, + @SerializedName("\$createdAt") + val createdAt: String, /** - * Function ID. + * Execution upate date in Datetime * */ - @SerializedName("functionId") - val functionId: String, + @SerializedName("\$updatedAt") + val updatedAt: String, + + /** + * Execution roles. + * + */ + @SerializedName("\$permissions") + val permissions: List, /** - * The execution creation date in Unix timestamp. + * Function ID. * */ - @SerializedName("dateCreated") - val dateCreated: Long, + @SerializedName("functionId") + val functionId: String, /** * The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. @@ -63,7 +70,14 @@ data class Execution( val response: String, /** - * The script stderr output string. Logs the last 4,000 characters of the execution stderr output + * The script stdout output string. Logs the last 4,000 characters of the execution stdout output. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + * + */ + @SerializedName("stdout") + val stdout: String, + + /** + * The script stderr output string. Logs the last 4,000 characters of the execution stderr output. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. * */ @SerializedName("stderr") @@ -80,13 +94,15 @@ data class Execution( @Suppress("UNCHECKED_CAST") fun from(map: Map) = Execution( id = map["\$id"] as String, - read = map["\$read"] as List, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, + permissions = map["\$permissions"] as List, functionId = map["functionId"] as String, - dateCreated = (map["dateCreated"] as Number).toLong(), trigger = map["trigger"] as String, status = map["status"] as String, statusCode = (map["statusCode"] as Number).toLong(), response = map["response"] as String, + stdout = map["stdout"] as String, stderr = map["stderr"] as String, time = (map["time"] as Number).toDouble() ) @@ -94,13 +110,15 @@ data class Execution( fun toMap(): Map = mapOf( "\$id" to id as Any, - "\$read" to read as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "\$permissions" to permissions as Any, "functionId" to functionId as Any, - "dateCreated" to dateCreated as Any, "trigger" to trigger as Any, "status" to status as Any, "statusCode" to statusCode as Any, "response" to response as Any, + "stdout" to stdout as Any, "stderr" to stderr as Any, "time" to time as Any ) diff --git a/library/src/main/java/io/appwrite/models/File.kt b/library/src/main/java/io/appwrite/models/File.kt index 2faa1e4..576751e 100644 --- a/library/src/main/java/io/appwrite/models/File.kt +++ b/library/src/main/java/io/appwrite/models/File.kt @@ -21,32 +21,32 @@ data class File( val bucketId: String, /** - * File read permissions. + * File creation date in Datetime * */ - @SerializedName("\$read") - val read: List, + @SerializedName("\$createdAt") + val createdAt: String, /** - * File write permissions. + * File update date in Datetime * */ - @SerializedName("\$write") - val write: List, + @SerializedName("\$updatedAt") + val updatedAt: String, /** - * File name. + * File permissions. [Learn more about permissions](/docs/permissions). * */ - @SerializedName("name") - val name: String, + @SerializedName("\$permissions") + val permissions: List, /** - * File creation date in Unix timestamp. + * File name. * */ - @SerializedName("dateCreated") - val dateCreated: Long, + @SerializedName("name") + val name: String, /** * File MD5 signature. @@ -88,10 +88,10 @@ data class File( fun from(map: Map) = File( id = map["\$id"] as String, bucketId = map["bucketId"] as String, - read = map["\$read"] as List, - write = map["\$write"] as List, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, + permissions = map["\$permissions"] as List, name = map["name"] as String, - dateCreated = (map["dateCreated"] as Number).toLong(), signature = map["signature"] as String, mimeType = map["mimeType"] as String, sizeOriginal = (map["sizeOriginal"] as Number).toLong(), @@ -103,10 +103,10 @@ data class File( fun toMap(): Map = mapOf( "\$id" to id as Any, "bucketId" to bucketId as Any, - "\$read" to read as Any, - "\$write" to write as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "\$permissions" to permissions as Any, "name" to name as Any, - "dateCreated" to dateCreated as Any, "signature" to signature as Any, "mimeType" to mimeType as Any, "sizeOriginal" to sizeOriginal as Any, diff --git a/library/src/main/java/io/appwrite/models/InputFile.kt b/library/src/main/java/io/appwrite/models/InputFile.kt new file mode 100644 index 0000000..afbb2e9 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/InputFile.kt @@ -0,0 +1,37 @@ +package io.appwrite.models + +import java.io.File +import java.net.URLConnection +import java.nio.file.Files +import java.nio.file.Paths + +class InputFile private constructor() { + + lateinit var path: String + lateinit var filename: String + lateinit var mimeType: String + lateinit var sourceType: String + lateinit var data: Any + + companion object { + fun fromFile(file: File) = InputFile().apply { + path = file.canonicalPath + filename = file.name + mimeType = Files.probeContentType(Paths.get(file.canonicalPath)) + ?: URLConnection.guessContentTypeFromName(filename) + ?: "" + sourceType = "file" + } + + fun fromPath(path: String): InputFile = fromFile(File(path)).apply { + sourceType = "path" + } + + fun fromBytes(bytes: ByteArray, filename: String = "", mimeType: String = "") = InputFile().apply { + this.filename = filename + this.mimeType = mimeType + data = bytes + sourceType = "bytes" + } + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Log.kt b/library/src/main/java/io/appwrite/models/Log.kt index fb4de88..7d7dcdf 100644 --- a/library/src/main/java/io/appwrite/models/Log.kt +++ b/library/src/main/java/io/appwrite/models/Log.kt @@ -49,11 +49,11 @@ data class Log( val ip: String, /** - * Log creation time in Unix timestamp. + * Log creation date in Datetime. * */ @SerializedName("time") - val time: Long, + val time: String, /** * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). @@ -162,7 +162,7 @@ data class Log( userName = map["userName"] as String, mode = map["mode"] as String, ip = map["ip"] as String, - time = (map["time"] as Number).toLong(), + time = map["time"] as String, osCode = map["osCode"] as String, osName = map["osName"] as String, osVersion = map["osVersion"] as String, diff --git a/library/src/main/java/io/appwrite/models/Membership.kt b/library/src/main/java/io/appwrite/models/Membership.kt index 3df7b69..f86d6bf 100644 --- a/library/src/main/java/io/appwrite/models/Membership.kt +++ b/library/src/main/java/io/appwrite/models/Membership.kt @@ -13,6 +13,20 @@ data class Membership( @SerializedName("\$id") val id: String, + /** + * Membership creation date in Datetime + * + */ + @SerializedName("\$createdAt") + val createdAt: String, + + /** + * Membership update date in Datetime + * + */ + @SerializedName("\$updatedAt") + val updatedAt: String, + /** * User ID. * @@ -49,18 +63,18 @@ data class Membership( val teamName: String, /** - * Date, the user has been invited to join the team in Unix timestamp. + * Date, the user has been invited to join the team in Datetime * */ @SerializedName("invited") - val invited: Long, + val invited: String, /** - * Date, the user has accepted the invitation to join the team in Unix timestamp. + * Date, the user has accepted the invitation to join the team in Datetime * */ @SerializedName("joined") - val joined: Long, + val joined: String, /** * User confirmation status, true if the user has joined the team or false otherwise. @@ -80,13 +94,15 @@ data class Membership( @Suppress("UNCHECKED_CAST") fun from(map: Map) = Membership( id = map["\$id"] as String, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, userId = map["userId"] as String, userName = map["userName"] as String, userEmail = map["userEmail"] as String, teamId = map["teamId"] as String, teamName = map["teamName"] as String, - invited = (map["invited"] as Number).toLong(), - joined = (map["joined"] as Number).toLong(), + invited = map["invited"] as String, + joined = map["joined"] as String, confirm = map["confirm"] as Boolean, roles = map["roles"] as List ) @@ -94,6 +110,8 @@ data class Membership( fun toMap(): Map = mapOf( "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, "userId" to userId as Any, "userName" to userName as Any, "userEmail" to userEmail as Any, diff --git a/library/src/main/java/io/appwrite/models/Session.kt b/library/src/main/java/io/appwrite/models/Session.kt index 1abd909..c0a49fb 100644 --- a/library/src/main/java/io/appwrite/models/Session.kt +++ b/library/src/main/java/io/appwrite/models/Session.kt @@ -13,6 +13,13 @@ data class Session( @SerializedName("\$id") val id: String, + /** + * Session creation date in Datetime + * + */ + @SerializedName("\$createdAt") + val createdAt: String, + /** * User ID. * @@ -21,11 +28,11 @@ data class Session( val userId: String, /** - * Session expiration date in Unix timestamp. + * Session expiration date in Datetime * */ @SerializedName("expire") - val expire: Long, + val expire: String, /** * Session Provider. @@ -49,11 +56,11 @@ data class Session( val providerAccessToken: String, /** - * Date, the Unix timestamp of when the access token expires. + * The date of when the access token expires in Datetime format. * */ @SerializedName("providerAccessTokenExpiry") - val providerAccessTokenExpiry: Long, + val providerAccessTokenExpiry: String, /** * Session Provider Refresh Token. @@ -178,12 +185,13 @@ data class Session( @Suppress("UNCHECKED_CAST") fun from(map: Map) = Session( id = map["\$id"] as String, + createdAt = map["\$createdAt"] as String, userId = map["userId"] as String, - expire = (map["expire"] as Number).toLong(), + expire = map["expire"] as String, provider = map["provider"] as String, providerUid = map["providerUid"] as String, providerAccessToken = map["providerAccessToken"] as String, - providerAccessTokenExpiry = (map["providerAccessTokenExpiry"] as Number).toLong(), + providerAccessTokenExpiry = map["providerAccessTokenExpiry"] as String, providerRefreshToken = map["providerRefreshToken"] as String, ip = map["ip"] as String, osCode = map["osCode"] as String, @@ -206,6 +214,7 @@ data class Session( fun toMap(): Map = mapOf( "\$id" to id as Any, + "\$createdAt" to createdAt as Any, "userId" to userId as Any, "expire" to expire as Any, "provider" to provider as Any, diff --git a/library/src/main/java/io/appwrite/models/Team.kt b/library/src/main/java/io/appwrite/models/Team.kt index f502375..0419e4b 100644 --- a/library/src/main/java/io/appwrite/models/Team.kt +++ b/library/src/main/java/io/appwrite/models/Team.kt @@ -14,18 +14,25 @@ data class Team( val id: String, /** - * Team name. + * Team creation date in Datetime * */ - @SerializedName("name") - val name: String, + @SerializedName("\$createdAt") + val createdAt: String, + + /** + * Team update date in Datetime + * + */ + @SerializedName("\$updatedAt") + val updatedAt: String, /** - * Team creation date in Unix timestamp. + * Team name. * */ - @SerializedName("dateCreated") - val dateCreated: Long, + @SerializedName("name") + val name: String, /** * Total number of team members. @@ -38,16 +45,18 @@ data class Team( @Suppress("UNCHECKED_CAST") fun from(map: Map) = Team( id = map["\$id"] as String, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, name = map["name"] as String, - dateCreated = (map["dateCreated"] as Number).toLong(), total = (map["total"] as Number).toLong() ) } fun toMap(): Map = mapOf( "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, "name" to name as Any, - "dateCreated" to dateCreated as Any, "total" to total as Any ) } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Token.kt b/library/src/main/java/io/appwrite/models/Token.kt index d555f45..d5a5c4f 100644 --- a/library/src/main/java/io/appwrite/models/Token.kt +++ b/library/src/main/java/io/appwrite/models/Token.kt @@ -13,6 +13,13 @@ data class Token( @SerializedName("\$id") val id: String, + /** + * Token creation date in Datetime + * + */ + @SerializedName("\$createdAt") + val createdAt: String, + /** * User ID. * @@ -28,24 +35,26 @@ data class Token( val secret: String, /** - * Token expiration date in Unix timestamp. + * Token expiration date in Datetime. * */ @SerializedName("expire") - val expire: Long + val expire: String ) { companion object { @Suppress("UNCHECKED_CAST") fun from(map: Map) = Token( id = map["\$id"] as String, + createdAt = map["\$createdAt"] as String, userId = map["userId"] as String, secret = map["secret"] as String, - expire = (map["expire"] as Number).toLong() + expire = map["expire"] as String ) } fun toMap(): Map = mapOf( "\$id" to id as Any, + "\$createdAt" to createdAt as Any, "userId" to userId as Any, "secret" to secret as Any, "expire" to expire as Any diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 8f144de..02fd660 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -12,33 +12,35 @@ import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import java.io.File -class Account(client: Client) : Service(client) { +class Account : Service { + + public constructor (client: Client) : super(client) { } /** * Get Account * * Get currently logged in user data as JSON object. * - * @return [io.appwrite.models.User] + * @return [io.appwrite.models.Account] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun get(): io.appwrite.models.User { + suspend fun get(): io.appwrite.models.Account { val path = "/account" val params = mutableMapOf( ) val headers = mutableMapOf( "content-type" to "application/json" ) - val converter: (Map) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it) + val converter: (Map) -> io.appwrite.models.Account = { + io.appwrite.models.Account.from(map = it) } return client.call( "GET", path, headers, params, - responseType = io.appwrite.models.User::class.java, + responseType = io.appwrite.models.Account::class.java, converter, ) } @@ -57,7 +59,7 @@ class Account(client: Client) : Service(client) { * @param email User email. * @param password User password. Must be at least 8 chars. * @param name User name. Max length: 128 chars. - * @return [io.appwrite.models.User] + * @return [io.appwrite.models.Account] */ @JvmOverloads @Throws(AppwriteException::class) @@ -66,7 +68,7 @@ class Account(client: Client) : Service(client) { email: String, password: String, name: String? = null - ): io.appwrite.models.User { + ): io.appwrite.models.Account { val path = "/account" val params = mutableMapOf( "userId" to userId, @@ -77,15 +79,15 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val converter: (Map) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it) + val converter: (Map) -> io.appwrite.models.Account = { + io.appwrite.models.Account.from(map = it) } return client.call( "POST", path, headers, params, - responseType = io.appwrite.models.User::class.java, + responseType = io.appwrite.models.Account::class.java, converter, ) } @@ -104,14 +106,14 @@ class Account(client: Client) : Service(client) { * * @param email User email. * @param password User password. Must be at least 8 chars. - * @return [io.appwrite.models.User] + * @return [io.appwrite.models.Account] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun updateEmail( email: String, password: String - ): io.appwrite.models.User { + ): io.appwrite.models.Account { val path = "/account/email" val params = mutableMapOf( "email" to email, @@ -120,15 +122,15 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val converter: (Map) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it) + val converter: (Map) -> io.appwrite.models.Account = { + io.appwrite.models.Account.from(map = it) } return client.call( "PATCH", path, headers, params, - responseType = io.appwrite.models.User::class.java, + responseType = io.appwrite.models.Account::class.java, converter, ) } @@ -172,20 +174,17 @@ class Account(client: Client) : Service(client) { * Get currently logged in user list of latest security activity logs. Each * log returns user IP address, location and date and time of log. * - * @param limit Maximum number of logs to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Only supported methods are limit and offset * @return [io.appwrite.models.LogList] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getLogs( - limit: Long? = null, - offset: Long? = null + queries: List? = null ): io.appwrite.models.LogList { val path = "/account/logs" val params = mutableMapOf( - "limit" to limit, - "offset" to offset + "queries" to queries ) val headers = mutableMapOf( "content-type" to "application/json" @@ -209,13 +208,13 @@ class Account(client: Client) : Service(client) { * Update currently logged in user account name. * * @param name User name. Max length: 128 chars. - * @return [io.appwrite.models.User] + * @return [io.appwrite.models.Account] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun updateName( name: String - ): io.appwrite.models.User { + ): io.appwrite.models.Account { val path = "/account/name" val params = mutableMapOf( "name" to name @@ -223,15 +222,15 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val converter: (Map) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it) + val converter: (Map) -> io.appwrite.models.Account = { + io.appwrite.models.Account.from(map = it) } return client.call( "PATCH", path, headers, params, - responseType = io.appwrite.models.User::class.java, + responseType = io.appwrite.models.Account::class.java, converter, ) } @@ -245,14 +244,14 @@ class Account(client: Client) : Service(client) { * * @param password New user password. Must be at least 8 chars. * @param oldPassword Current user password. Must be at least 8 chars. - * @return [io.appwrite.models.User] + * @return [io.appwrite.models.Account] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun updatePassword( password: String, oldPassword: String? = null - ): io.appwrite.models.User { + ): io.appwrite.models.Account { val path = "/account/password" val params = mutableMapOf( "password" to password, @@ -261,15 +260,55 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val converter: (Map) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it) + val converter: (Map) -> io.appwrite.models.Account = { + io.appwrite.models.Account.from(map = it) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.Account::class.java, + converter, + ) + } + + /** + * Update Account Phone + * + * Update the currently logged in user's phone number. After updating the + * phone number, the phone verification status will be reset. A confirmation + * SMS is not sent automatically, however you can use the [POST + * /account/verification/phone](/docs/client/account#accountCreatePhoneVerification) + * endpoint to send a confirmation SMS. + * + * @param phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param password User password. Must be at least 8 chars. + * @return [io.appwrite.models.Account] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updatePhone( + phone: String, + password: String + ): io.appwrite.models.Account { + val path = "/account/phone" + val params = mutableMapOf( + "phone" to phone, + "password" to password + ) + val headers = mutableMapOf( + "content-type" to "application/json" + ) + val converter: (Map) -> io.appwrite.models.Account = { + io.appwrite.models.Account.from(map = it) } return client.call( "PATCH", path, headers, params, - responseType = io.appwrite.models.User::class.java, + responseType = io.appwrite.models.Account::class.java, converter, ) } @@ -311,13 +350,13 @@ class Account(client: Client) : Service(client) { * size is 64kB and throws error if exceeded. * * @param prefs Prefs key-value JSON object. - * @return [io.appwrite.models.User] + * @return [io.appwrite.models.Account] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun updatePrefs( prefs: Any - ): io.appwrite.models.User { + ): io.appwrite.models.Account { val path = "/account/prefs" val params = mutableMapOf( "prefs" to prefs @@ -325,15 +364,15 @@ class Account(client: Client) : Service(client) { val headers = mutableMapOf( "content-type" to "application/json" ) - val converter: (Map) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it) + val converter: (Map) -> io.appwrite.models.Account = { + io.appwrite.models.Account.from(map = it) } return client.call( "PATCH", path, headers, params, - responseType = io.appwrite.models.User::class.java, + responseType = io.appwrite.models.Account::class.java, converter, ) } @@ -462,85 +501,85 @@ class Account(client: Client) : Service(client) { } /** - * Create Account Session + * Delete All Account Sessions * - * Allow the user to login into their account by providing a valid email and - * password combination. This route will create a new session for the user. + * Delete all sessions from the user account and remove any sessions cookies + * from the end client. * - * @param email User email. - * @param password User password. Must be at least 8 chars. - * @return [io.appwrite.models.Session] + * @return [Any] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun createSession( - email: String, - password: String - ): io.appwrite.models.Session { + suspend fun deleteSessions(): Any { val path = "/account/sessions" val params = mutableMapOf( - "email" to email, - "password" to password ) val headers = mutableMapOf( "content-type" to "application/json" ) - val converter: (Map) -> io.appwrite.models.Session = { - io.appwrite.models.Session.from(map = it) - } return client.call( - "POST", + "DELETE", path, headers, params, - responseType = io.appwrite.models.Session::class.java, - converter, + responseType = Any::class.java, ) } /** - * Delete All Account Sessions + * Create Anonymous Session * - * Delete all sessions from the user account and remove any sessions cookies - * from the end client. + * Use this endpoint to allow a new user to register an anonymous account in + * your project. This route will also create a new session for the user. To + * allow the new user to convert an anonymous account to a normal account, you + * need to update its [email and + * password](/docs/client/account#accountUpdateEmail) or create an [OAuth2 + * session](/docs/client/account#accountCreateOAuth2Session). * - * @return [Any] + * @return [io.appwrite.models.Session] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun deleteSessions(): Any { - val path = "/account/sessions" + suspend fun createAnonymousSession(): io.appwrite.models.Session { + val path = "/account/sessions/anonymous" val params = mutableMapOf( ) val headers = mutableMapOf( "content-type" to "application/json" ) + val converter: (Map) -> io.appwrite.models.Session = { + io.appwrite.models.Session.from(map = it) + } return client.call( - "DELETE", + "POST", path, headers, params, - responseType = Any::class.java, + responseType = io.appwrite.models.Session::class.java, + converter, ) } /** - * Create Anonymous Session + * Create Account Session with Email * - * Use this endpoint to allow a new user to register an anonymous account in - * your project. This route will also create a new session for the user. To - * allow the new user to convert an anonymous account to a normal account, you - * need to update its [email and - * password](/docs/client/account#accountUpdateEmail) or create an [OAuth2 - * session](/docs/client/account#accountCreateOAuth2Session). + * Allow the user to login into their account by providing a valid email and + * password combination. This route will create a new session for the user. * + * @param email User email. + * @param password User password. Must be at least 8 chars. * @return [io.appwrite.models.Session] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun createAnonymousSession(): io.appwrite.models.Session { - val path = "/account/sessions/anonymous" + suspend fun createEmailSession( + email: String, + password: String + ): io.appwrite.models.Session { + val path = "/account/sessions/email" val params = mutableMapOf( + "email" to email, + "password" to password ) val headers = mutableMapOf( "content-type" to "application/json" @@ -561,9 +600,10 @@ class Account(client: Client) : Service(client) { /** * Create Magic URL session * - * Sends the user an email with a secret key for creating a session. When the - * user clicks the link in the email, the user is redirected back to the URL - * you provided with the secret key and userId values attached to the URL + * Sends the user an email with a secret key for creating a session. If the + * provided user ID has not be registered, a new user will be created. When + * the user clicks the link in the email, the user is redirected back to the + * URL you provided with the secret key and userId values attached to the URL * query string. Use the query string parameters to submit a request to the * [PUT * /account/sessions/magic-url](/docs/client/account#accountUpdateMagicURLSession) @@ -668,10 +708,10 @@ class Account(client: Client) : Service(client) { * user.. * * - * @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, bitbucket, bitly, box, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, notion, okta, paypal, paypalSandbox, salesforce, slack, spotify, tradeshift, tradeshiftBox, twitch, zoom, yahoo, yammer, yandex, wordpress, stripe. + * @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, github, gitlab, google, linkedin, microsoft, notion, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoom. * @param success URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param failure URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. - * @param scopes A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 128 characters long. + * @param scopes A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. * */ @JvmOverloads @@ -681,7 +721,7 @@ class Account(client: Client) : Service(client) { provider: String, success: String? = null, failure: String? = null, - scopes: List? = null + scopes: List? = null ) { val path = "/account/sessions/oauth2/{provider}".replace("{provider}", provider) val params = mutableMapOf( @@ -734,6 +774,87 @@ class Account(client: Client) : Service(client) { } } + /** + * Create Phone session + * + * Sends the user an SMS with a secret key for creating a session. If the + * provided user ID has not be registered, a new user will be created. Use the + * returned user ID and secret and submit a request to the [PUT + * /account/sessions/phone](/docs/client/account#accountUpdatePhoneSession) + * endpoint to complete the login process. The secret sent to the user's phone + * is valid for 15 minutes. + * + * @param userId Unique Id. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @return [io.appwrite.models.Token] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createPhoneSession( + userId: String, + phone: String + ): io.appwrite.models.Token { + val path = "/account/sessions/phone" + val params = mutableMapOf( + "userId" to userId, + "phone" to phone + ) + val headers = mutableMapOf( + "content-type" to "application/json" + ) + val converter: (Map) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Token::class.java, + converter, + ) + } + + /** + * Create Phone Session (confirmation) + * + * Use this endpoint to complete creating a session with SMS. Use the + * **userId** from the + * [createPhoneSession](/docs/client/account#accountCreatePhoneSession) + * endpoint and the **secret** received via SMS to successfully update and + * confirm the phone session. + * + * @param userId User ID. + * @param secret Valid verification token. + * @return [io.appwrite.models.Session] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updatePhoneSession( + userId: String, + secret: String + ): io.appwrite.models.Session { + val path = "/account/sessions/phone" + val params = mutableMapOf( + "userId" to userId, + "secret" to secret + ) + val headers = mutableMapOf( + "content-type" to "application/json" + ) + val converter: (Map) -> io.appwrite.models.Session = { + io.appwrite.models.Session.from(map = it) + } + return client.call( + "PUT", + path, + headers, + params, + responseType = io.appwrite.models.Session::class.java, + converter, + ) + } + /** * Get Session By ID * @@ -839,26 +960,26 @@ class Account(client: Client) : Service(client) { * record is not deleted but permanently blocked from any access. To * completely delete a user, use the Users API instead. * - * @return [io.appwrite.models.User] + * @return [io.appwrite.models.Account] */ @JvmOverloads @Throws(AppwriteException::class) - suspend fun updateStatus(): io.appwrite.models.User { + suspend fun updateStatus(): io.appwrite.models.Account { val path = "/account/status" val params = mutableMapOf( ) val headers = mutableMapOf( "content-type" to "application/json" ) - val converter: (Map) -> io.appwrite.models.User = { - io.appwrite.models.User.from(map = it) + val converter: (Map) -> io.appwrite.models.Account = { + io.appwrite.models.Account.from(map = it) } return client.call( "PATCH", path, headers, params, - responseType = io.appwrite.models.User::class.java, + responseType = io.appwrite.models.Account::class.java, converter, ) } @@ -873,8 +994,8 @@ class Account(client: Client) : Service(client) { * should redirect the user back to your app and allow you to complete the * verification process by verifying both the **userId** and **secret** * parameters. Learn more about how to [complete the verification - * process](/docs/client/account#accountUpdateVerification). The verification - * link sent to the user's email address is valid for 7 days. + * process](/docs/client/account#accountUpdateEmailVerification). The + * verification link sent to the user's email address is valid for 7 days. * * Please note that in order to avoid a [Redirect * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), @@ -949,4 +1070,77 @@ class Account(client: Client) : Service(client) { ) } + /** + * Create Phone Verification + * + * Use this endpoint to send a verification SMS to the currently logged in + * user. This endpoint is meant for use after updating a user's phone number + * using the [accountUpdatePhone](/docs/client/account#accountUpdatePhone) + * endpoint. Learn more about how to [complete the verification + * process](/docs/client/account#accountUpdatePhoneVerification). The + * verification code sent to the user's phone number is valid for 15 minutes. + * + * @return [io.appwrite.models.Token] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun createPhoneVerification(): io.appwrite.models.Token { + val path = "/account/verification/phone" + val params = mutableMapOf( + ) + val headers = mutableMapOf( + "content-type" to "application/json" + ) + val converter: (Map) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it) + } + return client.call( + "POST", + path, + headers, + params, + responseType = io.appwrite.models.Token::class.java, + converter, + ) + } + + /** + * Create Phone Verification (confirmation) + * + * Use this endpoint to complete the user phone verification process. Use the + * **userId** and **secret** that were sent to your user's phone number to + * verify the user email ownership. If confirmed this route will return a 200 + * status code. + * + * @param userId User ID. + * @param secret Valid verification token. + * @return [io.appwrite.models.Token] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updatePhoneVerification( + userId: String, + secret: String + ): io.appwrite.models.Token { + val path = "/account/verification/phone" + val params = mutableMapOf( + "userId" to userId, + "secret" to secret + ) + val headers = mutableMapOf( + "content-type" to "application/json" + ) + val converter: (Map) -> io.appwrite.models.Token = { + io.appwrite.models.Token.from(map = it) + } + return client.call( + "PUT", + path, + headers, + params, + responseType = io.appwrite.models.Token::class.java, + converter, + ) + } + } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt index 20e1f54..bb75581 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -10,7 +10,9 @@ import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import java.io.File -class Avatars(client: Client) : Service(client) { +class Avatars : Service { + + public constructor (client: Client) : super(client) { } /** * Get Browser Icon @@ -129,7 +131,8 @@ class Avatars(client: Client) : Service(client) { * * You can use this endpoint to show different country flags icons to your * users. The code argument receives the 2 letter country code. Use width, - * height and quality arguments to change the output settings. + * height and quality arguments to change the output settings. Country codes + * follow the [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) standard. * * When one dimension is specified and the other is 0, the image is scaled * with preserved aspect ratio. If both dimensions are 0, the API provides an diff --git a/library/src/main/java/io/appwrite/services/Database.kt b/library/src/main/java/io/appwrite/services/Databases.kt similarity index 58% rename from library/src/main/java/io/appwrite/services/Database.kt rename to library/src/main/java/io/appwrite/services/Databases.kt index 74bced3..65f1ead 100644 --- a/library/src/main/java/io/appwrite/services/Database.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -8,47 +8,33 @@ import okhttp3.Cookie import okhttp3.Response import java.io.File -class Database(client: Client) : Service(client) { +class Databases : Service { + + public constructor (client: Client) : super(client) { } /** * List Documents * - * Get a list of all the user documents. You can use the query params to - * filter your results. On admin mode, this endpoint will return a list of all - * of the project's documents. [Learn more about different API - * modes](/docs/admin). + * Get a list of all the user's documents in a given collection. You can use + * the query params to filter your results. On admin mode, this endpoint will + * return a list of all of documents belonging to the provided collectionId. + * [Learn more about different API modes](/docs/admin). * - * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). - * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/database#querying-documents). Maximum of 100 queries are allowed, each 128 characters long. - * @param limit Maximum number of documents to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursor ID of the document used as the starting point for the query, excluding the document itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursorDirection Direction of the cursor. - * @param orderAttributes Array of attributes used to sort results. Maximum of 100 order attributes are allowed, each 128 characters long. - * @param orderTypes Array of order directions for sorting attribtues. Possible values are DESC for descending order, or ASC for ascending order. Maximum of 100 order types are allowed. + * @param databaseId Database ID. + * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. * @return [io.appwrite.models.DocumentList] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun listDocuments( + databaseId: String, collectionId: String, - queries: List? = null, - limit: Long? = null, - offset: Long? = null, - cursor: String? = null, - cursorDirection: String? = null, - orderAttributes: List? = null, - orderTypes: List? = null + queries: List? = null ): io.appwrite.models.DocumentList { - val path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId) + val path = "/databases/{databaseId}/collections/{collectionId}/documents".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId) val params = mutableMapOf( - "queries" to queries, - "limit" to limit, - "offset" to offset, - "cursor" to cursor, - "cursorDirection" to cursorDirection, - "orderAttributes" to orderAttributes, - "orderTypes" to orderTypes + "queries" to queries ) val headers = mutableMapOf( "content-type" to "application/json" @@ -71,31 +57,30 @@ class Database(client: Client) : Service(client) { * * Create a new Document. Before using this route, you should create a new * collection resource using either a [server - * integration](/docs/server/database#databaseCreateCollection) API or + * integration](/docs/server/databases#databasesCreateCollection) API or * directly from your database console. * - * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). Make sure to define attributes before creating documents. + * @param databaseId Database ID. + * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. * @param documentId Document ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param data Document data as JSON object. - * @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. - * @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. + * @param permissions An array of permissions strings. By default the current user is granted with all permissions. [Learn more about permissions](/docs/permissions). * @return [io.appwrite.models.Document] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun createDocument( + databaseId: String, collectionId: String, documentId: String, data: Any, - read: List? = null, - write: List? = null + permissions: List? = null ): io.appwrite.models.Document { - val path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId) + val path = "/databases/{databaseId}/collections/{collectionId}/documents".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId) val params = mutableMapOf( "documentId" to documentId, "data" to data, - "read" to read, - "write" to write + "permissions" to permissions ) val headers = mutableMapOf( "content-type" to "application/json" @@ -119,17 +104,19 @@ class Database(client: Client) : Service(client) { * Get a document by its unique ID. This endpoint response returns a JSON * object with the document data. * - * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). + * @param databaseId Database ID. + * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param documentId Document ID. * @return [io.appwrite.models.Document] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getDocument( + databaseId: String, collectionId: String, documentId: String ): io.appwrite.models.Document { - val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId) + val path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId).replace("{documentId}", documentId) val params = mutableMapOf( ) val headers = mutableMapOf( @@ -154,27 +141,26 @@ class Database(client: Client) : Service(client) { * Update a document by its unique ID. Using the patch method you can pass * only specific fields that will get updated. * + * @param databaseId Database ID. * @param collectionId Collection ID. * @param documentId Document ID. * @param data Document data as JSON object. Include only attribute and value pairs to be updated. - * @param read An array of strings with read permissions. By default inherits the existing read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. - * @param write An array of strings with write permissions. By default inherits the existing write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. + * @param permissions An array of permissions strings. By default the current permissions are inherited. [Learn more about permissions](/docs/permissions). * @return [io.appwrite.models.Document] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun updateDocument( + databaseId: String, collectionId: String, documentId: String, - data: Any, - read: List? = null, - write: List? = null + data: Any? = null, + permissions: List? = null ): io.appwrite.models.Document { - val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId) + val path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId).replace("{documentId}", documentId) val params = mutableMapOf( "data" to data, - "read" to read, - "write" to write + "permissions" to permissions ) val headers = mutableMapOf( "content-type" to "application/json" @@ -197,17 +183,19 @@ class Database(client: Client) : Service(client) { * * Delete a document by its unique ID. * - * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). + * @param databaseId Database ID. + * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param documentId Document ID. * @return [Any] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun deleteDocument( + databaseId: String, collectionId: String, documentId: String ): Any { - val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId) + val path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId).replace("{documentId}", documentId) val params = mutableMapOf( ) val headers = mutableMapOf( diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index 85a1f2c..1c50538 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -8,7 +8,9 @@ import okhttp3.Cookie import okhttp3.Response import java.io.File -class Functions(client: Client) : Service(client) { +class Functions : Service { + + public constructor (client: Client) : super(client) { } /** * Retry Build @@ -49,30 +51,21 @@ class Functions(client: Client) : Service(client) { * different API modes](/docs/admin). * * @param functionId Function ID. - * @param limit Maximum number of executions to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, statusCode, time * @param search Search term to filter your list results. Max length: 256 chars. - * @param cursor ID of the execution used as the starting point for the query, excluding the execution itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursorDirection Direction of the cursor. * @return [io.appwrite.models.ExecutionList] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun listExecutions( functionId: String, - limit: Long? = null, - offset: Long? = null, - search: String? = null, - cursor: String? = null, - cursorDirection: String? = null + queries: List? = null, + search: String? = null ): io.appwrite.models.ExecutionList { val path = "/functions/{functionId}/executions".replace("{functionId}", functionId) val params = mutableMapOf( - "limit" to limit, - "offset" to offset, - "search" to search, - "cursor" to cursor, - "cursorDirection" to cursorDirection + "queries" to queries, + "search" to search ) val headers = mutableMapOf( "content-type" to "application/json" diff --git a/library/src/main/java/io/appwrite/services/Locale.kt b/library/src/main/java/io/appwrite/services/Locale.kt index 21b297c..b4ff685 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -8,7 +8,9 @@ import okhttp3.Cookie import okhttp3.Response import java.io.File -class Locale(client: Client) : Service(client) { +class Locale : Service { + + public constructor (client: Client) : super(client) { } /** * Get User Locale diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index c1e0abc..053e0e6 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -10,7 +10,9 @@ import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import java.io.File -class Storage(client: Client) : Service(client) { +class Storage : Service { + + public constructor (client: Client) : super(client) { } /** * List Files @@ -20,33 +22,21 @@ class Storage(client: Client) : Service(client) { * project's files. [Learn more about different API modes](/docs/admin). * * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket). + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded * @param search Search term to filter your list results. Max length: 256 chars. - * @param limit Maximum number of files to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursor ID of the file used as the starting point for the query, excluding the file itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursorDirection Direction of the cursor. - * @param orderType Order result by ASC or DESC order. * @return [io.appwrite.models.FileList] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun listFiles( bucketId: String, - search: String? = null, - limit: Long? = null, - offset: Long? = null, - cursor: String? = null, - cursorDirection: String? = null, - orderType: String? = null + queries: List? = null, + search: String? = null ): io.appwrite.models.FileList { val path = "/storage/buckets/{bucketId}/files".replace("{bucketId}", bucketId) val params = mutableMapOf( - "search" to search, - "limit" to limit, - "offset" to offset, - "cursor" to cursor, - "cursorDirection" to cursorDirection, - "orderType" to orderType + "queries" to queries, + "search" to search ) val headers = mutableMapOf( "content-type" to "application/json" @@ -69,8 +59,8 @@ class Storage(client: Client) : Service(client) { * * Create a new file. Before using this route, you should create a new bucket * resource using either a [server - * integration](/docs/server/database#storageCreateBucket) API or directly - * from your Appwrite console. + * integration](/docs/server/storage#storageCreateBucket) API or directly from + * your Appwrite console. * * Larger files should be uploaded using multiple requests with the * [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) @@ -89,8 +79,7 @@ class Storage(client: Client) : Service(client) { * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket). * @param fileId File ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param file Binary file. - * @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. - * @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. + * @param permissions An array of permission strings. By default the current user is granted with all permissions. [Learn more about permissions](/docs/permissions). * @return [io.appwrite.models.File] */ @JvmOverloads @@ -98,16 +87,14 @@ class Storage(client: Client) : Service(client) { suspend fun createFile( bucketId: String, fileId: String, - file: File, - read: List? = null, - write: List? = null, onProgress: ((UploadProgress) -> Unit)? = null + file: InputFile, + permissions: List? = null, onProgress: ((UploadProgress) -> Unit)? = null ): io.appwrite.models.File { val path = "/storage/buckets/{bucketId}/files".replace("{bucketId}", bucketId) val params = mutableMapOf( "fileId" to fileId, "file" to file, - "read" to read, - "write" to write + "permissions" to permissions ) val headers = mutableMapOf( "content-type" to "multipart/form-data" @@ -172,8 +159,7 @@ class Storage(client: Client) : Service(client) { * * @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket). * @param fileId File unique ID. - * @param read An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. - * @param write An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions. + * @param permissions An array of permission string. By default the current permissions are inherited. [Learn more about permissions](/docs/permissions). * @return [io.appwrite.models.File] */ @JvmOverloads @@ -181,13 +167,11 @@ class Storage(client: Client) : Service(client) { suspend fun updateFile( bucketId: String, fileId: String, - read: List? = null, - write: List? = null + permissions: List? = null ): io.appwrite.models.File { val path = "/storage/buckets/{bucketId}/files/{fileId}".replace("{bucketId}", bucketId).replace("{fileId}", fileId) val params = mutableMapOf( - "read" to read, - "write" to write + "permissions" to permissions ) val headers = mutableMapOf( "content-type" to "application/json" diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 5b74d1d..46fe9d0 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -8,7 +8,9 @@ import okhttp3.Cookie import okhttp3.Response import java.io.File -class Teams(client: Client) : Service(client) { +class Teams : Service { + + public constructor (client: Client) : super(client) { } /** * List Teams @@ -19,32 +21,20 @@ class Teams(client: Client) : Service(client) { * In admin mode, this endpoint returns a list of all the teams in the current * project. [Learn more about different API modes](/docs/admin). * + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total * @param search Search term to filter your list results. Max length: 256 chars. - * @param limit Maximum number of teams to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursor ID of the team used as the starting point for the query, excluding the team itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursorDirection Direction of the cursor. - * @param orderType Order result by ASC or DESC order. * @return [io.appwrite.models.TeamList] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun list( - search: String? = null, - limit: Long? = null, - offset: Long? = null, - cursor: String? = null, - cursorDirection: String? = null, - orderType: String? = null + queries: List? = null, + search: String? = null ): io.appwrite.models.TeamList { val path = "/teams" val params = mutableMapOf( - "search" to search, - "limit" to limit, - "offset" to offset, - "cursor" to cursor, - "cursorDirection" to cursorDirection, - "orderType" to orderType + "queries" to queries, + "search" to search ) val headers = mutableMapOf( "content-type" to "application/json" @@ -79,7 +69,7 @@ class Teams(client: Client) : Service(client) { suspend fun create( teamId: String, name: String, - roles: List? = null + roles: List? = null ): io.appwrite.models.Team { val path = "/teams" val params = mutableMapOf( @@ -207,33 +197,21 @@ class Teams(client: Client) : Service(client) { * members have read access to this endpoint. * * @param teamId Team ID. + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm * @param search Search term to filter your list results. Max length: 256 chars. - * @param limit Maximum number of memberships to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request. - * @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursor ID of the membership used as the starting point for the query, excluding the membership itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination) - * @param cursorDirection Direction of the cursor. - * @param orderType Order result by ASC or DESC order. * @return [io.appwrite.models.MembershipList] */ @JvmOverloads @Throws(AppwriteException::class) suspend fun getMemberships( teamId: String, - search: String? = null, - limit: Long? = null, - offset: Long? = null, - cursor: String? = null, - cursorDirection: String? = null, - orderType: String? = null + queries: List? = null, + search: String? = null ): io.appwrite.models.MembershipList { val path = "/teams/{teamId}/memberships".replace("{teamId}", teamId) val params = mutableMapOf( - "search" to search, - "limit" to limit, - "offset" to offset, - "cursor" to cursor, - "cursorDirection" to cursorDirection, - "orderType" to orderType + "queries" to queries, + "search" to search ) val headers = mutableMapOf( "content-type" to "application/json" @@ -282,7 +260,7 @@ class Teams(client: Client) : Service(client) { suspend fun createMembership( teamId: String, email: String, - roles: List, + roles: List, url: String, name: String? = null ): io.appwrite.models.Membership { @@ -361,7 +339,7 @@ class Teams(client: Client) : Service(client) { suspend fun updateMembershipRoles( teamId: String, membershipId: String, - roles: List + roles: List ): io.appwrite.models.Membership { val path = "/teams/{teamId}/memberships/{membershipId}".replace("{teamId}", teamId).replace("{membershipId}", membershipId) val params = mutableMapOf(