diff --git a/CHANGELOG.md b/CHANGELOG.md index 31674228..ed8c1769 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +## 25.0.0 + +* Breaking: `avatars.getScreenshot` `theme` parameter now uses the `BrowserTheme` enum +* Breaking: Removed generic type parameters from `presences` service methods +* Added: `BrowserTheme` enum +* Updated: `Presence` model is now concrete and adds a `metadata` field + ## 24.1.1 * Fixed: Removed `Advisor` service and `Insight`, `InsightCTA`, `InsightList`, `Report`, `ReportList` models (admin-only endpoints, not intended for client SDKs) diff --git a/README.md b/README.md index 8e537c17..fadaf5f7 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:24.2.0") +implementation("io.appwrite:sdk-for-android:25.0.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 24.2.0 + 25.0.0 ``` diff --git a/docs/examples/java/avatars/get-screenshot.md b/docs/examples/java/avatars/get-screenshot.md index 2f261c5f..c016ea5f 100644 --- a/docs/examples/java/avatars/get-screenshot.md +++ b/docs/examples/java/avatars/get-screenshot.md @@ -2,7 +2,7 @@ import io.appwrite.Client; import io.appwrite.coroutines.CoroutineCallback; import io.appwrite.services.Avatars; -import io.appwrite.enums.Theme; +import io.appwrite.enums.BrowserTheme; import io.appwrite.enums.Timezone; import io.appwrite.enums.BrowserPermission; import io.appwrite.enums.ImageFormat; @@ -22,7 +22,7 @@ avatars.getScreenshot( 1920, // viewportWidth (optional) 1080, // viewportHeight (optional) 2, // scale (optional) - Theme.LIGHT, // theme (optional) + BrowserTheme.LIGHT, // theme (optional) "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15", // userAgent (optional) true, // fullpage (optional) "en-US", // locale (optional) diff --git a/docs/examples/kotlin/avatars/get-screenshot.md b/docs/examples/kotlin/avatars/get-screenshot.md index 94551fdb..1093c060 100644 --- a/docs/examples/kotlin/avatars/get-screenshot.md +++ b/docs/examples/kotlin/avatars/get-screenshot.md @@ -2,7 +2,7 @@ import io.appwrite.Client import io.appwrite.coroutines.CoroutineCallback import io.appwrite.services.Avatars -import io.appwrite.enums.Theme +import io.appwrite.enums.BrowserTheme import io.appwrite.enums.Timezone import io.appwrite.enums.BrowserPermission import io.appwrite.enums.ImageFormat @@ -22,11 +22,11 @@ val result = avatars.getScreenshot( viewportWidth = 1920, // (optional) viewportHeight = 1080, // (optional) scale = 2, // (optional) - theme = theme.LIGHT, // (optional) + theme = BrowserTheme.LIGHT, // (optional) userAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15", // (optional) fullpage = true, // (optional) locale = "en-US", // (optional) - timezone = timezone.AFRICA_ABIDJAN, // (optional) + timezone = Timezone.AFRICA_ABIDJAN, // (optional) latitude = 37.7749, // (optional) longitude = -122.4194, // (optional) accuracy = 100, // (optional) diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 98d86a3a..f43ec95a 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -94,7 +94,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "24.2.0", + "x-sdk-version" to "25.0.0", "x-appwrite-response-format" to "1.9.5" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/enums/Theme.kt b/library/src/main/java/io/appwrite/enums/BrowserTheme.kt similarity index 82% rename from library/src/main/java/io/appwrite/enums/Theme.kt rename to library/src/main/java/io/appwrite/enums/BrowserTheme.kt index d62acaf2..66584d24 100644 --- a/library/src/main/java/io/appwrite/enums/Theme.kt +++ b/library/src/main/java/io/appwrite/enums/BrowserTheme.kt @@ -2,7 +2,7 @@ package io.appwrite.enums import com.google.gson.annotations.SerializedName -enum class Theme(val value: String) { +enum class BrowserTheme(val value: String) { @SerializedName("light") LIGHT("light"), @SerializedName("dark") diff --git a/library/src/main/java/io/appwrite/models/Document.kt b/library/src/main/java/io/appwrite/models/Document.kt index a192a1dd..c55e6d26 100644 --- a/library/src/main/java/io/appwrite/models/Document.kt +++ b/library/src/main/java/io/appwrite/models/Document.kt @@ -99,7 +99,7 @@ data class Document( createdAt = map["\$createdAt"] as String, updatedAt = map["\$updatedAt"] as String, permissions = map["\$permissions"] as List, - data = map["data"]?.jsonCast(to = nestedType) ?: emptyMap().jsonCast(to = nestedType) + data = map["data"]?.jsonCast(to = nestedType) ?: map.jsonCast(to = nestedType) ) } } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Presence.kt b/library/src/main/java/io/appwrite/models/Presence.kt index d62ddc12..48cde361 100644 --- a/library/src/main/java/io/appwrite/models/Presence.kt +++ b/library/src/main/java/io/appwrite/models/Presence.kt @@ -6,7 +6,7 @@ import io.appwrite.extensions.jsonCast /** * Presence */ -data class Presence( +data class Presence( /** * Presence ID. */ @@ -56,10 +56,11 @@ data class Presence( var expiresAt: String?, /** - * Additional properties + * Presence metadata. */ @SerializedName("metadata") - val metadata: T + var metadata: Any?, + ) { fun toMap(): Map = mapOf( "\$id" to id as Any, @@ -70,37 +71,15 @@ data class Presence( "status" to status as Any, "source" to source as Any, "expiresAt" to expiresAt as Any, - "metadata" to metadata!!.jsonCast(to = Map::class.java) + "metadata" to metadata as Any, ) companion object { - operator fun invoke( - id: String, - createdAt: String, - updatedAt: String, - permissions: List, - userId: String, - status: String?, - source: String, - expiresAt: String?, - metadata: Map - ) = Presence>( - id, - createdAt, - updatedAt, - permissions, - userId, - status, - source, - expiresAt, - metadata - ) @Suppress("UNCHECKED_CAST") - fun from( + fun from( map: Map, - nestedType: Class - ) = Presence( + ) = Presence( id = map["\$id"] as String, createdAt = map["\$createdAt"] as String, updatedAt = map["\$updatedAt"] as String, @@ -109,7 +88,7 @@ data class Presence( status = map["status"] as? String, source = map["source"] as String, expiresAt = map["expiresAt"] as? String, - metadata = map["metadata"]?.jsonCast(to = nestedType) ?: emptyMap().jsonCast(to = nestedType) + metadata = map["metadata"] as? Any, ) } } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/PresenceList.kt b/library/src/main/java/io/appwrite/models/PresenceList.kt index 00d2ac14..b5b9a62a 100644 --- a/library/src/main/java/io/appwrite/models/PresenceList.kt +++ b/library/src/main/java/io/appwrite/models/PresenceList.kt @@ -6,7 +6,7 @@ import io.appwrite.extensions.jsonCast /** * Presences List */ -data class PresenceList( +data class PresenceList( /** * Total number of presences that matched your query. */ @@ -17,7 +17,7 @@ data class PresenceList( * List of presences. */ @SerializedName("presences") - val presences: List>, + val presences: List, ) { fun toMap(): Map = mapOf( @@ -26,21 +26,13 @@ data class PresenceList( ) companion object { - operator fun invoke( - total: Long, - presences: List>>, - ) = PresenceList>( - total, - presences, - ) @Suppress("UNCHECKED_CAST") - fun from( + fun from( map: Map, - nestedType: Class - ) = PresenceList( + ) = PresenceList( total = (map["total"] as Number).toLong(), - presences = (map["presences"] as List>).map { Presence.from(map = it, nestedType) }, + presences = (map["presences"] as List>).map { Presence.from(map = it) }, ) } } \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/Row.kt b/library/src/main/java/io/appwrite/models/Row.kt index c01672e7..488ec7bc 100644 --- a/library/src/main/java/io/appwrite/models/Row.kt +++ b/library/src/main/java/io/appwrite/models/Row.kt @@ -99,7 +99,7 @@ data class Row( createdAt = map["\$createdAt"] as String, updatedAt = map["\$updatedAt"] as String, permissions = map["\$permissions"] as List, - data = map["data"]?.jsonCast(to = nestedType) ?: emptyMap().jsonCast(to = nestedType) + data = map["data"]?.jsonCast(to = nestedType) ?: map.jsonCast(to = nestedType) ) } } \ 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 004440f3..298713c4 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -297,7 +297,7 @@ class Avatars(client: Client) : Service(client) { viewportWidth: Long? = null, viewportHeight: Long? = null, scale: Double? = null, - theme: io.appwrite.enums.Theme? = null, + theme: io.appwrite.enums.BrowserTheme? = null, userAgent: String? = null, fullpage: Boolean? = null, locale: String? = null, diff --git a/library/src/main/java/io/appwrite/services/Presences.kt b/library/src/main/java/io/appwrite/services/Presences.kt index 883fec4f..21d234a6 100644 --- a/library/src/main/java/io/appwrite/services/Presences.kt +++ b/library/src/main/java/io/appwrite/services/Presences.kt @@ -21,15 +21,14 @@ class Presences(client: Client) : Service(client) { * @param queries Array of query strings generated using the Query class provided by the SDK. * @param total When set to false, the total count returned will be 0 and will not be calculated. * @param ttl TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, collection, schema version (attributes and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; document writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Must be between 0 and 86400 (24 hours). - * @return [io.appwrite.models.PresenceList] + * @return [io.appwrite.models.PresenceList] */ @JvmOverloads - suspend fun list( + suspend fun list( queries: List? = null, total: Boolean? = null, ttl: Long? = null, - nestedType: Class, - ): io.appwrite.models.PresenceList { + ): io.appwrite.models.PresenceList { val apiPath = "/presences" val apiParams = mutableMapOf( @@ -39,53 +38,31 @@ class Presences(client: Client) : Service(client) { ) val apiHeaders = mutableMapOf( ) - val converter: (Any) -> io.appwrite.models.PresenceList = { + val converter: (Any) -> io.appwrite.models.PresenceList = { @Suppress("UNCHECKED_CAST") - io.appwrite.models.PresenceList.from(map = it as Map, nestedType) + io.appwrite.models.PresenceList.from(map = it as Map) } return client.call( "GET", apiPath, apiHeaders, apiParams, - responseType = classOf(), + responseType = io.appwrite.models.PresenceList::class.java, converter, ) } - /** - * List presence logs. Expired entries are filtered out automatically. - * - * - * @param queries Array of query strings generated using the Query class provided by the SDK. - * @param total When set to false, the total count returned will be 0 and will not be calculated. - * @param ttl TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, collection, schema version (attributes and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; document writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Must be between 0 and 86400 (24 hours). - * @return [io.appwrite.models.PresenceList] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun list( - queries: List? = null, - total: Boolean? = null, - ttl: Long? = null, - ): io.appwrite.models.PresenceList> = list( - queries, - total, - ttl, - nestedType = classOf(), - ) /** * Get a presence log by its unique ID. Entries whose `expiresAt` is in the past are treated as not found. * * * @param presenceId Presence unique ID. - * @return [io.appwrite.models.Presence] + * @return [io.appwrite.models.Presence] */ - suspend fun get( + suspend fun get( presenceId: String, - nestedType: Class, - ): io.appwrite.models.Presence { + ): io.appwrite.models.Presence { val apiPath = "/presences/{presenceId}" .replace("{presenceId}", presenceId) @@ -93,34 +70,20 @@ class Presences(client: Client) : Service(client) { ) val apiHeaders = mutableMapOf( ) - val converter: (Any) -> io.appwrite.models.Presence = { + val converter: (Any) -> io.appwrite.models.Presence = { @Suppress("UNCHECKED_CAST") - io.appwrite.models.Presence.from(map = it as Map, nestedType) + io.appwrite.models.Presence.from(map = it as Map) } return client.call( "GET", apiPath, apiHeaders, apiParams, - responseType = classOf(), + responseType = io.appwrite.models.Presence::class.java, converter, ) } - /** - * Get a presence log by its unique ID. Entries whose `expiresAt` is in the past are treated as not found. - * - * - * @param presenceId Presence unique ID. - * @return [io.appwrite.models.Presence] - */ - @Throws(AppwriteException::class) - suspend fun get( - presenceId: String, - ): io.appwrite.models.Presence> = get( - presenceId, - nestedType = classOf(), - ) /** * Create or update a presence log by its user ID. @@ -131,17 +94,16 @@ class Presences(client: Client) : Service(client) { * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param expiresAt Presence expiry datetime. * @param metadata Presence metadata object. - * @return [io.appwrite.models.Presence] + * @return [io.appwrite.models.Presence] */ @JvmOverloads - suspend fun upsert( + suspend fun upsert( presenceId: String, status: String, permissions: List? = null, expiresAt: String? = null, metadata: Any? = null, - nestedType: Class, - ): io.appwrite.models.Presence { + ): io.appwrite.models.Presence { val apiPath = "/presences/{presenceId}" .replace("{presenceId}", presenceId) @@ -154,47 +116,20 @@ class Presences(client: Client) : Service(client) { val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.Presence = { + val converter: (Any) -> io.appwrite.models.Presence = { @Suppress("UNCHECKED_CAST") - io.appwrite.models.Presence.from(map = it as Map, nestedType) + io.appwrite.models.Presence.from(map = it as Map) } return client.call( "PUT", apiPath, apiHeaders, apiParams, - responseType = classOf(), + responseType = io.appwrite.models.Presence::class.java, converter, ) } - /** - * Create or update a presence log by its user ID. - * - * - * @param presenceId Presence unique ID. - * @param status Presence status. - * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param expiresAt Presence expiry datetime. - * @param metadata Presence metadata object. - * @return [io.appwrite.models.Presence] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun upsert( - presenceId: String, - status: String, - permissions: List? = null, - expiresAt: String? = null, - metadata: Any? = null, - ): io.appwrite.models.Presence> = upsert( - presenceId, - status, - permissions, - expiresAt, - metadata, - nestedType = classOf(), - ) /** * Update a presence log by its unique ID. Using the patch method you can pass only specific fields that will get updated. @@ -206,18 +141,17 @@ class Presences(client: Client) : Service(client) { * @param metadata Presence metadata object. * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param purge When true, purge cached responses used by list presences endpoint. - * @return [io.appwrite.models.Presence] + * @return [io.appwrite.models.Presence] */ @JvmOverloads - suspend fun update( + suspend fun update( presenceId: String, status: String? = null, expiresAt: String? = null, metadata: Any? = null, permissions: List? = null, purge: Boolean? = null, - nestedType: Class, - ): io.appwrite.models.Presence { + ): io.appwrite.models.Presence { val apiPath = "/presences/{presenceId}" .replace("{presenceId}", presenceId) @@ -231,50 +165,20 @@ class Presences(client: Client) : Service(client) { val apiHeaders = mutableMapOf( "content-type" to "application/json", ) - val converter: (Any) -> io.appwrite.models.Presence = { + val converter: (Any) -> io.appwrite.models.Presence = { @Suppress("UNCHECKED_CAST") - io.appwrite.models.Presence.from(map = it as Map, nestedType) + io.appwrite.models.Presence.from(map = it as Map) } return client.call( "PATCH", apiPath, apiHeaders, apiParams, - responseType = classOf(), + responseType = io.appwrite.models.Presence::class.java, converter, ) } - /** - * Update a presence log by its unique ID. Using the patch method you can pass only specific fields that will get updated. - * - * - * @param presenceId Presence unique ID. - * @param status Presence status. - * @param expiresAt Presence expiry datetime. - * @param metadata Presence metadata object. - * @param permissions An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param purge When true, purge cached responses used by list presences endpoint. - * @return [io.appwrite.models.Presence] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun update( - presenceId: String, - status: String? = null, - expiresAt: String? = null, - metadata: Any? = null, - permissions: List? = null, - purge: Boolean? = null, - ): io.appwrite.models.Presence> = update( - presenceId, - status, - expiresAt, - metadata, - permissions, - purge, - nestedType = classOf(), - ) /** * Delete a presence log by its unique ID.