Skip to content

Commit 235e58d

Browse files
feat: support for 0.14.x
1 parent 46e8b64 commit 235e58d

File tree

16 files changed

+204
-149
lines changed

16 files changed

+204
-149
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
![Maven Central](https://img.shields.io/maven-central/v/io.appwrite/sdk-for-kotlin.svg?color=green&style=flat-square)
44
![License](https://img.shields.io/github/license/appwrite/sdk-for-kotlin.svg?style=flat-square)
5-
![Version](https://img.shields.io/badge/api%20version-0.13.0-blue.svg?style=flat-square)
5+
![Version](https://img.shields.io/badge/api%20version-0.14.0-blue.svg?style=flat-square)
66
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
77
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
88

9-
**This SDK is compatible with Appwrite server version 0.13.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-kotlin/releases).**
9+
**This SDK is compatible with Appwrite server version 0.14.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-kotlin/releases).**
1010

1111
> This is the Kotlin SDK for integrating with Appwrite from your Kotlin server-side code. If you're looking for the Android SDK you should check [appwrite/sdk-for-android](https://github.com/appwrite/sdk-for-android)
1212
@@ -39,7 +39,7 @@ repositories {
3939
Next, add the dependency to your project's `build.gradle(.kts)` file:
4040

4141
```groovy
42-
implementation("io.appwrite:sdk-for-kotlin:0.4.0")
42+
implementation("io.appwrite:sdk-for-kotlin:0.5.0")
4343
```
4444

4545
### Maven
@@ -50,7 +50,7 @@ Add this to your project's `pom.xml` file:
5050
<dependency>
5151
<groupId>io.appwrite</groupId>
5252
<artifactId>sdk-for-kotlin</artifactId>
53-
<version>0.4.0</version>
53+
<version>0.5.0</version>
5454
</dependency>
5555
</dependencies>
5656
```

docs/examples/java/account/delete.md renamed to docs/examples/java/account/update-status.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public void main() {
88
.setJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ..."); // Your secret JSON Web Token
99

1010
Account account = new Account(client);
11-
account.delete(new Continuation<Response>() {
11+
account.updateStatus(new Continuation<Response>() {
1212
@NotNull
1313
@Override
1414
public CoroutineContext getContext() {

docs/examples/java/health/get-queue-usage.md

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import io.appwrite.Client
2+
import io.appwrite.services.Users
3+
4+
public void main() {
5+
Client client = Client(context)
6+
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
7+
.setProject("5df5acd0d48c2") // Your project ID
8+
.setKey("919c2d18fb5d4...a2ae413da83346ad2"); // Your secret API key
9+
10+
Users users = new Users(client);
11+
users.getMemberships(
12+
userId = "[USER_ID]"
13+
new Continuation<Response>() {
14+
@NotNull
15+
@Override
16+
public CoroutineContext getContext() {
17+
return EmptyCoroutineContext.INSTANCE;
18+
}
19+
20+
@Override
21+
public void resumeWith(@NotNull Object o) {
22+
String json = "";
23+
try {
24+
if (o instanceof Result.Failure) {
25+
Result.Failure failure = (Result.Failure) o;
26+
throw failure.exception;
27+
} else {
28+
Response response = (Response) o;
29+
}
30+
} catch (Throwable th) {
31+
Log.e("ERROR", th.toString());
32+
}
33+
}
34+
}
35+
);
36+
}

docs/examples/kotlin/account/delete.md renamed to docs/examples/kotlin/account/update-status.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ suspend fun main() {
88
.setJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token
99

1010
val account = Account(client)
11-
val response = account.delete()
11+
val response = account.updateStatus()
1212
val json = response.body?.string()
1313
}
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import io.appwrite.Client
2-
import io.appwrite.services.Health
2+
import io.appwrite.services.Users
33

44
suspend fun main() {
55
val client = Client(context)
66
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
77
.setProject("5df5acd0d48c2") // Your project ID
88
.setKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
99

10-
val health = Health(client)
11-
val response = health.getQueueUsage()
10+
val users = Users(client)
11+
val response = users.getMemberships(
12+
userId = "[USER_ID]"
13+
)
1214
val json = response.body?.string()
1315
}

src/main/kotlin/io/appwrite/models/Execution.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ data class Execution(
5656
val statusCode: Long,
5757

5858
/**
59-
* The script stdout output string. Logs the last 4,000 characters of the execution stdout output.
59+
* The script response output string. Logs the last 4,000 characters of the execution response output.
6060
*
6161
*/
62-
@SerializedName("stdout")
63-
val stdout: String,
62+
@SerializedName("response")
63+
val response: String,
6464

6565
/**
6666
* The script stderr output string. Logs the last 4,000 characters of the execution stderr output
@@ -86,7 +86,7 @@ data class Execution(
8686
trigger = map["trigger"] as String,
8787
status = map["status"] as String,
8888
statusCode = (map["statusCode"] as Number).toLong(),
89-
stdout = map["stdout"] as String,
89+
response = map["response"] as String,
9090
stderr = map["stderr"] as String,
9191
time = (map["time"] as Number).toDouble()
9292
)
@@ -100,7 +100,7 @@ data class Execution(
100100
"trigger" to trigger as Any,
101101
"status" to status as Any,
102102
"statusCode" to statusCode as Any,
103-
"stdout" to stdout as Any,
103+
"response" to response as Any,
104104
"stderr" to stderr as Any,
105105
"time" to time as Any
106106
)

src/main/kotlin/io/appwrite/models/Membership.kt

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,32 @@ data class Membership(
2121
val userId: String,
2222

2323
/**
24-
* Team ID.
24+
* User name.
2525
*
2626
*/
27-
@SerializedName("teamId")
28-
val teamId: String,
27+
@SerializedName("userName")
28+
val userName: String,
2929

3030
/**
31-
* User name.
31+
* User email address.
3232
*
3333
*/
34-
@SerializedName("name")
35-
val name: String,
34+
@SerializedName("userEmail")
35+
val userEmail: String,
3636

3737
/**
38-
* User email address.
38+
* Team ID.
39+
*
40+
*/
41+
@SerializedName("teamId")
42+
val teamId: String,
43+
44+
/**
45+
* Team name.
3946
*
4047
*/
41-
@SerializedName("email")
42-
val email: String,
48+
@SerializedName("teamName")
49+
val teamName: String,
4350

4451
/**
4552
* Date, the user has been invited to join the team in Unix timestamp.
@@ -74,9 +81,10 @@ data class Membership(
7481
fun from(map: Map<String, Any>) = Membership(
7582
id = map["\$id"] as String,
7683
userId = map["userId"] as String,
84+
userName = map["userName"] as String,
85+
userEmail = map["userEmail"] as String,
7786
teamId = map["teamId"] as String,
78-
name = map["name"] as String,
79-
email = map["email"] as String,
87+
teamName = map["teamName"] as String,
8088
invited = (map["invited"] as Number).toLong(),
8189
joined = (map["joined"] as Number).toLong(),
8290
confirm = map["confirm"] as Boolean,
@@ -87,9 +95,10 @@ data class Membership(
8795
fun toMap(): Map<String, Any> = mapOf(
8896
"\$id" to id as Any,
8997
"userId" to userId as Any,
98+
"userName" to userName as Any,
99+
"userEmail" to userEmail as Any,
90100
"teamId" to teamId as Any,
91-
"name" to name as Any,
92-
"email" to email as Any,
101+
"teamName" to teamName as Any,
93102
"invited" to invited as Any,
94103
"joined" to joined as Any,
95104
"confirm" to confirm as Any,

src/main/kotlin/io/appwrite/services/Account.kt

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -37,35 +37,6 @@ class Account(client: Client) : Service(client) {
3737
)
3838
}
3939

40-
/**
41-
* Delete Account
42-
*
43-
* Delete a currently logged in user account. Behind the scene, the user
44-
* record is not deleted but permanently blocked from any access. This is done
45-
* to avoid deleted accounts being overtaken by new users with the same email
46-
* address. Any user-related resources like documents or storage files should
47-
* be deleted separately.
48-
*
49-
* @return [Any]
50-
*/
51-
@JvmOverloads
52-
@Throws(AppwriteException::class)
53-
suspend fun delete(): Any {
54-
val path = "/account"
55-
val params = mutableMapOf<String, Any?>(
56-
)
57-
val headers = mutableMapOf(
58-
"content-type" to "application/json"
59-
)
60-
return client.call(
61-
"DELETE",
62-
path,
63-
headers,
64-
params,
65-
responseType = Any::class.java,
66-
)
67-
}
68-
6940
/**
7041
* Update Account Email
7142
*
@@ -184,7 +155,7 @@ class Account(client: Client) : Service(client) {
184155
*
185156
* Update currently logged in user password. For validation, user is required
186157
* to pass in the new password, and the old password. For users created with
187-
* OAuth and Team Invites, oldPassword is optional.
158+
* OAuth, Team Invites and Magic URL, oldPassword is optional.
188159
*
189160
* @param password New user password. Must be at least 8 chars.
190161
* @param oldPassword Current user password. Must be at least 8 chars.
@@ -466,6 +437,10 @@ class Account(client: Client) : Service(client) {
466437
/**
467438
* Update Session (Refresh Tokens)
468439
*
440+
* Access tokens have limited lifespan and expire to mitigate security risks.
441+
* If session was created using an OAuth provider, this route can be used to
442+
* "refresh" the access token.
443+
*
469444
* @param sessionId Session ID. Use the string &#039;current&#039; to update the current device session.
470445
* @return [io.appwrite.models.Session]
471446
*/
@@ -524,6 +499,37 @@ class Account(client: Client) : Service(client) {
524499
)
525500
}
526501

502+
/**
503+
* Update Account Status
504+
*
505+
* Block the currently logged in user account. Behind the scene, the user
506+
* record is not deleted but permanently blocked from any access. To
507+
* completely delete a user, use the Users API instead.
508+
*
509+
* @return [io.appwrite.models.User]
510+
*/
511+
@JvmOverloads
512+
@Throws(AppwriteException::class)
513+
suspend fun updateStatus(): io.appwrite.models.User {
514+
val path = "/account/status"
515+
val params = mutableMapOf<String, Any?>(
516+
)
517+
val headers = mutableMapOf(
518+
"content-type" to "application/json"
519+
)
520+
val converter: (Map<String, Any>) -> io.appwrite.models.User = {
521+
io.appwrite.models.User.from(map = it)
522+
}
523+
return client.call(
524+
"PATCH",
525+
path,
526+
headers,
527+
params,
528+
responseType = io.appwrite.models.User::class.java,
529+
converter,
530+
)
531+
}
532+
527533
/**
528534
* Create Email Verification
529535
*

0 commit comments

Comments
 (0)