Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 11.1.0

* Deprecate `createVerification` method in `Account` service
* Add `createEmailVerification` method in `Account` service

## 8.2.0

* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ repositories {
Next, add the dependency to your project's `build.gradle(.kts)` file:

```groovy
implementation("io.appwrite:sdk-for-android:11.0.0")
implementation("io.appwrite:sdk-for-android:11.1.0")
```

### Maven
Expand All @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file:
<dependency>
<groupId>io.appwrite</groupId>
<artifactId>sdk-for-android</artifactId>
<version>11.0.0</version>
<version>11.1.0</version>
</dependency>
</dependencies>
```
Expand Down
22 changes: 22 additions & 0 deletions docs/examples/java/account/create-email-verification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Account;

Client client = new Client(context)
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>"); // Your project ID

Account account = new Account(client);

account.createEmailVerification(
"https://example.com", // url
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
return;
}

Log.d("Appwrite", result.toString());
})
);

23 changes: 23 additions & 0 deletions docs/examples/java/account/update-email-verification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Account;

Client client = new Client(context)
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>"); // Your project ID

Account account = new Account(client);

account.updateEmailVerification(
"<USER_ID>", // userId
"<SECRET>", // secret
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
return;
}

Log.d("Appwrite", result.toString());
})
);

13 changes: 13 additions & 0 deletions docs/examples/kotlin/account/create-email-verification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import io.appwrite.Client
import io.appwrite.coroutines.CoroutineCallback
import io.appwrite.services.Account

val client = Client(context)
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID

val account = Account(client)

val result = account.createEmailVerification(
url = "https://example.com",
)
14 changes: 14 additions & 0 deletions docs/examples/kotlin/account/update-email-verification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import io.appwrite.Client
import io.appwrite.coroutines.CoroutineCallback
import io.appwrite.services.Account

val client = Client(context)
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID

val account = Account(client)

val result = account.updateEmailVerification(
userId = "<USER_ID>",
secret = "<SECRET>",
)
2 changes: 1 addition & 1 deletion library/src/main/java/io/appwrite/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class Client @JvmOverloads constructor(
"x-sdk-name" to "Android",
"x-sdk-platform" to "client",
"x-sdk-language" to "android",
"x-sdk-version" to "11.0.0",
"x-sdk-version" to "11.1.0",
"x-appwrite-response-format" to "1.8.0"
)
config = mutableMapOf()
Expand Down
86 changes: 82 additions & 4 deletions library/src/main/java/io/appwrite/services/Account.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2029,10 +2029,49 @@ class Account(client: Client) : Service(client) {
* @param url URL to redirect the user back to your app from the verification 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.
* @return [io.appwrite.models.Token]
*/
suspend fun createEmailVerification(
url: String,
): io.appwrite.models.Token {
val apiPath = "/account/verifications/email"

val apiParams = mutableMapOf<String, Any?>(
"url" to url,
)
val apiHeaders = mutableMapOf<String, String>(
"content-type" to "application/json",
)
val converter: (Any) -> io.appwrite.models.Token = {
@Suppress("UNCHECKED_CAST")
io.appwrite.models.Token.from(map = it as Map<String, Any>)
}
return client.call(
"POST",
apiPath,
apiHeaders,
apiParams,
responseType = io.appwrite.models.Token::class.java,
converter,
)
}


/**
* Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days.
*
* Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface.
*
*
* @param url URL to redirect the user back to your app from the verification 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.
* @return [io.appwrite.models.Token]
*/
@Deprecated(
message = "This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.",
replaceWith = ReplaceWith("io.appwrite.services.Account.createEmailVerification")
)
suspend fun createVerification(
url: String,
): io.appwrite.models.Token {
val apiPath = "/account/verification"
val apiPath = "/account/verifications/email"

val apiParams = mutableMapOf<String, Any?>(
"url" to url,
Expand Down Expand Up @@ -2062,11 +2101,50 @@ class Account(client: Client) : Service(client) {
* @param secret Valid verification token.
* @return [io.appwrite.models.Token]
*/
suspend fun updateEmailVerification(
userId: String,
secret: String,
): io.appwrite.models.Token {
val apiPath = "/account/verifications/email"

val apiParams = mutableMapOf<String, Any?>(
"userId" to userId,
"secret" to secret,
)
val apiHeaders = mutableMapOf<String, String>(
"content-type" to "application/json",
)
val converter: (Any) -> io.appwrite.models.Token = {
@Suppress("UNCHECKED_CAST")
io.appwrite.models.Token.from(map = it as Map<String, Any>)
}
return client.call(
"PUT",
apiPath,
apiHeaders,
apiParams,
responseType = io.appwrite.models.Token::class.java,
converter,
)
}


/**
* Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code.
*
* @param userId User ID.
* @param secret Valid verification token.
* @return [io.appwrite.models.Token]
*/
@Deprecated(
message = "This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.",
replaceWith = ReplaceWith("io.appwrite.services.Account.updateEmailVerification")
)
suspend fun updateVerification(
userId: String,
secret: String,
): io.appwrite.models.Token {
val apiPath = "/account/verification"
val apiPath = "/account/verifications/email"

val apiParams = mutableMapOf<String, Any?>(
"userId" to userId,
Expand Down Expand Up @@ -2097,7 +2175,7 @@ class Account(client: Client) : Service(client) {
*/
suspend fun createPhoneVerification(
): io.appwrite.models.Token {
val apiPath = "/account/verification/phone"
val apiPath = "/account/verifications/phone"

val apiParams = mutableMapOf<String, Any?>(
)
Expand Down Expand Up @@ -2130,7 +2208,7 @@ class Account(client: Client) : Service(client) {
userId: String,
secret: String,
): io.appwrite.models.Token {
val apiPath = "/account/verification/phone"
val apiPath = "/account/verifications/phone"

val apiParams = mutableMapOf<String, Any?>(
"userId" to userId,
Expand Down
22 changes: 11 additions & 11 deletions library/src/main/java/io/appwrite/services/TablesDb.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TablesDB(client: Client) : Service(client) {
* Get a list of all the user's rows in a given table. You can use the query params to filter your results.
*
* @param databaseId Database ID.
* @param tableId Table ID. You can create a new table using the TableDB service [server integration](https://appwrite.io/docs/server/tablesdbdb#tablesdbCreate).
* @param tableId Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/products/databases/tables#create-table).
* @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
* @return [io.appwrite.models.RowList<T>]
*/
Expand Down Expand Up @@ -56,7 +56,7 @@ class TablesDB(client: Client) : Service(client) {
* Get a list of all the user's rows in a given table. You can use the query params to filter your results.
*
* @param databaseId Database ID.
* @param tableId Table ID. You can create a new table using the TableDB service [server integration](https://appwrite.io/docs/server/tablesdbdb#tablesdbCreate).
* @param tableId Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/products/databases/tables#create-table).
* @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
* @return [io.appwrite.models.RowList<T>]
*/
Expand All @@ -74,10 +74,10 @@ class TablesDB(client: Client) : Service(client) {
)

/**
* Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console.
* Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console.
*
* @param databaseId Database ID.
* @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows.
* @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). Make sure to define columns before creating rows.
* @param rowId Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
* @param data Row data as JSON 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).
Expand Down Expand Up @@ -119,10 +119,10 @@ class TablesDB(client: Client) : Service(client) {
}

/**
* Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console.
* Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console.
*
* @param databaseId Database ID.
* @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows.
* @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). Make sure to define columns before creating rows.
* @param rowId Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
* @param data Row data as JSON 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).
Expand All @@ -149,7 +149,7 @@ class TablesDB(client: Client) : Service(client) {
* Get a row by its unique ID. This endpoint response returns a JSON object with the row data.
*
* @param databaseId Database ID.
* @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
* @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable).
* @param rowId Row ID.
* @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
* @return [io.appwrite.models.Row<T>]
Expand Down Expand Up @@ -190,7 +190,7 @@ class TablesDB(client: Client) : Service(client) {
* Get a row by its unique ID. This endpoint response returns a JSON object with the row data.
*
* @param databaseId Database ID.
* @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
* @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable).
* @param rowId Row ID.
* @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.
* @return [io.appwrite.models.Row<T>]
Expand All @@ -211,7 +211,7 @@ class TablesDB(client: Client) : Service(client) {
)

/**
* Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console.
* Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console.
*
* @param databaseId Database ID.
* @param tableId Table ID.
Expand Down Expand Up @@ -256,7 +256,7 @@ class TablesDB(client: Client) : Service(client) {
}

/**
* Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable) API or directly from your database console.
* Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console.
*
* @param databaseId Database ID.
* @param tableId Table ID.
Expand Down Expand Up @@ -358,7 +358,7 @@ class TablesDB(client: Client) : Service(client) {
* Delete a row by its unique ID.
*
* @param databaseId Database ID.
* @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
* @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable).
* @param rowId Row ID.
* @return [Any]
*/
Expand Down