diff --git a/README.md b/README.md
index 745f21c..db65d39 100644
--- a/README.md
+++ b/README.md
@@ -38,7 +38,7 @@ repositories {
Next, add the dependency to your project's `build.gradle(.kts)` file:
```groovy
-implementation("io.appwrite:sdk-for-android:8.2.0")
+implementation("io.appwrite:sdk-for-android:8.2.2")
```
### Maven
@@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file:
io.appwrite
sdk-for-android
- 8.2.0
+ 8.2.2
```
@@ -75,7 +75,7 @@ In order to capture the Appwrite OAuth callback url, the following activity need
-
+
@@ -91,8 +91,8 @@ import io.appwrite.Client
import io.appwrite.services.Account
val client = Client(context)
- .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
- .setProject("5df5acd0d48c2") // Your project ID
+ .setEndpoint("https:///v1") // Your API Endpoint
+ .setProject("") // Your project ID
.setSelfSigned(true) // Remove in production
```
@@ -123,8 +123,8 @@ import io.appwrite.services.Account
import io.appwrite.ID
val client = Client(context)
- .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
- .setProject("5df5acd0d48c2") // Your project ID
+ .setEndpoint("https:///v1") // Your API Endpoint
+ .setProject("") // Your project ID
.setSelfSigned(true) // Remove in production
val account = Account(client)
@@ -136,7 +136,134 @@ val user = account.create(
)
```
+### Type Safety with Models
+
+The Appwrite Android SDK provides type safety when working with database documents through generic methods. Methods like `listDocuments`, `getDocument`, and others accept a `nestedType` parameter that allows you to specify your custom model type for full type safety.
+
+**Kotlin:**
+```kotlin
+data class Book(
+ val name: String,
+ val author: String,
+ val releaseYear: String? = null,
+ val category: String? = null,
+ val genre: List? = null,
+ val isCheckedOut: Boolean
+)
+
+val databases = Databases(client)
+
+try {
+ val documents = databases.listDocuments(
+ databaseId = "your-database-id",
+ collectionId = "your-collection-id",
+ nestedType = Book::class.java // Pass in your custom model type
+ )
+
+ for (book in documents.documents) {
+ Log.d("Appwrite", "Book: ${book.name} by ${book.author}") // Now you have full type safety
+ }
+} catch (e: AppwriteException) {
+ Log.e("Appwrite", e.message ?: "Unknown error")
+}
+```
+
+**Java:**
+```java
+public class Book {
+ private String name;
+ private String author;
+ private String releaseYear;
+ private String category;
+ private List genre;
+ private boolean isCheckedOut;
+
+ // Constructor
+ public Book(String name, String author, boolean isCheckedOut) {
+ this.name = name;
+ this.author = author;
+ this.isCheckedOut = isCheckedOut;
+ }
+
+ // Getters and setters
+ public String getName() { return name; }
+ public void setName(String name) { this.name = name; }
+
+ public String getAuthor() { return author; }
+ public void setAuthor(String author) { this.author = author; }
+
+ public String getReleaseYear() { return releaseYear; }
+ public void setReleaseYear(String releaseYear) { this.releaseYear = releaseYear; }
+
+ public String getCategory() { return category; }
+ public void setCategory(String category) { this.category = category; }
+
+ public List getGenre() { return genre; }
+ public void setGenre(List genre) { this.genre = genre; }
+
+ public boolean isCheckedOut() { return isCheckedOut; }
+ public void setCheckedOut(boolean checkedOut) { isCheckedOut = checkedOut; }
+}
+
+Databases databases = new Databases(client);
+
+try {
+ DocumentList documents = databases.listDocuments(
+ "your-database-id",
+ "your-collection-id",
+ Book.class // Pass in your custom model type
+ );
+
+ for (Book book : documents.getDocuments()) {
+ Log.d("Appwrite", "Book: " + book.getName() + " by " + book.getAuthor()); // Now you have full type safety
+ }
+} catch (AppwriteException e) {
+ Log.e("Appwrite", e.getMessage() != null ? e.getMessage() : "Unknown error");
+}
+```
+
+**Tip**: You can use the `appwrite types` command to automatically generate model definitions based on your Appwrite database schema. Learn more about [type generation](https://appwrite.io/docs/products/databases/type-generation).
+
+### Working with Model Methods
+
+All Appwrite models come with built-in methods for data conversion and manipulation:
+
+**`toMap()`** - Converts a model instance to a Map format, useful for debugging or manual data manipulation:
+```kotlin
+val account = Account(client)
+val user = account.get()
+val userMap = user.toMap()
+Log.d("Appwrite", userMap.toString()) // Prints all user properties as a Map
+```
+
+**`from(map:, nestedType:)`** - Creates a model instance from a Map, useful when working with raw data:
+```kotlin
+val userData: Map = mapOf(
+ "\$id" to "123",
+ "name" to "John",
+ "email" to "john@example.com"
+)
+val user = User.from(userData, User::class.java)
+```
+
+**JSON Serialization** - Models can be easily converted to/from JSON using Gson (which the SDK uses internally):
+```kotlin
+import com.google.gson.Gson
+
+val account = Account(client)
+val user = account.get()
+
+// Convert to JSON
+val gson = Gson()
+val jsonString = gson.toJson(user)
+Log.d("Appwrite", "User JSON: $jsonString")
+
+// Convert from JSON
+val userFromJson = gson.fromJson(jsonString, User::class.java)
+```
+
### Error Handling
+
The Appwrite Android SDK raises an `AppwriteException` object with `message`, `code` and `response` properties. You can handle any errors by catching `AppwriteException` and present the `message` to the user or handle it yourself based on the provided error information. Below is an example.
```kotlin
diff --git a/docs/examples/java/functions/create-execution.md b/docs/examples/java/functions/create-execution.md
index c138b0e..06c5027 100644
--- a/docs/examples/java/functions/create-execution.md
+++ b/docs/examples/java/functions/create-execution.md
@@ -15,7 +15,7 @@ functions.createExecution(
"", // path (optional)
ExecutionMethod.GET, // method (optional)
mapOf( "a" to "b" ), // headers (optional)
- "", // scheduledAt (optional)
+ "", // scheduledAt (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
diff --git a/docs/examples/kotlin/functions/create-execution.md b/docs/examples/kotlin/functions/create-execution.md
index cb7c60b..5e1950b 100644
--- a/docs/examples/kotlin/functions/create-execution.md
+++ b/docs/examples/kotlin/functions/create-execution.md
@@ -15,5 +15,5 @@ val result = functions.createExecution(
path = "", // (optional)
method = ExecutionMethod.GET, // (optional)
headers = mapOf( "a" to "b" ), // (optional)
- scheduledAt = "", // (optional)
+ scheduledAt = "", // (optional)
)
\ No newline at end of file
diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt
index bf0480f..1dbeda8 100644
--- a/library/src/main/java/io/appwrite/Client.kt
+++ b/library/src/main/java/io/appwrite/Client.kt
@@ -87,7 +87,7 @@ class Client @JvmOverloads constructor(
"x-sdk-name" to "Android",
"x-sdk-platform" to "client",
"x-sdk-language" to "android",
- "x-sdk-version" to "8.2.0",
+ "x-sdk-version" to "8.2.2",
"x-appwrite-response-format" to "1.7.0"
)
config = mutableMapOf()
diff --git a/scripts/publish-config.gradle b/scripts/publish-config.gradle
index 299c6c4..5934f92 100644
--- a/scripts/publish-config.gradle
+++ b/scripts/publish-config.gradle
@@ -30,8 +30,8 @@ nexusPublishing {
stagingProfileId = sonatypeStagingProfileId
username = ossrhUsername
password = ossrhPassword
- nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
- snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
+ nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
+ snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
}
}
}
\ No newline at end of file