Skip to content

Commit 1d4bda5

Browse files
Merge pull request #5 from appwrite/dev
feat: Bug fixes and version bump
2 parents fdc6913 + 6eeb915 commit 1d4bda5

File tree

10 files changed

+104
-12
lines changed

10 files changed

+104
-12
lines changed

README.md

+4-4
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.8.0-blue.svg?style=flat-square)
5+
![Version](https://img.shields.io/badge/api%20version-0.9.0-blue.svg?style=flat-square)
66
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite_io?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite_io)
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.8.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.9.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-kotlin/releases).**
1010

1111
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 Kotlin 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)
1212

@@ -37,7 +37,7 @@ repositories {
3737
Next, add the dependency to your project's `build.gradle(.kts)` file:
3838

3939
```groovy
40-
implementation("io.appwrite:sdk-for-kotlin:0.0.0")
40+
implementation("io.appwrite:sdk-for-kotlin:0.0.1")
4141
```
4242

4343
### Maven
@@ -48,7 +48,7 @@ Add this to your project's `pom.xml` file:
4848
<dependency>
4949
<groupId>io.appwrite</groupId>
5050
<artifactId>sdk-for-kotlin</artifactId>
51-
<version>0.0.0</version>
51+
<version>0.0.1</version>
5252
</dependency>
5353
</dependencies>
5454
```

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins {
77
ext {
88
PUBLISH_GROUP_ID = 'io.appwrite'
99
PUBLISH_ARTIFACT_ID = 'sdk-for-kotlin'
10-
PUBLISH_VERSION = '0.0.0'
10+
PUBLISH_VERSION = '0.0.1'
1111
POM_URL = 'https://github.com/appwrite/sdk-for-kotlin'
1212
POM_SCM_URL = 'https://github.com/appwrite/sdk-for-kotlin'
1313
POM_ISSUE_URL = 'https://github.com/appwrite/sdk-for-kotlin/issues'

docs/examples/account/get-session.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import io.appwrite.Client
2+
import io.appwrite.services.Account
3+
4+
suspend fun main() {
5+
val client = Client(context)
6+
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
7+
.setProject("5df5acd0d48c2") // Your project ID
8+
.setJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...") // Your secret JSON Web Token
9+
10+
val account = Account(client)
11+
val response = account.getSession(
12+
sessionId = "[SESSION_ID]"
13+
)
14+
val json = response.body?.string()
15+
}

docs/examples/functions/create.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ suspend fun main() {
1111
val response = functions.create(
1212
name = "[NAME]",
1313
execute = listOf(),
14-
env = "dotnet-3.1",
14+
runtime = "java-11.0",
1515
)
1616
val json = response.body?.string()
1717
}
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import io.appwrite.Client
2+
import io.appwrite.services.Users
3+
4+
suspend fun main() {
5+
val 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+
val users = Users(client)
11+
val response = users.updateVerification(
12+
userId = "[USER_ID]",
13+
emailVerification = false
14+
)
15+
val json = response.body?.string()
16+
}

src/main/kotlin/io/appwrite/Client.kt

+9-3
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class Client @JvmOverloads constructor(
4747
init {
4848
headers = mutableMapOf(
4949
"content-type" to "application/json",
50-
"x-sdk-version" to "appwrite:kotlin:0.0.0",
51-
"x-appwrite-response-format" to "0.8.0"
50+
"x-sdk-version" to "appwrite:kotlin:0.0.1",
51+
"x-appwrite-response-format" to "0.9.0"
5252
)
5353
config = mutableMapOf()
5454

@@ -219,7 +219,13 @@ class Client @JvmOverloads constructor(
219219
return@forEach
220220
}
221221
is List<*> -> {
222-
httpBuilder.addQueryParameter(it.key + "[]", it.value.toString())
222+
val list = it.value as List<*>
223+
for (index in list.indices) {
224+
httpBuilder.addQueryParameter(
225+
"${it.key}[]",
226+
list[index].toString()
227+
)
228+
}
223229
}
224230
else -> {
225231
httpBuilder.addQueryParameter(it.key, it.value.toString())

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

+25
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,31 @@ class Account(private val client: Client) : BaseService(client) {
332332
return client.call("DELETE", path, headers, params)
333333
}
334334

335+
/**
336+
* Get Session By ID
337+
*
338+
* Use this endpoint to get a logged in user's session using a Session ID.
339+
* Inputting 'current' will return the current session being used.
340+
*
341+
* @param sessionId
342+
* @return [Response]
343+
*/
344+
@JvmOverloads
345+
@Throws(AppwriteException::class)
346+
suspend fun getSession(
347+
sessionId: String
348+
): Response {
349+
val path = "/account/sessions/{sessionId}".replace("{sessionId}", sessionId)
350+
val params = mapOf<String, Any?>(
351+
)
352+
353+
val headers = mapOf(
354+
"content-type" to "application/json"
355+
)
356+
357+
return client.call("GET", path, headers, params)
358+
}
359+
335360
/**
336361
* Delete Account Session
337362
*

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Functions(private val client: Client) : BaseService(client) {
5252
*
5353
* @param name
5454
* @param execute
55-
* @param env
55+
* @param runtime
5656
* @param vars
5757
* @param events
5858
* @param schedule
@@ -64,7 +64,7 @@ class Functions(private val client: Client) : BaseService(client) {
6464
suspend fun create(
6565
name: String,
6666
execute: List<Any>,
67-
env: String,
67+
runtime: String,
6868
vars: Any? = null,
6969
events: List<Any>? = null,
7070
schedule: String? = null,
@@ -74,7 +74,7 @@ class Functions(private val client: Client) : BaseService(client) {
7474
val params = mapOf<String, Any?>(
7575
"name" to name,
7676
"execute" to execute,
77-
"env" to env,
77+
"runtime" to runtime,
7878
"vars" to vars,
7979
"events" to events,
8080
"schedule" to schedule,

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

+3
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ class Storage(private val client: Client) : BaseService(client) {
195195
* @param fileId
196196
* @param width
197197
* @param height
198+
* @param gravity
198199
* @param quality
199200
* @param borderWidth
200201
* @param borderColor
@@ -211,6 +212,7 @@ class Storage(private val client: Client) : BaseService(client) {
211212
fileId: String,
212213
width: Int? = null,
213214
height: Int? = null,
215+
gravity: String? = null,
214216
quality: Int? = null,
215217
borderWidth: Int? = null,
216218
borderColor: String? = null,
@@ -224,6 +226,7 @@ class Storage(private val client: Client) : BaseService(client) {
224226
val params = mapOf<String, Any?>(
225227
"width" to width,
226228
"height" to height,
229+
"gravity" to gravity,
227230
"quality" to quality,
228231
"borderWidth" to borderWidth,
229232
"borderColor" to borderColor,

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

+27
Original file line numberDiff line numberDiff line change
@@ -299,4 +299,31 @@ class Users(private val client: Client) : BaseService(client) {
299299
return client.call("PATCH", path, headers, params)
300300
}
301301

302+
/**
303+
* Update Email Verification
304+
*
305+
* Update the user email verification status by its unique ID.
306+
*
307+
* @param userId
308+
* @param emailVerification
309+
* @return [Response]
310+
*/
311+
@JvmOverloads
312+
@Throws(AppwriteException::class)
313+
suspend fun updateVerification(
314+
userId: String,
315+
emailVerification: Boolean
316+
): Response {
317+
val path = "/users/{userId}/verification".replace("{userId}", userId)
318+
val params = mapOf<String, Any?>(
319+
"emailVerification" to emailVerification
320+
)
321+
322+
val headers = mapOf(
323+
"content-type" to "application/json"
324+
)
325+
326+
return client.call("PATCH", path, headers, params)
327+
}
328+
302329
}

0 commit comments

Comments
 (0)