diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b22d7e..fd1a484 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 25.2.0 + +* Added: Realtime connections now send an `x-appwrite-jwt` header for authentication. +* Added: Forwarded `impersonateUserId` on `avatars` and `storage` file requests. + ## 25.1.0 * Added: Email metadata fields to `User` (`emailCanonical`, `emailIsFree`, `emailIsDisposable`, `emailIsCorporate`, `emailIsCanonical`). diff --git a/README.md b/README.md index 74bd317..5ccbd23 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:25.1.0") +implementation("io.appwrite:sdk-for-android:25.2.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 25.1.0 + 25.2.0 ``` diff --git a/docs/examples/java/account/create.md b/docs/examples/java/account/create.md index 333b1f3..9cf0a72 100644 --- a/docs/examples/java/account/create.md +++ b/docs/examples/java/account/create.md @@ -12,7 +12,7 @@ Account account = new Account(client); account.create( "", // userId "email@example.com", // email - "", // password + "password", // password "", // name (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { diff --git a/docs/examples/java/account/update-password.md b/docs/examples/java/account/update-password.md index 93562d5..9d07bdb 100644 --- a/docs/examples/java/account/update-password.md +++ b/docs/examples/java/account/update-password.md @@ -10,8 +10,8 @@ Client client = new Client(context) Account account = new Account(client); account.updatePassword( - "", // password - "", // oldPassword (optional) + "password", // password + "password", // oldPassword (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/account/update-recovery.md b/docs/examples/java/account/update-recovery.md index 2ea21c9..ce60d60 100644 --- a/docs/examples/java/account/update-recovery.md +++ b/docs/examples/java/account/update-recovery.md @@ -12,7 +12,7 @@ Account account = new Account(client); account.updateRecovery( "", // userId "", // secret - "", // password + "password", // password new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/kotlin/account/create.md b/docs/examples/kotlin/account/create.md index 9f80913..8e7f12c 100644 --- a/docs/examples/kotlin/account/create.md +++ b/docs/examples/kotlin/account/create.md @@ -12,7 +12,7 @@ val account = Account(client) val result = account.create( userId = "", email = "email@example.com", - password = "", + password = "password", name = "", // (optional) ) ``` diff --git a/docs/examples/kotlin/account/update-password.md b/docs/examples/kotlin/account/update-password.md index dd8a06b..1ec378a 100644 --- a/docs/examples/kotlin/account/update-password.md +++ b/docs/examples/kotlin/account/update-password.md @@ -10,7 +10,7 @@ val client = Client(context) val account = Account(client) val result = account.updatePassword( - password = "", - oldPassword = "", // (optional) + password = "password", + oldPassword = "password", // (optional) ) ``` diff --git a/docs/examples/kotlin/account/update-recovery.md b/docs/examples/kotlin/account/update-recovery.md index 8e16074..c182625 100644 --- a/docs/examples/kotlin/account/update-recovery.md +++ b/docs/examples/kotlin/account/update-recovery.md @@ -12,6 +12,6 @@ val account = Account(client) val result = account.updateRecovery( userId = "", secret = "", - password = "", + password = "password", ) ``` diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index f51628d..12b1212 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 "25.1.0", + "x-sdk-version" to "25.2.0", "x-appwrite-response-format" to "1.9.5" ) config = mutableMapOf() @@ -192,7 +192,7 @@ class Client @JvmOverloads constructor( /** * Set ImpersonateUserId * - * Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + * Impersonate a user by ID * * @param {string} impersonateuserid * @@ -207,7 +207,7 @@ class Client @JvmOverloads constructor( /** * Set ImpersonateUserEmail * - * Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + * Impersonate a user by email * * @param {string} impersonateuseremail * @@ -222,7 +222,7 @@ class Client @JvmOverloads constructor( /** * Set ImpersonateUserPhone * - * Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + * Impersonate a user by phone * * @param {string} impersonateuserphone * @@ -358,7 +358,7 @@ class Client @JvmOverloads constructor( fun getHttpClient(): OkHttpClient = http /** - * Sends a "ping" request to Appwrite to verify connectivity. + * Send a ping to project as part of onboarding. * * @return String */ @@ -366,8 +366,8 @@ class Client @JvmOverloads constructor( val apiPath = "/ping" val apiParams = mutableMapOf() val apiHeaders = mutableMapOf( - "content-type" to "application/json", "X-Appwrite-Project" to config["project"].orEmpty(), + "accept" to "application/json", ) return call( diff --git a/library/src/main/java/io/appwrite/services/Account.kt b/library/src/main/java/io/appwrite/services/Account.kt index 5f9ee7b..25c4463 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -26,7 +26,8 @@ class Account(client: Client) : Service(client) { suspend fun get( nestedType: Class, ): io.appwrite.models.User { - val apiPath = "/account" + val apiPath = ("/account" + ) val apiParams = mutableMapOf( ) @@ -76,7 +77,8 @@ class Account(client: Client) : Service(client) { name: String? = null, nestedType: Class, ): io.appwrite.models.User { - val apiPath = "/account" + val apiPath = ("/account" + ) val apiParams = mutableMapOf( "userId" to userId, @@ -141,7 +143,8 @@ class Account(client: Client) : Service(client) { password: String, nestedType: Class, ): io.appwrite.models.User { - val apiPath = "/account/email" + val apiPath = ("/account/email" + ) val apiParams = mutableMapOf( "email" to email, @@ -197,7 +200,8 @@ class Account(client: Client) : Service(client) { queries: List? = null, total: Boolean? = null, ): io.appwrite.models.IdentityList { - val apiPath = "/account/identities" + val apiPath = ("/account/identities" + ) val apiParams = mutableMapOf( "queries" to queries, @@ -231,8 +235,9 @@ class Account(client: Client) : Service(client) { suspend fun deleteIdentity( identityId: String, ): Any { - val apiPath = "/account/identities/{identityId}" + val apiPath = ("/account/identities/{identityId}" .replace("{identityId}", identityId) + ) val apiParams = mutableMapOf( ) @@ -260,7 +265,8 @@ class Account(client: Client) : Service(client) { suspend fun createJWT( duration: Long? = null, ): io.appwrite.models.Jwt { - val apiPath = "/account/jwts" + val apiPath = ("/account/jwts" + ) val apiParams = mutableMapOf( "duration" to duration, @@ -297,7 +303,8 @@ class Account(client: Client) : Service(client) { queries: List? = null, total: Boolean? = null, ): io.appwrite.models.LogList { - val apiPath = "/account/logs" + val apiPath = ("/account/logs" + ) val apiParams = mutableMapOf( "queries" to queries, @@ -332,7 +339,8 @@ class Account(client: Client) : Service(client) { mfa: Boolean, nestedType: Class, ): io.appwrite.models.User { - val apiPath = "/account/mfa" + val apiPath = ("/account/mfa" + ) val apiParams = mutableMapOf( "mfa" to mfa, @@ -383,8 +391,9 @@ class Account(client: Client) : Service(client) { suspend fun createMfaAuthenticator( type: io.appwrite.enums.AuthenticatorType, ): io.appwrite.models.MfaType { - val apiPath = "/account/mfa/authenticators/{type}" + val apiPath = ("/account/mfa/authenticators/{type}" .replace("{type}", type.value) + ) val apiParams = mutableMapOf( ) @@ -417,8 +426,9 @@ class Account(client: Client) : Service(client) { suspend fun createMFAAuthenticator( type: io.appwrite.enums.AuthenticatorType, ): io.appwrite.models.MfaType { - val apiPath = "/account/mfa/authenticators/{type}" + val apiPath = ("/account/mfa/authenticators/{type}" .replace("{type}", type.value) + ) val apiParams = mutableMapOf( ) @@ -458,8 +468,9 @@ class Account(client: Client) : Service(client) { otp: String, nestedType: Class, ): io.appwrite.models.User { - val apiPath = "/account/mfa/authenticators/{type}" + val apiPath = ("/account/mfa/authenticators/{type}" .replace("{type}", type.value) + ) val apiParams = mutableMapOf( "otp" to otp, @@ -516,8 +527,9 @@ class Account(client: Client) : Service(client) { otp: String, nestedType: Class, ): io.appwrite.models.User { - val apiPath = "/account/mfa/authenticators/{type}" + val apiPath = ("/account/mfa/authenticators/{type}" .replace("{type}", type.value) + ) val apiParams = mutableMapOf( "otp" to otp, @@ -571,8 +583,9 @@ class Account(client: Client) : Service(client) { suspend fun deleteMfaAuthenticator( type: io.appwrite.enums.AuthenticatorType, ): Any { - val apiPath = "/account/mfa/authenticators/{type}" + val apiPath = ("/account/mfa/authenticators/{type}" .replace("{type}", type.value) + ) val apiParams = mutableMapOf( ) @@ -599,8 +612,9 @@ class Account(client: Client) : Service(client) { suspend fun deleteMFAAuthenticator( type: io.appwrite.enums.AuthenticatorType, ): Any { - val apiPath = "/account/mfa/authenticators/{type}" + val apiPath = ("/account/mfa/authenticators/{type}" .replace("{type}", type.value) + ) val apiParams = mutableMapOf( ) @@ -631,7 +645,8 @@ class Account(client: Client) : Service(client) { suspend fun createMfaChallenge( factor: io.appwrite.enums.AuthenticationFactor, ): io.appwrite.models.MfaChallenge { - val apiPath = "/account/mfa/challenges" + val apiPath = ("/account/mfa/challenges" + ) val apiParams = mutableMapOf( "factor" to factor, @@ -665,7 +680,8 @@ class Account(client: Client) : Service(client) { suspend fun createMFAChallenge( factor: io.appwrite.enums.AuthenticationFactor, ): io.appwrite.models.MfaChallenge { - val apiPath = "/account/mfa/challenges" + val apiPath = ("/account/mfa/challenges" + ) val apiParams = mutableMapOf( "factor" to factor, @@ -705,7 +721,8 @@ class Account(client: Client) : Service(client) { challengeId: String, otp: String, ): io.appwrite.models.Session { - val apiPath = "/account/mfa/challenges" + val apiPath = ("/account/mfa/challenges" + ) val apiParams = mutableMapOf( "challengeId" to challengeId, @@ -742,7 +759,8 @@ class Account(client: Client) : Service(client) { challengeId: String, otp: String, ): io.appwrite.models.Session { - val apiPath = "/account/mfa/challenges" + val apiPath = ("/account/mfa/challenges" + ) val apiParams = mutableMapOf( "challengeId" to challengeId, @@ -779,7 +797,8 @@ class Account(client: Client) : Service(client) { ) suspend fun listMfaFactors( ): io.appwrite.models.MfaFactors { - val apiPath = "/account/mfa/factors" + val apiPath = ("/account/mfa/factors" + ) val apiParams = mutableMapOf( ) @@ -809,7 +828,8 @@ class Account(client: Client) : Service(client) { */ suspend fun listMFAFactors( ): io.appwrite.models.MfaFactors { - val apiPath = "/account/mfa/factors" + val apiPath = ("/account/mfa/factors" + ) val apiParams = mutableMapOf( ) @@ -843,7 +863,8 @@ class Account(client: Client) : Service(client) { ) suspend fun getMfaRecoveryCodes( ): io.appwrite.models.MfaRecoveryCodes { - val apiPath = "/account/mfa/recovery-codes" + val apiPath = ("/account/mfa/recovery-codes" + ) val apiParams = mutableMapOf( ) @@ -873,7 +894,8 @@ class Account(client: Client) : Service(client) { */ suspend fun getMFARecoveryCodes( ): io.appwrite.models.MfaRecoveryCodes { - val apiPath = "/account/mfa/recovery-codes" + val apiPath = ("/account/mfa/recovery-codes" + ) val apiParams = mutableMapOf( ) @@ -907,7 +929,8 @@ class Account(client: Client) : Service(client) { ) suspend fun createMfaRecoveryCodes( ): io.appwrite.models.MfaRecoveryCodes { - val apiPath = "/account/mfa/recovery-codes" + val apiPath = ("/account/mfa/recovery-codes" + ) val apiParams = mutableMapOf( ) @@ -938,7 +961,8 @@ class Account(client: Client) : Service(client) { */ suspend fun createMFARecoveryCodes( ): io.appwrite.models.MfaRecoveryCodes { - val apiPath = "/account/mfa/recovery-codes" + val apiPath = ("/account/mfa/recovery-codes" + ) val apiParams = mutableMapOf( ) @@ -973,7 +997,8 @@ class Account(client: Client) : Service(client) { ) suspend fun updateMfaRecoveryCodes( ): io.appwrite.models.MfaRecoveryCodes { - val apiPath = "/account/mfa/recovery-codes" + val apiPath = ("/account/mfa/recovery-codes" + ) val apiParams = mutableMapOf( ) @@ -1004,7 +1029,8 @@ class Account(client: Client) : Service(client) { */ suspend fun updateMFARecoveryCodes( ): io.appwrite.models.MfaRecoveryCodes { - val apiPath = "/account/mfa/recovery-codes" + val apiPath = ("/account/mfa/recovery-codes" + ) val apiParams = mutableMapOf( ) @@ -1038,7 +1064,8 @@ class Account(client: Client) : Service(client) { name: String, nestedType: Class, ): io.appwrite.models.User { - val apiPath = "/account/name" + val apiPath = ("/account/name" + ) val apiParams = mutableMapOf( "name" to name, @@ -1089,7 +1116,8 @@ class Account(client: Client) : Service(client) { oldPassword: String? = null, nestedType: Class, ): io.appwrite.models.User { - val apiPath = "/account/password" + val apiPath = ("/account/password" + ) val apiParams = mutableMapOf( "password" to password, @@ -1144,7 +1172,8 @@ class Account(client: Client) : Service(client) { password: String, nestedType: Class, ): io.appwrite.models.User { - val apiPath = "/account/phone" + val apiPath = ("/account/phone" + ) val apiParams = mutableMapOf( "phone" to phone, @@ -1194,7 +1223,8 @@ class Account(client: Client) : Service(client) { suspend fun getPrefs( nestedType: Class, ): io.appwrite.models.Preferences { - val apiPath = "/account/prefs" + val apiPath = ("/account/prefs" + ) val apiParams = mutableMapOf( ) @@ -1237,7 +1267,8 @@ class Account(client: Client) : Service(client) { prefs: Any, nestedType: Class, ): io.appwrite.models.User { - val apiPath = "/account/prefs" + val apiPath = ("/account/prefs" + ) val apiParams = mutableMapOf( "prefs" to prefs, @@ -1286,7 +1317,8 @@ class Account(client: Client) : Service(client) { email: String, url: String, ): io.appwrite.models.Token { - val apiPath = "/account/recovery" + val apiPath = ("/account/recovery" + ) val apiParams = mutableMapOf( "email" to email, @@ -1327,7 +1359,8 @@ class Account(client: Client) : Service(client) { secret: String, password: String, ): io.appwrite.models.Token { - val apiPath = "/account/recovery" + val apiPath = ("/account/recovery" + ) val apiParams = mutableMapOf( "userId" to userId, @@ -1361,7 +1394,8 @@ class Account(client: Client) : Service(client) { */ suspend fun listSessions( ): io.appwrite.models.SessionList { - val apiPath = "/account/sessions" + val apiPath = ("/account/sessions" + ) val apiParams = mutableMapOf( ) @@ -1391,7 +1425,8 @@ class Account(client: Client) : Service(client) { */ suspend fun deleteSessions( ): Any { - val apiPath = "/account/sessions" + val apiPath = ("/account/sessions" + ) val apiParams = mutableMapOf( ) @@ -1416,7 +1451,8 @@ class Account(client: Client) : Service(client) { */ suspend fun createAnonymousSession( ): io.appwrite.models.Session { - val apiPath = "/account/sessions/anonymous" + val apiPath = ("/account/sessions/anonymous" + ) val apiParams = mutableMapOf( ) @@ -1453,7 +1489,8 @@ class Account(client: Client) : Service(client) { email: String, password: String, ): io.appwrite.models.Session { - val apiPath = "/account/sessions/email" + val apiPath = ("/account/sessions/email" + ) val apiParams = mutableMapOf( "email" to email, @@ -1494,7 +1531,8 @@ class Account(client: Client) : Service(client) { userId: String, secret: String, ): io.appwrite.models.Session { - val apiPath = "/account/sessions/magic-url" + val apiPath = ("/account/sessions/magic-url" + ) val apiParams = mutableMapOf( "userId" to userId, @@ -1541,8 +1579,9 @@ class Account(client: Client) : Service(client) { failure: String? = null, scopes: List? = null, ) { - val apiPath = "/account/sessions/oauth2/{provider}" + val apiPath = ("/account/sessions/oauth2/{provider}" .replace("{provider}", provider.value) + ) val apiParams = mutableMapOf( "success" to success, @@ -1612,7 +1651,8 @@ class Account(client: Client) : Service(client) { userId: String, secret: String, ): io.appwrite.models.Session { - val apiPath = "/account/sessions/phone" + val apiPath = ("/account/sessions/phone" + ) val apiParams = mutableMapOf( "userId" to userId, @@ -1649,7 +1689,8 @@ class Account(client: Client) : Service(client) { userId: String, secret: String, ): io.appwrite.models.Session { - val apiPath = "/account/sessions/token" + val apiPath = ("/account/sessions/token" + ) val apiParams = mutableMapOf( "userId" to userId, @@ -1684,8 +1725,9 @@ class Account(client: Client) : Service(client) { suspend fun getSession( sessionId: String, ): io.appwrite.models.Session { - val apiPath = "/account/sessions/{sessionId}" + val apiPath = ("/account/sessions/{sessionId}" .replace("{sessionId}", sessionId) + ) val apiParams = mutableMapOf( ) @@ -1717,8 +1759,9 @@ class Account(client: Client) : Service(client) { suspend fun updateSession( sessionId: String, ): io.appwrite.models.Session { - val apiPath = "/account/sessions/{sessionId}" + val apiPath = ("/account/sessions/{sessionId}" .replace("{sessionId}", sessionId) + ) val apiParams = mutableMapOf( ) @@ -1751,8 +1794,9 @@ class Account(client: Client) : Service(client) { suspend fun deleteSession( sessionId: String, ): Any { - val apiPath = "/account/sessions/{sessionId}" + val apiPath = ("/account/sessions/{sessionId}" .replace("{sessionId}", sessionId) + ) val apiParams = mutableMapOf( ) @@ -1778,7 +1822,8 @@ class Account(client: Client) : Service(client) { suspend fun updateStatus( nestedType: Class, ): io.appwrite.models.User { - val apiPath = "/account/status" + val apiPath = ("/account/status" + ) val apiParams = mutableMapOf( ) @@ -1826,7 +1871,8 @@ class Account(client: Client) : Service(client) { identifier: String, providerId: String? = null, ): io.appwrite.models.Target { - val apiPath = "/account/targets/push" + val apiPath = ("/account/targets/push" + ) val apiParams = mutableMapOf( "targetId" to targetId, @@ -1864,8 +1910,9 @@ class Account(client: Client) : Service(client) { targetId: String, identifier: String, ): io.appwrite.models.Target { - val apiPath = "/account/targets/{targetId}/push" + val apiPath = ("/account/targets/{targetId}/push" .replace("{targetId}", targetId) + ) val apiParams = mutableMapOf( "identifier" to identifier, @@ -1899,8 +1946,9 @@ class Account(client: Client) : Service(client) { suspend fun deletePushTarget( targetId: String, ): Any { - val apiPath = "/account/targets/{targetId}/push" + val apiPath = ("/account/targets/{targetId}/push" .replace("{targetId}", targetId) + ) val apiParams = mutableMapOf( ) @@ -1935,7 +1983,8 @@ class Account(client: Client) : Service(client) { email: String, phrase: Boolean? = null, ): io.appwrite.models.Token { - val apiPath = "/account/tokens/email" + val apiPath = ("/account/tokens/email" + ) val apiParams = mutableMapOf( "userId" to userId, @@ -1981,7 +2030,8 @@ class Account(client: Client) : Service(client) { url: String? = null, phrase: Boolean? = null, ): io.appwrite.models.Token { - val apiPath = "/account/tokens/magic-url" + val apiPath = ("/account/tokens/magic-url" + ) val apiParams = mutableMapOf( "userId" to userId, @@ -2029,8 +2079,9 @@ class Account(client: Client) : Service(client) { failure: String? = null, scopes: List? = null, ) { - val apiPath = "/account/tokens/oauth2/{provider}" + val apiPath = ("/account/tokens/oauth2/{provider}" .replace("{provider}", provider.value) + ) val apiParams = mutableMapOf( "success" to success, @@ -2098,7 +2149,8 @@ class Account(client: Client) : Service(client) { userId: String, phone: String, ): io.appwrite.models.Token { - val apiPath = "/account/tokens/phone" + val apiPath = ("/account/tokens/phone" + ) val apiParams = mutableMapOf( "userId" to userId, @@ -2136,7 +2188,8 @@ class Account(client: Client) : Service(client) { suspend fun createEmailVerification( url: String, ): io.appwrite.models.Token { - val apiPath = "/account/verifications/email" + val apiPath = ("/account/verifications/email" + ) val apiParams = mutableMapOf( "url" to url, @@ -2177,7 +2230,8 @@ class Account(client: Client) : Service(client) { suspend fun createVerification( url: String, ): io.appwrite.models.Token { - val apiPath = "/account/verifications/email" + val apiPath = ("/account/verifications/email" + ) val apiParams = mutableMapOf( "url" to url, @@ -2213,7 +2267,8 @@ class Account(client: Client) : Service(client) { userId: String, secret: String, ): io.appwrite.models.Token { - val apiPath = "/account/verifications/email" + val apiPath = ("/account/verifications/email" + ) val apiParams = mutableMapOf( "userId" to userId, @@ -2254,7 +2309,8 @@ class Account(client: Client) : Service(client) { userId: String, secret: String, ): io.appwrite.models.Token { - val apiPath = "/account/verifications/email" + val apiPath = ("/account/verifications/email" + ) val apiParams = mutableMapOf( "userId" to userId, @@ -2287,7 +2343,8 @@ class Account(client: Client) : Service(client) { */ suspend fun createPhoneVerification( ): io.appwrite.models.Token { - val apiPath = "/account/verifications/phone" + val apiPath = ("/account/verifications/phone" + ) val apiParams = mutableMapOf( ) @@ -2322,7 +2379,8 @@ class Account(client: Client) : Service(client) { userId: String, secret: String, ): io.appwrite.models.Token { - val apiPath = "/account/verifications/phone" + val apiPath = ("/account/verifications/phone" + ) val apiParams = mutableMapOf( "userId" to userId, diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt index 298713c..3a01f1e 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -34,14 +34,16 @@ class Avatars(client: Client) : Service(client) { height: Long? = null, quality: Long? = null, ): ByteArray { - val apiPath = "/avatars/browsers/{code}" + val apiPath = ("/avatars/browsers/{code}" .replace("{code}", code.value) + ) val apiParams = mutableMapOf( "width" to width, "height" to height, "quality" to quality, "project" to client.config["project"], + "impersonateuserid" to client.config["impersonateuserid"], ) return client.call( "GET", @@ -71,14 +73,16 @@ class Avatars(client: Client) : Service(client) { height: Long? = null, quality: Long? = null, ): ByteArray { - val apiPath = "/avatars/credit-cards/{code}" + val apiPath = ("/avatars/credit-cards/{code}" .replace("{code}", code.value) + ) val apiParams = mutableMapOf( "width" to width, "height" to height, "quality" to quality, "project" to client.config["project"], + "impersonateuserid" to client.config["impersonateuserid"], ) return client.call( "GET", @@ -100,11 +104,13 @@ class Avatars(client: Client) : Service(client) { suspend fun getFavicon( url: String, ): ByteArray { - val apiPath = "/avatars/favicon" + val apiPath = ("/avatars/favicon" + ) val apiParams = mutableMapOf( "url" to url, "project" to client.config["project"], + "impersonateuserid" to client.config["impersonateuserid"], ) return client.call( "GET", @@ -134,14 +140,16 @@ class Avatars(client: Client) : Service(client) { height: Long? = null, quality: Long? = null, ): ByteArray { - val apiPath = "/avatars/flags/{code}" + val apiPath = ("/avatars/flags/{code}" .replace("{code}", code.value) + ) val apiParams = mutableMapOf( "width" to width, "height" to height, "quality" to quality, "project" to client.config["project"], + "impersonateuserid" to client.config["impersonateuserid"], ) return client.call( "GET", @@ -170,13 +178,15 @@ class Avatars(client: Client) : Service(client) { width: Long? = null, height: Long? = null, ): ByteArray { - val apiPath = "/avatars/image" + val apiPath = ("/avatars/image" + ) val apiParams = mutableMapOf( "url" to url, "width" to width, "height" to height, "project" to client.config["project"], + "impersonateuserid" to client.config["impersonateuserid"], ) return client.call( "GET", @@ -208,7 +218,8 @@ class Avatars(client: Client) : Service(client) { height: Long? = null, background: String? = null, ): ByteArray { - val apiPath = "/avatars/initials" + val apiPath = ("/avatars/initials" + ) val apiParams = mutableMapOf( "name" to name, @@ -216,6 +227,7 @@ class Avatars(client: Client) : Service(client) { "height" to height, "background" to background, "project" to client.config["project"], + "impersonateuserid" to client.config["impersonateuserid"], ) return client.call( "GET", @@ -243,7 +255,8 @@ class Avatars(client: Client) : Service(client) { margin: Long? = null, download: Boolean? = null, ): ByteArray { - val apiPath = "/avatars/qr" + val apiPath = ("/avatars/qr" + ) val apiParams = mutableMapOf( "text" to text, @@ -251,6 +264,7 @@ class Avatars(client: Client) : Service(client) { "margin" to margin, "download" to download, "project" to client.config["project"], + "impersonateuserid" to client.config["impersonateuserid"], ) return client.call( "GET", @@ -313,7 +327,8 @@ class Avatars(client: Client) : Service(client) { quality: Long? = null, output: io.appwrite.enums.ImageFormat? = null, ): ByteArray { - val apiPath = "/avatars/screenshots" + val apiPath = ("/avatars/screenshots" + ) val apiParams = mutableMapOf( "url" to url, @@ -337,6 +352,7 @@ class Avatars(client: Client) : Service(client) { "quality" to quality, "output" to output, "project" to client.config["project"], + "impersonateuserid" to client.config["impersonateuserid"], ) return client.call( "GET", diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index ce4e832..9fba03a 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -20,11 +20,16 @@ class Databases(client: Client) : Service(client) { * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). * @return [io.appwrite.models.TransactionList] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `TablesDB.listTransactions` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.listTransactions") + ) @JvmOverloads suspend fun listTransactions( queries: List? = null, ): io.appwrite.models.TransactionList { - val apiPath = "/databases/transactions" + val apiPath = ("/databases/transactions" + ) val apiParams = mutableMapOf( "queries" to queries, @@ -54,11 +59,16 @@ class Databases(client: Client) : Service(client) { * @param ttl Seconds before the transaction expires. * @return [io.appwrite.models.Transaction] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `TablesDB.createTransaction` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.createTransaction") + ) @JvmOverloads suspend fun createTransaction( ttl: Long? = null, ): io.appwrite.models.Transaction { - val apiPath = "/databases/transactions" + val apiPath = ("/databases/transactions" + ) val apiParams = mutableMapOf( "ttl" to ttl, @@ -89,11 +99,16 @@ class Databases(client: Client) : Service(client) { * @param transactionId Transaction ID. * @return [io.appwrite.models.Transaction] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `TablesDB.getTransaction` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.getTransaction") + ) suspend fun getTransaction( transactionId: String, ): io.appwrite.models.Transaction { - val apiPath = "/databases/transactions/{transactionId}" + val apiPath = ("/databases/transactions/{transactionId}" .replace("{transactionId}", transactionId) + ) val apiParams = mutableMapOf( ) @@ -124,14 +139,19 @@ class Databases(client: Client) : Service(client) { * @param rollback Rollback transaction? * @return [io.appwrite.models.Transaction] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `TablesDB.updateTransaction` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.updateTransaction") + ) @JvmOverloads suspend fun updateTransaction( transactionId: String, commit: Boolean? = null, rollback: Boolean? = null, ): io.appwrite.models.Transaction { - val apiPath = "/databases/transactions/{transactionId}" + val apiPath = ("/databases/transactions/{transactionId}" .replace("{transactionId}", transactionId) + ) val apiParams = mutableMapOf( "commit" to commit, @@ -163,11 +183,16 @@ class Databases(client: Client) : Service(client) { * @param transactionId Transaction ID. * @return [Any] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTransaction` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.deleteTransaction") + ) suspend fun deleteTransaction( transactionId: String, ): Any { - val apiPath = "/databases/transactions/{transactionId}" + val apiPath = ("/databases/transactions/{transactionId}" .replace("{transactionId}", transactionId) + ) val apiParams = mutableMapOf( ) @@ -192,13 +217,18 @@ class Databases(client: Client) : Service(client) { * @param operations Array of staged operations. * @return [io.appwrite.models.Transaction] */ + @Deprecated( + message = "This API has been deprecated since 1.8.0. Please use `TablesDB.createOperations` instead.", + replaceWith = ReplaceWith("io.appwrite.services.TablesDB.createOperations") + ) @JvmOverloads suspend fun createOperations( transactionId: String, operations: List? = null, ): io.appwrite.models.Transaction { - val apiPath = "/databases/transactions/{transactionId}/operations" + val apiPath = ("/databases/transactions/{transactionId}/operations" .replace("{transactionId}", transactionId) + ) val apiParams = mutableMapOf( "operations" to operations, @@ -248,9 +278,10 @@ class Databases(client: Client) : Service(client) { ttl: Long? = null, nestedType: Class, ): io.appwrite.models.DocumentList { - val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" + val apiPath = ("/databases/{databaseId}/collections/{collectionId}/documents" .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) + ) val apiParams = mutableMapOf( "queries" to queries, @@ -335,9 +366,10 @@ class Databases(client: Client) : Service(client) { transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Document { - val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" + val apiPath = ("/databases/{databaseId}/collections/{collectionId}/documents" .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) + ) val apiParams = mutableMapOf( "documentId" to documentId, @@ -421,10 +453,11 @@ class Databases(client: Client) : Service(client) { transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Document { - val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" + val apiPath = ("/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) .replace("{documentId}", documentId) + ) val apiParams = mutableMapOf( "queries" to queries, @@ -504,10 +537,11 @@ class Databases(client: Client) : Service(client) { transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Document { - val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" + val apiPath = ("/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) .replace("{documentId}", documentId) + ) val apiParams = mutableMapOf( "data" to data, @@ -592,10 +626,11 @@ class Databases(client: Client) : Service(client) { transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Document { - val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" + val apiPath = ("/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) .replace("{documentId}", documentId) + ) val apiParams = mutableMapOf( "data" to data, @@ -675,10 +710,11 @@ class Databases(client: Client) : Service(client) { documentId: String, transactionId: String? = null, ): Any { - val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" + val apiPath = ("/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) .replace("{documentId}", documentId) + ) val apiParams = mutableMapOf( "transactionId" to transactionId, @@ -724,11 +760,12 @@ class Databases(client: Client) : Service(client) { transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Document { - val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement" + val apiPath = ("/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement" .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) .replace("{documentId}", documentId) .replace("{attribute}", attribute) + ) val apiParams = mutableMapOf( "value" to value, @@ -818,11 +855,12 @@ class Databases(client: Client) : Service(client) { transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Document { - val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment" + val apiPath = ("/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment" .replace("{databaseId}", databaseId) .replace("{collectionId}", collectionId) .replace("{documentId}", documentId) .replace("{attribute}", attribute) + ) val apiParams = mutableMapOf( "value" to value, diff --git a/library/src/main/java/io/appwrite/services/Functions.kt b/library/src/main/java/io/appwrite/services/Functions.kt index 191c8cc..f56ea7f 100644 --- a/library/src/main/java/io/appwrite/services/Functions.kt +++ b/library/src/main/java/io/appwrite/services/Functions.kt @@ -28,8 +28,9 @@ class Functions(client: Client) : Service(client) { queries: List? = null, total: Boolean? = null, ): io.appwrite.models.ExecutionList { - val apiPath = "/functions/{functionId}/executions" + val apiPath = ("/functions/{functionId}/executions" .replace("{functionId}", functionId) + ) val apiParams = mutableMapOf( "queries" to queries, @@ -76,8 +77,9 @@ class Functions(client: Client) : Service(client) { headers: Any? = null, scheduledAt: String? = null, ): io.appwrite.models.Execution { - val apiPath = "/functions/{functionId}/executions" + val apiPath = ("/functions/{functionId}/executions" .replace("{functionId}", functionId) + ) val apiParams = mutableMapOf( "body" to body, @@ -118,9 +120,10 @@ class Functions(client: Client) : Service(client) { functionId: String, executionId: String, ): io.appwrite.models.Execution { - val apiPath = "/functions/{functionId}/executions/{executionId}" + val apiPath = ("/functions/{functionId}/executions/{executionId}" .replace("{functionId}", functionId) .replace("{executionId}", executionId) + ) val apiParams = mutableMapOf( ) diff --git a/library/src/main/java/io/appwrite/services/Graphql.kt b/library/src/main/java/io/appwrite/services/Graphql.kt index 950366e..cef1cc6 100644 --- a/library/src/main/java/io/appwrite/services/Graphql.kt +++ b/library/src/main/java/io/appwrite/services/Graphql.kt @@ -23,7 +23,8 @@ class Graphql(client: Client) : Service(client) { suspend fun query( query: Any, ): Any { - val apiPath = "/graphql" + val apiPath = ("/graphql" + ) val apiParams = mutableMapOf( "query" to query, @@ -57,7 +58,8 @@ class Graphql(client: Client) : Service(client) { suspend fun mutation( query: Any, ): Any { - val apiPath = "/graphql/mutation" + val apiPath = ("/graphql/mutation" + ) val apiParams = mutableMapOf( "query" to query, diff --git a/library/src/main/java/io/appwrite/services/Locale.kt b/library/src/main/java/io/appwrite/services/Locale.kt index d662ac6..a0434af 100644 --- a/library/src/main/java/io/appwrite/services/Locale.kt +++ b/library/src/main/java/io/appwrite/services/Locale.kt @@ -23,7 +23,8 @@ class Locale(client: Client) : Service(client) { */ suspend fun get( ): io.appwrite.models.Locale { - val apiPath = "/locale" + val apiPath = ("/locale" + ) val apiParams = mutableMapOf( ) @@ -53,7 +54,8 @@ class Locale(client: Client) : Service(client) { */ suspend fun listCodes( ): io.appwrite.models.LocaleCodeList { - val apiPath = "/locale/codes" + val apiPath = ("/locale/codes" + ) val apiParams = mutableMapOf( ) @@ -83,7 +85,8 @@ class Locale(client: Client) : Service(client) { */ suspend fun listContinents( ): io.appwrite.models.ContinentList { - val apiPath = "/locale/continents" + val apiPath = ("/locale/continents" + ) val apiParams = mutableMapOf( ) @@ -113,7 +116,8 @@ class Locale(client: Client) : Service(client) { */ suspend fun listCountries( ): io.appwrite.models.CountryList { - val apiPath = "/locale/countries" + val apiPath = ("/locale/countries" + ) val apiParams = mutableMapOf( ) @@ -143,7 +147,8 @@ class Locale(client: Client) : Service(client) { */ suspend fun listCountriesEU( ): io.appwrite.models.CountryList { - val apiPath = "/locale/countries/eu" + val apiPath = ("/locale/countries/eu" + ) val apiParams = mutableMapOf( ) @@ -173,7 +178,8 @@ class Locale(client: Client) : Service(client) { */ suspend fun listCountriesPhones( ): io.appwrite.models.PhoneList { - val apiPath = "/locale/countries/phones" + val apiPath = ("/locale/countries/phones" + ) val apiParams = mutableMapOf( ) @@ -203,7 +209,8 @@ class Locale(client: Client) : Service(client) { */ suspend fun listCurrencies( ): io.appwrite.models.CurrencyList { - val apiPath = "/locale/currencies" + val apiPath = ("/locale/currencies" + ) val apiParams = mutableMapOf( ) @@ -233,7 +240,8 @@ class Locale(client: Client) : Service(client) { */ suspend fun listLanguages( ): io.appwrite.models.LanguageList { - val apiPath = "/locale/languages" + val apiPath = ("/locale/languages" + ) val apiParams = mutableMapOf( ) diff --git a/library/src/main/java/io/appwrite/services/Messaging.kt b/library/src/main/java/io/appwrite/services/Messaging.kt index bf0d246..7a219a4 100644 --- a/library/src/main/java/io/appwrite/services/Messaging.kt +++ b/library/src/main/java/io/appwrite/services/Messaging.kt @@ -27,8 +27,9 @@ class Messaging(client: Client) : Service(client) { subscriberId: String, targetId: String, ): io.appwrite.models.Subscriber { - val apiPath = "/messaging/topics/{topicId}/subscribers" + val apiPath = ("/messaging/topics/{topicId}/subscribers" .replace("{topicId}", topicId) + ) val apiParams = mutableMapOf( "subscriberId" to subscriberId, @@ -65,9 +66,10 @@ class Messaging(client: Client) : Service(client) { topicId: String, subscriberId: String, ): Any { - val apiPath = "/messaging/topics/{topicId}/subscribers/{subscriberId}" + val apiPath = ("/messaging/topics/{topicId}/subscribers/{subscriberId}" .replace("{topicId}", topicId) .replace("{subscriberId}", subscriberId) + ) val apiParams = mutableMapOf( ) diff --git a/library/src/main/java/io/appwrite/services/Presences.kt b/library/src/main/java/io/appwrite/services/Presences.kt index bebcb50..2c9147d 100644 --- a/library/src/main/java/io/appwrite/services/Presences.kt +++ b/library/src/main/java/io/appwrite/services/Presences.kt @@ -29,7 +29,8 @@ class Presences(client: Client) : Service(client) { total: Boolean? = null, ttl: Long? = null, ): io.appwrite.models.PresenceList { - val apiPath = "/presences" + val apiPath = ("/presences" + ) val apiParams = mutableMapOf( "queries" to queries, @@ -65,8 +66,9 @@ class Presences(client: Client) : Service(client) { suspend fun get( presenceId: String, ): io.appwrite.models.Presence { - val apiPath = "/presences/{presenceId}" + val apiPath = ("/presences/{presenceId}" .replace("{presenceId}", presenceId) + ) val apiParams = mutableMapOf( ) @@ -108,8 +110,9 @@ class Presences(client: Client) : Service(client) { expiresAt: String? = null, metadata: Any? = null, ): io.appwrite.models.Presence { - val apiPath = "/presences/{presenceId}" + val apiPath = ("/presences/{presenceId}" .replace("{presenceId}", presenceId) + ) val apiParams = mutableMapOf( "status" to status, @@ -158,8 +161,9 @@ class Presences(client: Client) : Service(client) { permissions: List? = null, purge: Boolean? = null, ): io.appwrite.models.Presence { - val apiPath = "/presences/{presenceId}" + val apiPath = ("/presences/{presenceId}" .replace("{presenceId}", presenceId) + ) val apiParams = mutableMapOf( "status" to status, @@ -198,8 +202,9 @@ class Presences(client: Client) : Service(client) { suspend fun delete( presenceId: String, ): Any { - val apiPath = "/presences/{presenceId}" + val apiPath = ("/presences/{presenceId}" .replace("{presenceId}", presenceId) + ) val apiParams = mutableMapOf( ) diff --git a/library/src/main/java/io/appwrite/services/Realtime.kt b/library/src/main/java/io/appwrite/services/Realtime.kt index bc96ef9..bb1233a 100644 --- a/library/src/main/java/io/appwrite/services/Realtime.kt +++ b/library/src/main/java/io/appwrite/services/Realtime.kt @@ -73,7 +73,12 @@ class Realtime(client: Client) : Service(client), CoroutineScope { val encodedProject = java.net.URLEncoder.encode(client.config["project"].toString(), "UTF-8") val queryParams = "project=$encodedProject" val url = "${client.endpointRealtime}/realtime?$queryParams" - val request = Request.Builder().url(url).build() + val requestBuilder = Request.Builder().url(url) + val jwt = client.config["jwt"] + if (!jwt.isNullOrEmpty()) { + requestBuilder.addHeader("x-appwrite-jwt", jwt) + } + val request = requestBuilder.build() val generation = socketGeneration.incrementAndGet() socket = client.http.newWebSocket(request, AppwriteWebSocketListener(generation)) diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index ec073df..7e95b52 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -32,8 +32,9 @@ class Storage(client: Client) : Service(client) { search: String? = null, total: Boolean? = null, ): io.appwrite.models.FileList { - val apiPath = "/storage/buckets/{bucketId}/files" + val apiPath = ("/storage/buckets/{bucketId}/files" .replace("{bucketId}", bucketId) + ) val apiParams = mutableMapOf( "queries" to queries, @@ -83,8 +84,9 @@ class Storage(client: Client) : Service(client) { permissions: List? = null, onProgress: ((UploadProgress) -> Unit)? = null ): io.appwrite.models.File { - val apiPath = "/storage/buckets/{bucketId}/files" + val apiPath = ("/storage/buckets/{bucketId}/files" .replace("{bucketId}", bucketId) + ) val apiParams = mutableMapOf( "fileId" to fileId, @@ -126,9 +128,10 @@ class Storage(client: Client) : Service(client) { bucketId: String, fileId: String, ): io.appwrite.models.File { - val apiPath = "/storage/buckets/{bucketId}/files/{fileId}" + val apiPath = ("/storage/buckets/{bucketId}/files/{fileId}" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) + ) val apiParams = mutableMapOf( ) @@ -167,9 +170,10 @@ class Storage(client: Client) : Service(client) { name: String? = null, permissions: List? = null, ): io.appwrite.models.File { - val apiPath = "/storage/buckets/{bucketId}/files/{fileId}" + val apiPath = ("/storage/buckets/{bucketId}/files/{fileId}" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) + ) val apiParams = mutableMapOf( "name" to name, @@ -206,9 +210,10 @@ class Storage(client: Client) : Service(client) { bucketId: String, fileId: String, ): Any { - val apiPath = "/storage/buckets/{bucketId}/files/{fileId}" + val apiPath = ("/storage/buckets/{bucketId}/files/{fileId}" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) + ) val apiParams = mutableMapOf( ) @@ -240,13 +245,15 @@ class Storage(client: Client) : Service(client) { fileId: String, token: String? = null, ): ByteArray { - val apiPath = "/storage/buckets/{bucketId}/files/{fileId}/download" + val apiPath = ("/storage/buckets/{bucketId}/files/{fileId}/download" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) + ) val apiParams = mutableMapOf( "token" to token, "project" to client.config["project"], + "impersonateuserid" to client.config["impersonateuserid"], ) return client.call( "GET", @@ -293,9 +300,10 @@ class Storage(client: Client) : Service(client) { output: io.appwrite.enums.ImageFormat? = null, token: String? = null, ): ByteArray { - val apiPath = "/storage/buckets/{bucketId}/files/{fileId}/preview" + val apiPath = ("/storage/buckets/{bucketId}/files/{fileId}/preview" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) + ) val apiParams = mutableMapOf( "width" to width, @@ -311,6 +319,7 @@ class Storage(client: Client) : Service(client) { "output" to output, "token" to token, "project" to client.config["project"], + "impersonateuserid" to client.config["impersonateuserid"], ) return client.call( "GET", @@ -335,13 +344,15 @@ class Storage(client: Client) : Service(client) { fileId: String, token: String? = null, ): ByteArray { - val apiPath = "/storage/buckets/{bucketId}/files/{fileId}/view" + val apiPath = ("/storage/buckets/{bucketId}/files/{fileId}/view" .replace("{bucketId}", bucketId) .replace("{fileId}", fileId) + ) val apiParams = mutableMapOf( "token" to token, "project" to client.config["project"], + "impersonateuserid" to client.config["impersonateuserid"], ) return client.call( "GET", diff --git a/library/src/main/java/io/appwrite/services/TablesDB.kt b/library/src/main/java/io/appwrite/services/TablesDB.kt index 8595a4f..2bb131d 100644 --- a/library/src/main/java/io/appwrite/services/TablesDB.kt +++ b/library/src/main/java/io/appwrite/services/TablesDB.kt @@ -24,7 +24,8 @@ class TablesDB(client: Client) : Service(client) { suspend fun listTransactions( queries: List? = null, ): io.appwrite.models.TransactionList { - val apiPath = "/tablesdb/transactions" + val apiPath = ("/tablesdb/transactions" + ) val apiParams = mutableMapOf( "queries" to queries, @@ -58,7 +59,8 @@ class TablesDB(client: Client) : Service(client) { suspend fun createTransaction( ttl: Long? = null, ): io.appwrite.models.Transaction { - val apiPath = "/tablesdb/transactions" + val apiPath = ("/tablesdb/transactions" + ) val apiParams = mutableMapOf( "ttl" to ttl, @@ -92,8 +94,9 @@ class TablesDB(client: Client) : Service(client) { suspend fun getTransaction( transactionId: String, ): io.appwrite.models.Transaction { - val apiPath = "/tablesdb/transactions/{transactionId}" + val apiPath = ("/tablesdb/transactions/{transactionId}" .replace("{transactionId}", transactionId) + ) val apiParams = mutableMapOf( ) @@ -130,8 +133,9 @@ class TablesDB(client: Client) : Service(client) { commit: Boolean? = null, rollback: Boolean? = null, ): io.appwrite.models.Transaction { - val apiPath = "/tablesdb/transactions/{transactionId}" + val apiPath = ("/tablesdb/transactions/{transactionId}" .replace("{transactionId}", transactionId) + ) val apiParams = mutableMapOf( "commit" to commit, @@ -166,8 +170,9 @@ class TablesDB(client: Client) : Service(client) { suspend fun deleteTransaction( transactionId: String, ): Any { - val apiPath = "/tablesdb/transactions/{transactionId}" + val apiPath = ("/tablesdb/transactions/{transactionId}" .replace("{transactionId}", transactionId) + ) val apiParams = mutableMapOf( ) @@ -197,8 +202,9 @@ class TablesDB(client: Client) : Service(client) { transactionId: String, operations: List? = null, ): io.appwrite.models.Transaction { - val apiPath = "/tablesdb/transactions/{transactionId}/operations" + val apiPath = ("/tablesdb/transactions/{transactionId}/operations" .replace("{transactionId}", transactionId) + ) val apiParams = mutableMapOf( "operations" to operations, @@ -244,9 +250,10 @@ class TablesDB(client: Client) : Service(client) { ttl: Long? = null, nestedType: Class, ): io.appwrite.models.RowList { - val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows" + val apiPath = ("/tablesdb/{databaseId}/tables/{tableId}/rows" .replace("{databaseId}", databaseId) .replace("{tableId}", tableId) + ) val apiParams = mutableMapOf( "queries" to queries, @@ -323,9 +330,10 @@ class TablesDB(client: Client) : Service(client) { transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Row { - val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows" + val apiPath = ("/tablesdb/{databaseId}/tables/{tableId}/rows" .replace("{databaseId}", databaseId) .replace("{tableId}", tableId) + ) val apiParams = mutableMapOf( "rowId" to rowId, @@ -401,10 +409,11 @@ class TablesDB(client: Client) : Service(client) { transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Row { - val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" + val apiPath = ("/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" .replace("{databaseId}", databaseId) .replace("{tableId}", tableId) .replace("{rowId}", rowId) + ) val apiParams = mutableMapOf( "queries" to queries, @@ -476,10 +485,11 @@ class TablesDB(client: Client) : Service(client) { transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Row { - val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" + val apiPath = ("/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" .replace("{databaseId}", databaseId) .replace("{tableId}", tableId) .replace("{rowId}", rowId) + ) val apiParams = mutableMapOf( "data" to data, @@ -556,10 +566,11 @@ class TablesDB(client: Client) : Service(client) { transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Row { - val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" + val apiPath = ("/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" .replace("{databaseId}", databaseId) .replace("{tableId}", tableId) .replace("{rowId}", rowId) + ) val apiParams = mutableMapOf( "data" to data, @@ -631,10 +642,11 @@ class TablesDB(client: Client) : Service(client) { rowId: String, transactionId: String? = null, ): Any { - val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" + val apiPath = ("/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" .replace("{databaseId}", databaseId) .replace("{tableId}", tableId) .replace("{rowId}", rowId) + ) val apiParams = mutableMapOf( "transactionId" to transactionId, @@ -676,11 +688,12 @@ class TablesDB(client: Client) : Service(client) { transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Row { - val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement" + val apiPath = ("/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement" .replace("{databaseId}", databaseId) .replace("{tableId}", tableId) .replace("{rowId}", rowId) .replace("{column}", column) + ) val apiParams = mutableMapOf( "value" to value, @@ -762,11 +775,12 @@ class TablesDB(client: Client) : Service(client) { transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Row { - val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment" + val apiPath = ("/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment" .replace("{databaseId}", databaseId) .replace("{tableId}", tableId) .replace("{rowId}", rowId) .replace("{column}", column) + ) val apiParams = mutableMapOf( "value" to value, diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index 1ab6c54..508b877 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -29,7 +29,8 @@ class Teams(client: Client) : Service(client) { total: Boolean? = null, nestedType: Class, ): io.appwrite.models.TeamList { - val apiPath = "/teams" + val apiPath = ("/teams" + ) val apiParams = mutableMapOf( "queries" to queries, @@ -90,7 +91,8 @@ class Teams(client: Client) : Service(client) { roles: List? = null, nestedType: Class, ): io.appwrite.models.Team { - val apiPath = "/teams" + val apiPath = ("/teams" + ) val apiParams = mutableMapOf( "teamId" to teamId, @@ -147,8 +149,9 @@ class Teams(client: Client) : Service(client) { teamId: String, nestedType: Class, ): io.appwrite.models.Team { - val apiPath = "/teams/{teamId}" + val apiPath = ("/teams/{teamId}" .replace("{teamId}", teamId) + ) val apiParams = mutableMapOf( ) @@ -196,8 +199,9 @@ class Teams(client: Client) : Service(client) { name: String, nestedType: Class, ): io.appwrite.models.Team { - val apiPath = "/teams/{teamId}" + val apiPath = ("/teams/{teamId}" .replace("{teamId}", teamId) + ) val apiParams = mutableMapOf( "name" to name, @@ -247,8 +251,9 @@ class Teams(client: Client) : Service(client) { suspend fun delete( teamId: String, ): Any { - val apiPath = "/teams/{teamId}" + val apiPath = ("/teams/{teamId}" .replace("{teamId}", teamId) + ) val apiParams = mutableMapOf( ) @@ -282,8 +287,9 @@ class Teams(client: Client) : Service(client) { search: String? = null, total: Boolean? = null, ): io.appwrite.models.MembershipList { - val apiPath = "/teams/{teamId}/memberships" + val apiPath = ("/teams/{teamId}/memberships" .replace("{teamId}", teamId) + ) val apiParams = mutableMapOf( "queries" to queries, @@ -338,8 +344,9 @@ class Teams(client: Client) : Service(client) { url: String? = null, name: String? = null, ): io.appwrite.models.Membership { - val apiPath = "/teams/{teamId}/memberships" + val apiPath = ("/teams/{teamId}/memberships" .replace("{teamId}", teamId) + ) val apiParams = mutableMapOf( "email" to email, @@ -380,9 +387,10 @@ class Teams(client: Client) : Service(client) { teamId: String, membershipId: String, ): io.appwrite.models.Membership { - val apiPath = "/teams/{teamId}/memberships/{membershipId}" + val apiPath = ("/teams/{teamId}/memberships/{membershipId}" .replace("{teamId}", teamId) .replace("{membershipId}", membershipId) + ) val apiParams = mutableMapOf( ) @@ -419,9 +427,10 @@ class Teams(client: Client) : Service(client) { membershipId: String, roles: List, ): io.appwrite.models.Membership { - val apiPath = "/teams/{teamId}/memberships/{membershipId}" + val apiPath = ("/teams/{teamId}/memberships/{membershipId}" .replace("{teamId}", teamId) .replace("{membershipId}", membershipId) + ) val apiParams = mutableMapOf( "roles" to roles, @@ -457,9 +466,10 @@ class Teams(client: Client) : Service(client) { teamId: String, membershipId: String, ): Any { - val apiPath = "/teams/{teamId}/memberships/{membershipId}" + val apiPath = ("/teams/{teamId}/memberships/{membershipId}" .replace("{teamId}", teamId) .replace("{membershipId}", membershipId) + ) val apiParams = mutableMapOf( ) @@ -495,9 +505,10 @@ class Teams(client: Client) : Service(client) { userId: String, secret: String, ): io.appwrite.models.Membership { - val apiPath = "/teams/{teamId}/memberships/{membershipId}/status" + val apiPath = ("/teams/{teamId}/memberships/{membershipId}/status" .replace("{teamId}", teamId) .replace("{membershipId}", membershipId) + ) val apiParams = mutableMapOf( "userId" to userId, @@ -533,8 +544,9 @@ class Teams(client: Client) : Service(client) { teamId: String, nestedType: Class, ): io.appwrite.models.Preferences { - val apiPath = "/teams/{teamId}/prefs" + val apiPath = ("/teams/{teamId}/prefs" .replace("{teamId}", teamId) + ) val apiParams = mutableMapOf( ) @@ -582,8 +594,9 @@ class Teams(client: Client) : Service(client) { prefs: Any, nestedType: Class, ): io.appwrite.models.Preferences { - val apiPath = "/teams/{teamId}/prefs" + val apiPath = ("/teams/{teamId}/prefs" .replace("{teamId}", teamId) + ) val apiParams = mutableMapOf( "prefs" to prefs,