Skip to content

Commit 159d02d

Browse files
authored
Merge pull request #46 from appwrite/dev
fix: pong response & chunked upload
2 parents feef4c8 + b412380 commit 159d02d

File tree

8 files changed

+60
-51
lines changed

8 files changed

+60
-51
lines changed

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2024 Appwrite (https://appwrite.io) and individual contributors.
1+
Copyright (c) 2025 Appwrite (https://appwrite.io) and individual contributors.
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -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:6.2.0")
42+
implementation("io.appwrite:sdk-for-kotlin:7.0.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>6.2.0</version>
53+
<version>7.0.0</version>
5454
</dependency>
5555
</dependencies>
5656
```

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

+41-14
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ class Client @JvmOverloads constructor(
5757
init {
5858
headers = mutableMapOf(
5959
"content-type" to "application/json",
60-
"user-agent" to "AppwriteKotlinSDK/6.2.0 ${System.getProperty("http.agent")}",
60+
"user-agent" to "AppwriteKotlinSDK/7.0.0 ${System.getProperty("http.agent")}",
6161
"x-sdk-name" to "Kotlin",
6262
"x-sdk-platform" to "server",
6363
"x-sdk-language" to "kotlin",
64-
"x-sdk-version" to "6.2.0",
64+
"x-sdk-version" to "7.0.0",
6565
"x-appwrite-response-format" to "1.6.0",
6666
)
6767

@@ -235,9 +235,28 @@ class Client @JvmOverloads constructor(
235235
return this
236236
}
237237

238+
/**
239+
* Sends a "ping" request to Appwrite to verify connectivity.
240+
*
241+
* @return String
242+
*/
243+
suspend fun ping(): String {
244+
val apiPath = "/ping"
245+
val apiParams = mutableMapOf<String, Any?>()
246+
val apiHeaders = mutableMapOf("content-type" to "application/json")
247+
248+
return call(
249+
"GET",
250+
apiPath,
251+
apiHeaders,
252+
apiParams,
253+
responseType = String::class.java
254+
)
255+
}
256+
238257
/**
239258
* Prepare the HTTP request
240-
*
259+
*
241260
* @param method
242261
* @param path
243262
* @param headers
@@ -332,7 +351,7 @@ class Client @JvmOverloads constructor(
332351
* @param headers
333352
* @param params
334353
*
335-
* @return [T]
354+
* @return [T]
336355
*/
337356
@Throws(AppwriteException::class)
338357
suspend fun <T> call(
@@ -355,7 +374,7 @@ class Client @JvmOverloads constructor(
355374
* @param headers
356375
* @param params
357376
*
358-
* @return [T]
377+
* @return [T]
359378
*/
360379
@Throws(AppwriteException::class)
361380
suspend fun redirect(
@@ -427,7 +446,7 @@ class Client @JvmOverloads constructor(
427446
var offset = 0L
428447
var result: Map<*, *>? = null
429448

430-
if (idParamName?.isNotEmpty() == true && params[idParamName] != "unique()") {
449+
if (idParamName?.isNotEmpty() == true) {
431450
// Make a request to check if a file already exists
432451
val current = call(
433452
method = "GET",
@@ -494,7 +513,7 @@ class Client @JvmOverloads constructor(
494513
return converter(result as Map<String, Any>)
495514
}
496515

497-
/**
516+
/**
498517
* Await Redirect
499518
*
500519
* @param request
@@ -521,14 +540,14 @@ class Client @JvmOverloads constructor(
521540
.charStream()
522541
.buffered()
523542
.use(BufferedReader::readText)
524-
543+
525544
val error = if (response.headers["content-type"]?.contains("application/json") == true) {
526545
val map = body.fromJson<Map<String, Any>>()
527546

528547
AppwriteException(
529-
map["message"] as? String ?: "",
548+
map["message"] as? String ?: "",
530549
(map["code"] as Number).toInt(),
531-
map["type"] as? String ?: "",
550+
map["type"] as? String ?: "",
532551
body
533552
)
534553
} else {
@@ -572,14 +591,14 @@ class Client @JvmOverloads constructor(
572591
.charStream()
573592
.buffered()
574593
.use(BufferedReader::readText)
575-
594+
576595
val error = if (response.headers["content-type"]?.contains("application/json") == true) {
577596
val map = body.fromJson<Map<String, Any>>()
578597

579598
AppwriteException(
580-
map["message"] as? String ?: "",
599+
map["message"] as? String ?: "",
581600
(map["code"] as Number).toInt(),
582-
map["type"] as? String ?: "",
601+
map["type"] as? String ?: "",
583602
body
584603
)
585604
} else {
@@ -601,6 +620,14 @@ class Client @JvmOverloads constructor(
601620
it.resume(true as T)
602621
return
603622
}
623+
responseType == String::class.java -> {
624+
val body = response.body!!
625+
.charStream()
626+
.buffered()
627+
.use(BufferedReader::readText)
628+
it.resume(body as T)
629+
return
630+
}
604631
responseType == ByteArray::class.java -> {
605632
it.resume(response.body!!
606633
.byteStream()
@@ -629,4 +656,4 @@ class Client @JvmOverloads constructor(
629656
}
630657
})
631658
}
632-
}
659+
}

src/main/kotlin/io/appwrite/enums/ImageFormat.kt

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ enum class ImageFormat(val value: String) {
1313
PNG("png"),
1414
@SerializedName("webp")
1515
WEBP("webp"),
16+
@SerializedName("heic")
17+
HEIC("heic"),
1618
@SerializedName("avif")
1719
AVIF("avif");
1820

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

+7-3
Original file line numberDiff line numberDiff line change
@@ -518,13 +518,13 @@ class Account(client: Client) : Service(client) {
518518
*
519519
* @param challengeId ID of the challenge.
520520
* @param otp Valid verification token.
521-
* @return [Any]
521+
* @return [io.appwrite.models.Session]
522522
*/
523523
@Throws(AppwriteException::class)
524524
suspend fun updateMfaChallenge(
525525
challengeId: String,
526526
otp: String,
527-
): Any {
527+
): io.appwrite.models.Session {
528528
val apiPath = "/account/mfa/challenge"
529529

530530
val apiParams = mutableMapOf<String, Any?>(
@@ -534,12 +534,16 @@ class Account(client: Client) : Service(client) {
534534
val apiHeaders = mutableMapOf(
535535
"content-type" to "application/json",
536536
)
537+
val converter: (Any) -> io.appwrite.models.Session = {
538+
io.appwrite.models.Session.from(map = it as Map<String, Any>)
539+
}
537540
return client.call(
538541
"PUT",
539542
apiPath,
540543
apiHeaders,
541544
apiParams,
542-
responseType = Any::class.java,
545+
responseType = io.appwrite.models.Session::class.java,
546+
converter,
543547
)
544548
}
545549

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ class Functions(client: Client) : Service(client) {
554554
/**
555555
* Rebuild deployment
556556
*
557-
*
557+
* Create a new build for an existing function deployment. This endpoint allows you to rebuild a deployment with the updated function configuration, including its entrypoint and build commands if they have been modified The build process will be queued and executed asynchronously. The original deployment&#039;s code will be preserved and used for the new build.
558558
*
559559
* @param functionId Function ID.
560560
* @param deploymentId Deployment ID.
@@ -590,7 +590,7 @@ class Functions(client: Client) : Service(client) {
590590
/**
591591
* Cancel deployment
592592
*
593-
*
593+
* Cancel an ongoing function deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn&#039;t started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status &#039;ready&#039;) or failed. The response includes the final build status and details.
594594
*
595595
* @param functionId Function ID.
596596
* @param deploymentId Deployment ID.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ class Messaging(client: Client) : Service(client) {
415415
/**
416416
* Update SMS
417417
*
418-
* Update an email message by its unique ID.
418+
* Update an SMS message by its unique ID.
419419
*
420420
* @param messageId Message ID.
421421
* @param topics List of Topic IDs.

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

+4-28
Original file line numberDiff line numberDiff line change
@@ -1121,14 +1121,13 @@ class Users(client: Client) : Service(client) {
11211121
*
11221122
* @param userId User ID.
11231123
* @param type Type of authenticator.
1124-
* @return [io.appwrite.models.User<T>]
1124+
* @return [Any]
11251125
*/
11261126
@Throws(AppwriteException::class)
1127-
suspend fun <T> deleteMfaAuthenticator(
1127+
suspend fun deleteMfaAuthenticator(
11281128
userId: String,
11291129
type: io.appwrite.enums.AuthenticatorType,
1130-
nestedType: Class<T>,
1131-
): io.appwrite.models.User<T> {
1130+
): Any {
11321131
val apiPath = "/users/{userId}/mfa/authenticators/{type}"
11331132
.replace("{userId}", userId)
11341133
.replace("{type}", type.value)
@@ -1138,38 +1137,15 @@ class Users(client: Client) : Service(client) {
11381137
val apiHeaders = mutableMapOf(
11391138
"content-type" to "application/json",
11401139
)
1141-
val converter: (Any) -> io.appwrite.models.User<T> = {
1142-
io.appwrite.models.User.from(map = it as Map<String, Any>, nestedType)
1143-
}
11441140
return client.call(
11451141
"DELETE",
11461142
apiPath,
11471143
apiHeaders,
11481144
apiParams,
1149-
responseType = classOf(),
1150-
converter,
1145+
responseType = Any::class.java,
11511146
)
11521147
}
11531148

1154-
/**
1155-
* Delete authenticator
1156-
*
1157-
* Delete an authenticator app.
1158-
*
1159-
* @param userId User ID.
1160-
* @param type Type of authenticator.
1161-
* @return [io.appwrite.models.User<T>]
1162-
*/
1163-
@Throws(AppwriteException::class)
1164-
suspend fun deleteMfaAuthenticator(
1165-
userId: String,
1166-
type: io.appwrite.enums.AuthenticatorType,
1167-
): io.appwrite.models.User<Map<String, Any>> = deleteMfaAuthenticator(
1168-
userId,
1169-
type,
1170-
nestedType = classOf(),
1171-
)
1172-
11731149
/**
11741150
* List factors
11751151
*

0 commit comments

Comments
 (0)