diff --git a/README.md b/README.md index 2b1d293..1f076d6 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.13.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-0.14.0-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 0.13.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).** +**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).** 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.5.0") +implementation("io.appwrite:sdk-for-android:0.6.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 0.5.0 + 0.6.0 ``` diff --git a/docs/examples/java/account/delete.md b/docs/examples/java/account/update-status.md similarity index 96% rename from docs/examples/java/account/delete.md rename to docs/examples/java/account/update-status.md index aec96f1..0ef6a6e 100644 --- a/docs/examples/java/account/delete.md +++ b/docs/examples/java/account/update-status.md @@ -18,7 +18,7 @@ public class MainActivity extends AppCompatActivity { Account account = new Account(client); - account.delete(new Continuation() { + account.updateStatus(new Continuation() { @NotNull @Override public CoroutineContext getContext() { diff --git a/docs/examples/kotlin/account/delete.md b/docs/examples/kotlin/account/update-status.md similarity index 93% rename from docs/examples/kotlin/account/delete.md rename to docs/examples/kotlin/account/update-status.md index 7bfe95e..e138751 100644 --- a/docs/examples/kotlin/account/delete.md +++ b/docs/examples/kotlin/account/update-status.md @@ -17,7 +17,7 @@ class MainActivity : AppCompatActivity() { val account = Account(client) GlobalScope.launch { - val response = account.delete() + val response = account.updateStatus() val json = response.body?.string() } } diff --git a/library/src/main/java/io/appwrite/models/Execution.kt b/library/src/main/java/io/appwrite/models/Execution.kt index c8f2ae2..06c2811 100644 --- a/library/src/main/java/io/appwrite/models/Execution.kt +++ b/library/src/main/java/io/appwrite/models/Execution.kt @@ -56,11 +56,11 @@ data class Execution( val statusCode: Long, /** - * The script stdout output string. Logs the last 4,000 characters of the execution stdout output. + * The script response output string. Logs the last 4,000 characters of the execution response output. * */ - @SerializedName("stdout") - val stdout: String, + @SerializedName("response") + val response: String, /** * The script stderr output string. Logs the last 4,000 characters of the execution stderr output @@ -86,7 +86,7 @@ data class Execution( trigger = map["trigger"] as String, status = map["status"] as String, statusCode = (map["statusCode"] as Number).toLong(), - stdout = map["stdout"] as String, + response = map["response"] as String, stderr = map["stderr"] as String, time = (map["time"] as Number).toDouble() ) @@ -100,7 +100,7 @@ data class Execution( "trigger" to trigger as Any, "status" to status as Any, "statusCode" to statusCode as Any, - "stdout" to stdout as Any, + "response" to response as Any, "stderr" to stderr as Any, "time" to time as Any ) diff --git a/library/src/main/java/io/appwrite/models/Membership.kt b/library/src/main/java/io/appwrite/models/Membership.kt index 45b42c8..3df7b69 100644 --- a/library/src/main/java/io/appwrite/models/Membership.kt +++ b/library/src/main/java/io/appwrite/models/Membership.kt @@ -20,6 +20,20 @@ data class Membership( @SerializedName("userId") val userId: String, + /** + * User name. + * + */ + @SerializedName("userName") + val userName: String, + + /** + * User email address. + * + */ + @SerializedName("userEmail") + val userEmail: String, + /** * Team ID. * @@ -28,18 +42,11 @@ data class Membership( val teamId: String, /** - * User name. + * Team name. * */ - @SerializedName("name") - val name: String, - - /** - * User email address. - * - */ - @SerializedName("email") - val email: String, + @SerializedName("teamName") + val teamName: String, /** * Date, the user has been invited to join the team in Unix timestamp. @@ -74,9 +81,10 @@ data class Membership( fun from(map: Map) = Membership( id = map["\$id"] as String, userId = map["userId"] as String, + userName = map["userName"] as String, + userEmail = map["userEmail"] as String, teamId = map["teamId"] as String, - name = map["name"] as String, - email = map["email"] as String, + teamName = map["teamName"] as String, invited = (map["invited"] as Number).toLong(), joined = (map["joined"] as Number).toLong(), confirm = map["confirm"] as Boolean, @@ -87,9 +95,10 @@ data class Membership( fun toMap(): Map = mapOf( "\$id" to id as Any, "userId" to userId as Any, + "userName" to userName as Any, + "userEmail" to userEmail as Any, "teamId" to teamId as Any, - "name" to name as Any, - "email" to email as Any, + "teamName" to teamName as Any, "invited" to invited as Any, "joined" to joined as Any, "confirm" to confirm 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 d47a521..8f144de 100644 --- a/library/src/main/java/io/appwrite/services/Account.kt +++ b/library/src/main/java/io/appwrite/services/Account.kt @@ -90,35 +90,6 @@ class Account(client: Client) : Service(client) { ) } - /** - * Delete Account - * - * Delete a currently logged in user account. Behind the scene, the user - * record is not deleted but permanently blocked from any access. This is done - * to avoid deleted accounts being overtaken by new users with the same email - * address. Any user-related resources like documents or storage files should - * be deleted separately. - * - * @return [Any] - */ - @JvmOverloads - @Throws(AppwriteException::class) - suspend fun delete(): Any { - val path = "/account" - val params = mutableMapOf( - ) - val headers = mutableMapOf( - "content-type" to "application/json" - ) - return client.call( - "DELETE", - path, - headers, - params, - responseType = Any::class.java, - ) - } - /** * Update Account Email * @@ -270,7 +241,7 @@ class Account(client: Client) : Service(client) { * * Update currently logged in user password. For validation, user is required * to pass in the new password, and the old password. For users created with - * OAuth and Team Invites, oldPassword is optional. + * OAuth, Team Invites and Magic URL, oldPassword is optional. * * @param password New user password. Must be at least 8 chars. * @param oldPassword Current user password. Must be at least 8 chars. @@ -697,10 +668,10 @@ class Account(client: Client) : Service(client) { * user.. * * - * @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, bitbucket, bitly, box, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, notion, paypal, paypalSandbox, salesforce, slack, spotify, tradeshift, tradeshiftBox, twitch, vk, yahoo, yammer, yandex, wordpress, stripe. + * @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 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. + * @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. * */ @JvmOverloads @@ -799,6 +770,10 @@ class Account(client: Client) : Service(client) { /** * Update Session (Refresh Tokens) * + * Access tokens have limited lifespan and expire to mitigate security risks. + * If session was created using an OAuth provider, this route can be used to + * "refresh" the access token. + * * @param sessionId Session ID. Use the string 'current' to update the current device session. * @return [io.appwrite.models.Session] */ @@ -857,6 +832,37 @@ class Account(client: Client) : Service(client) { ) } + /** + * Update Account Status + * + * Block the currently logged in user account. Behind the scene, the user + * 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] + */ + @JvmOverloads + @Throws(AppwriteException::class) + suspend fun updateStatus(): io.appwrite.models.User { + 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) + } + return client.call( + "PATCH", + path, + headers, + params, + responseType = io.appwrite.models.User::class.java, + converter, + ) + } + /** * Create Email Verification * diff --git a/library/src/main/java/io/appwrite/services/Avatars.kt b/library/src/main/java/io/appwrite/services/Avatars.kt index 09afbc6..20e1f54 100644 --- a/library/src/main/java/io/appwrite/services/Avatars.kt +++ b/library/src/main/java/io/appwrite/services/Avatars.kt @@ -16,9 +16,14 @@ class Avatars(client: Client) : Service(client) { * Get Browser Icon * * You can use this endpoint to show different browser icons to your users. - * The code argument receives the browser code as it appears in your user - * /account/sessions endpoint. Use width, height and quality arguments to - * change the output settings. + * The code argument receives the browser code as it appears in your user [GET + * /account/sessions](/docs/client/account#accountGetSessions) endpoint. Use + * width, height and quality arguments to change the output settings. + * + * When one dimension is specified and the other is 0, the image is scaled + * with preserved aspect ratio. If both dimensions are 0, the API provides an + * image at source quality. If dimensions are not specified, the default size + * of image returned is 100x100px. * * @param code Browser Code. * @param width Image width. Pass an integer between 0 to 2000. Defaults to 100. @@ -55,6 +60,12 @@ class Avatars(client: Client) : Service(client) { * The credit card endpoint will return you the icon of the credit card * provider you need. Use width, height and quality arguments to change the * output settings. + * + * When one dimension is specified and the other is 0, the image is scaled + * with preserved aspect ratio. If both dimensions are 0, the API provides an + * image at source quality. If dimensions are not specified, the default size + * of image returned is 100x100px. + * * * @param code Credit Card Code. Possible values: amex, argencard, cabal, censosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro. * @param width Image width. Pass an integer between 0 to 2000. Defaults to 100. @@ -119,6 +130,12 @@ 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. + * + * When one dimension is specified and the other is 0, the image is scaled + * with preserved aspect ratio. If both dimensions are 0, the API provides an + * image at source quality. If dimensions are not specified, the default size + * of image returned is 100x100px. + * * * @param code Country Code. ISO Alpha-2 country code format. * @param width Image width. Pass an integer between 0 to 2000. Defaults to 100. @@ -156,10 +173,16 @@ class Avatars(client: Client) : Service(client) { * you want. This endpoint is very useful if you need to crop and display * remote images in your app or in case you want to make sure a 3rd party * image is properly served using a TLS protocol. + * + * When one dimension is specified and the other is 0, the image is scaled + * with preserved aspect ratio. If both dimensions are 0, the API provides an + * image at source quality. If dimensions are not specified, the default size + * of image returned is 400x400px. + * * * @param url Image URL which you want to crop. - * @param width Resize preview image width, Pass an integer between 0 to 2000. - * @param height Resize preview image height, Pass an integer between 0 to 2000. + * @param width Resize preview image width, Pass an integer between 0 to 2000. Defaults to 400. + * @param height Resize preview image height, Pass an integer between 0 to 2000. Defaults to 400. * @return [ByteArray] */ @JvmOverloads @@ -197,6 +220,12 @@ class Avatars(client: Client) : Service(client) { * default, a random theme will be selected. The random theme will persist for * the user's initials when reloading the same theme will always return for * the same initials. + * + * When one dimension is specified and the other is 0, the image is scaled + * with preserved aspect ratio. If both dimensions are 0, the API provides an + * image at source quality. If dimensions are not specified, the default size + * of image returned is 100x100px. + * * * @param name Full Name. When empty, current user name or email will be used. Max length: 128 chars. * @param width Image width. Pass an integer between 0 to 2000. Defaults to 100. @@ -236,9 +265,10 @@ class Avatars(client: Client) : Service(client) { * * Converts a given plain text to a QR code image. You can use the query * parameters to change the size and style of the resulting image. + * * * @param text Plain text to be converted to QR code image. - * @param size QR code size. Pass an integer between 0 to 1000. Defaults to 400. + * @param size QR code size. Pass an integer between 1 to 1000. Defaults to 400. * @param margin Margin from edge. Pass an integer between 0 to 10. Defaults to 1. * @param download Return resulting image with 'Content-Disposition: attachment ' headers for the browser to start downloading it. Pass 0 for no header, or 1 for otherwise. Default value is set to 0. * @return [ByteArray] diff --git a/library/src/main/java/io/appwrite/services/Database.kt b/library/src/main/java/io/appwrite/services/Database.kt index 85a04ca..74bced3 100644 --- a/library/src/main/java/io/appwrite/services/Database.kt +++ b/library/src/main/java/io/appwrite/services/Database.kt @@ -19,13 +19,13 @@ class Database(client: Client) : Service(client) { * 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. + * @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. - * @param orderTypes Array of order directions for sorting attribtues. Possible values are DESC for descending order, or ASC for ascending order. + * @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. * @return [io.appwrite.models.DocumentList] */ @JvmOverloads @@ -156,7 +156,7 @@ class Database(client: Client) : Service(client) { * * @param collectionId Collection ID. * @param documentId Document ID. - * @param data Document data as JSON object. + * @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. * @return [io.appwrite.models.Document] @@ -195,9 +195,7 @@ class Database(client: Client) : Service(client) { /** * Delete Document * - * Delete a document by its unique ID. This endpoint deletes only the parent - * documents, its attributes and relations to other documents. Child documents - * **will not** be deleted. + * 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 documentId Document ID. diff --git a/library/src/main/java/io/appwrite/services/Storage.kt b/library/src/main/java/io/appwrite/services/Storage.kt index a632fd2..927829b 100644 --- a/library/src/main/java/io/appwrite/services/Storage.kt +++ b/library/src/main/java/io/appwrite/services/Storage.kt @@ -115,7 +115,8 @@ class Storage(client: Client) : Service(client) { val converter: (Map) -> io.appwrite.models.File = { io.appwrite.models.File.from(map = it) } - val idParamName: String? = "fileId" + val idParamName: String? = "fileId" + idParamName = "fileId" val paramName = "file" return client.chunkedUpload( path, diff --git a/library/src/main/java/io/appwrite/services/Teams.kt b/library/src/main/java/io/appwrite/services/Teams.kt index e8b232c..5b74d1d 100644 --- a/library/src/main/java/io/appwrite/services/Teams.kt +++ b/library/src/main/java/io/appwrite/services/Teams.kt @@ -71,7 +71,7 @@ class Teams(client: Client) : Service(client) { * * @param teamId Team 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 name Team name. Max length: 128 chars. - * @param roles Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Max length for each role is 32 chars. + * @param roles Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. * @return [io.appwrite.models.Team] */ @JvmOverloads @@ -272,7 +272,7 @@ class Teams(client: Client) : Service(client) { * * @param teamId Team ID. * @param email Email of the new team member. - * @param roles Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Max length for each role is 32 chars. + * @param roles Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. * @param url URL to redirect the user back to your app from the invitation email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. * @param name Name of the new team member. Max length: 128 chars. * @return [io.appwrite.models.Membership] @@ -353,7 +353,7 @@ class Teams(client: Client) : Service(client) { * * @param teamId Team ID. * @param membershipId Membership ID. - * @param roles An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Max length for each role is 32 chars. + * @param roles An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. * @return [io.appwrite.models.Membership] */ @JvmOverloads