Skip to content

Commit 19aed72

Browse files
authored
Merge pull request #92 from appwrite/dev
feat: Android SDK update for version 11.1.0
2 parents ecf2875 + 5a6b3c8 commit 19aed72

File tree

9 files changed

+173
-18
lines changed

9 files changed

+173
-18
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Log
22

3+
## 11.1.0
4+
5+
* Deprecate `createVerification` method in `Account` service
6+
* Add `createEmailVerification` method in `Account` service
7+
38
## 8.2.0
49

510
* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ repositories {
3838
Next, add the dependency to your project's `build.gradle(.kts)` file:
3939

4040
```groovy
41-
implementation("io.appwrite:sdk-for-android:11.0.0")
41+
implementation("io.appwrite:sdk-for-android:11.1.0")
4242
```
4343

4444
### Maven
@@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file:
4949
<dependency>
5050
<groupId>io.appwrite</groupId>
5151
<artifactId>sdk-for-android</artifactId>
52-
<version>11.0.0</version>
52+
<version>11.1.0</version>
5353
</dependency>
5454
</dependencies>
5555
```
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import io.appwrite.Client;
2+
import io.appwrite.coroutines.CoroutineCallback;
3+
import io.appwrite.services.Account;
4+
5+
Client client = new Client(context)
6+
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
7+
.setProject("<YOUR_PROJECT_ID>"); // Your project ID
8+
9+
Account account = new Account(client);
10+
11+
account.createEmailVerification(
12+
"https://example.com", // url
13+
new CoroutineCallback<>((result, error) -> {
14+
if (error != null) {
15+
error.printStackTrace();
16+
return;
17+
}
18+
19+
Log.d("Appwrite", result.toString());
20+
})
21+
);
22+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import io.appwrite.Client;
2+
import io.appwrite.coroutines.CoroutineCallback;
3+
import io.appwrite.services.Account;
4+
5+
Client client = new Client(context)
6+
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
7+
.setProject("<YOUR_PROJECT_ID>"); // Your project ID
8+
9+
Account account = new Account(client);
10+
11+
account.updateEmailVerification(
12+
"<USER_ID>", // userId
13+
"<SECRET>", // secret
14+
new CoroutineCallback<>((result, error) -> {
15+
if (error != null) {
16+
error.printStackTrace();
17+
return;
18+
}
19+
20+
Log.d("Appwrite", result.toString());
21+
})
22+
);
23+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import io.appwrite.Client
2+
import io.appwrite.coroutines.CoroutineCallback
3+
import io.appwrite.services.Account
4+
5+
val client = Client(context)
6+
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
7+
.setProject("<YOUR_PROJECT_ID>") // Your project ID
8+
9+
val account = Account(client)
10+
11+
val result = account.createEmailVerification(
12+
url = "https://example.com",
13+
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import io.appwrite.Client
2+
import io.appwrite.coroutines.CoroutineCallback
3+
import io.appwrite.services.Account
4+
5+
val client = Client(context)
6+
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
7+
.setProject("<YOUR_PROJECT_ID>") // Your project ID
8+
9+
val account = Account(client)
10+
11+
val result = account.updateEmailVerification(
12+
userId = "<USER_ID>",
13+
secret = "<SECRET>",
14+
)

library/src/main/java/io/appwrite/Client.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class Client @JvmOverloads constructor(
8787
"x-sdk-name" to "Android",
8888
"x-sdk-platform" to "client",
8989
"x-sdk-language" to "android",
90-
"x-sdk-version" to "11.0.0",
90+
"x-sdk-version" to "11.1.0",
9191
"x-appwrite-response-format" to "1.8.0"
9292
)
9393
config = mutableMapOf()

library/src/main/java/io/appwrite/services/Account.kt

Lines changed: 82 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,10 +2029,49 @@ class Account(client: Client) : Service(client) {
20292029
* @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.
20302030
* @return [io.appwrite.models.Token]
20312031
*/
2032+
suspend fun createEmailVerification(
2033+
url: String,
2034+
): io.appwrite.models.Token {
2035+
val apiPath = "/account/verifications/email"
2036+
2037+
val apiParams = mutableMapOf<String, Any?>(
2038+
"url" to url,
2039+
)
2040+
val apiHeaders = mutableMapOf<String, String>(
2041+
"content-type" to "application/json",
2042+
)
2043+
val converter: (Any) -> io.appwrite.models.Token = {
2044+
@Suppress("UNCHECKED_CAST")
2045+
io.appwrite.models.Token.from(map = it as Map<String, Any>)
2046+
}
2047+
return client.call(
2048+
"POST",
2049+
apiPath,
2050+
apiHeaders,
2051+
apiParams,
2052+
responseType = io.appwrite.models.Token::class.java,
2053+
converter,
2054+
)
2055+
}
2056+
2057+
2058+
/**
2059+
* 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.
2060+
*
2061+
* 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.
2062+
*
2063+
*
2064+
* @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.
2065+
* @return [io.appwrite.models.Token]
2066+
*/
2067+
@Deprecated(
2068+
message = "This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.",
2069+
replaceWith = ReplaceWith("io.appwrite.services.Account.createEmailVerification")
2070+
)
20322071
suspend fun createVerification(
20332072
url: String,
20342073
): io.appwrite.models.Token {
2035-
val apiPath = "/account/verification"
2074+
val apiPath = "/account/verifications/email"
20362075

20372076
val apiParams = mutableMapOf<String, Any?>(
20382077
"url" to url,
@@ -2062,11 +2101,50 @@ class Account(client: Client) : Service(client) {
20622101
* @param secret Valid verification token.
20632102
* @return [io.appwrite.models.Token]
20642103
*/
2104+
suspend fun updateEmailVerification(
2105+
userId: String,
2106+
secret: String,
2107+
): io.appwrite.models.Token {
2108+
val apiPath = "/account/verifications/email"
2109+
2110+
val apiParams = mutableMapOf<String, Any?>(
2111+
"userId" to userId,
2112+
"secret" to secret,
2113+
)
2114+
val apiHeaders = mutableMapOf<String, String>(
2115+
"content-type" to "application/json",
2116+
)
2117+
val converter: (Any) -> io.appwrite.models.Token = {
2118+
@Suppress("UNCHECKED_CAST")
2119+
io.appwrite.models.Token.from(map = it as Map<String, Any>)
2120+
}
2121+
return client.call(
2122+
"PUT",
2123+
apiPath,
2124+
apiHeaders,
2125+
apiParams,
2126+
responseType = io.appwrite.models.Token::class.java,
2127+
converter,
2128+
)
2129+
}
2130+
2131+
2132+
/**
2133+
* 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.
2134+
*
2135+
* @param userId User ID.
2136+
* @param secret Valid verification token.
2137+
* @return [io.appwrite.models.Token]
2138+
*/
2139+
@Deprecated(
2140+
message = "This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.",
2141+
replaceWith = ReplaceWith("io.appwrite.services.Account.updateEmailVerification")
2142+
)
20652143
suspend fun updateVerification(
20662144
userId: String,
20672145
secret: String,
20682146
): io.appwrite.models.Token {
2069-
val apiPath = "/account/verification"
2147+
val apiPath = "/account/verifications/email"
20702148

20712149
val apiParams = mutableMapOf<String, Any?>(
20722150
"userId" to userId,
@@ -2097,7 +2175,7 @@ class Account(client: Client) : Service(client) {
20972175
*/
20982176
suspend fun createPhoneVerification(
20992177
): io.appwrite.models.Token {
2100-
val apiPath = "/account/verification/phone"
2178+
val apiPath = "/account/verifications/phone"
21012179

21022180
val apiParams = mutableMapOf<String, Any?>(
21032181
)
@@ -2130,7 +2208,7 @@ class Account(client: Client) : Service(client) {
21302208
userId: String,
21312209
secret: String,
21322210
): io.appwrite.models.Token {
2133-
val apiPath = "/account/verification/phone"
2211+
val apiPath = "/account/verifications/phone"
21342212

21352213
val apiParams = mutableMapOf<String, Any?>(
21362214
"userId" to userId,

library/src/main/java/io/appwrite/services/TablesDb.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class TablesDB(client: Client) : Service(client) {
1818
* Get a list of all the user's rows in a given table. You can use the query params to filter your results.
1919
*
2020
* @param databaseId Database ID.
21-
* @param tableId Table ID. You can create a new table using the TableDB service [server integration](https://appwrite.io/docs/server/tablesdbdb#tablesdbCreate).
21+
* @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).
2222
* @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.
2323
* @return [io.appwrite.models.RowList<T>]
2424
*/
@@ -56,7 +56,7 @@ class TablesDB(client: Client) : Service(client) {
5656
* Get a list of all the user's rows in a given table. You can use the query params to filter your results.
5757
*
5858
* @param databaseId Database ID.
59-
* @param tableId Table ID. You can create a new table using the TableDB service [server integration](https://appwrite.io/docs/server/tablesdbdb#tablesdbCreate).
59+
* @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).
6060
* @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.
6161
* @return [io.appwrite.models.RowList<T>]
6262
*/
@@ -74,10 +74,10 @@ class TablesDB(client: Client) : Service(client) {
7474
)
7575

7676
/**
77-
* 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.
77+
* 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.
7878
*
7979
* @param databaseId Database ID.
80-
* @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.
80+
* @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.
8181
* @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.
8282
* @param data Row data as JSON object.
8383
* @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).
@@ -119,10 +119,10 @@ class TablesDB(client: Client) : Service(client) {
119119
}
120120

121121
/**
122-
* 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.
122+
* 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.
123123
*
124124
* @param databaseId Database ID.
125-
* @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.
125+
* @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.
126126
* @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.
127127
* @param data Row data as JSON object.
128128
* @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).
@@ -149,7 +149,7 @@ class TablesDB(client: Client) : Service(client) {
149149
* Get a row by its unique ID. This endpoint response returns a JSON object with the row data.
150150
*
151151
* @param databaseId Database ID.
152-
* @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
152+
* @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).
153153
* @param rowId Row ID.
154154
* @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.
155155
* @return [io.appwrite.models.Row<T>]
@@ -190,7 +190,7 @@ class TablesDB(client: Client) : Service(client) {
190190
* Get a row by its unique ID. This endpoint response returns a JSON object with the row data.
191191
*
192192
* @param databaseId Database ID.
193-
* @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
193+
* @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).
194194
* @param rowId Row ID.
195195
* @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.
196196
* @return [io.appwrite.models.Row<T>]
@@ -211,7 +211,7 @@ class TablesDB(client: Client) : Service(client) {
211211
)
212212

213213
/**
214-
* 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.
214+
* 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.
215215
*
216216
* @param databaseId Database ID.
217217
* @param tableId Table ID.
@@ -256,7 +256,7 @@ class TablesDB(client: Client) : Service(client) {
256256
}
257257

258258
/**
259-
* 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.
259+
* 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.
260260
*
261261
* @param databaseId Database ID.
262262
* @param tableId Table ID.
@@ -358,7 +358,7 @@ class TablesDB(client: Client) : Service(client) {
358358
* Delete a row by its unique ID.
359359
*
360360
* @param databaseId Database ID.
361-
* @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate).
361+
* @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).
362362
* @param rowId Row ID.
363363
* @return [Any]
364364
*/

0 commit comments

Comments
 (0)