@@ -21,7 +21,7 @@ open class Client {
2121 " x-sdk-name " : " Swift " ,
2222 " x-sdk-platform " : " server " ,
2323 " x-sdk-language " : " swift " ,
24- " x-sdk-version " : " 6.2 .0" ,
24+ " x-sdk-version " : " 7.0 .0" ,
2525 " x-appwrite-response-format " : " 1.6.0 "
2626 ]
2727
@@ -257,6 +257,26 @@ open class Client {
257257 ) ?? " "
258258 }
259259
260+ ///
261+ /// Sends a "ping" request to Appwrite to verify connectivity.
262+ ///
263+ /// @return String
264+ /// @throws Exception
265+ ///
266+ open func ping( ) async throws -> String {
267+ let apiPath : String = " /ping "
268+
269+ let apiHeaders : [ String : String ] = [
270+ " content-type " : " application/json "
271+ ]
272+
273+ return try await call (
274+ method: " GET " ,
275+ path: apiPath,
276+ headers: apiHeaders
277+ )
278+ }
279+
260280 ///
261281 /// Make an API call
262282 ///
@@ -392,15 +412,18 @@ open class Client {
392412 }
393413 }
394414
415+ var data = try await response. body. collect ( upTo: Int . max)
416+
395417 switch response. status. code {
396418 case 0 ..< 400 :
397419 switch T . self {
398420 case is Bool . Type :
399421 return true as! T
422+ case is String . Type :
423+ return ( data. readString ( length: data. readableBytes) ?? " " ) as! T
400424 case is ByteBuffer . Type :
401- return try await response . body . collect ( upTo : Int . max ) as! T
425+ return data as! T
402426 default :
403- let data = try await response. body. collect ( upTo: Int . max)
404427 if data. readableBytes == 0 {
405428 return true as! T
406429 }
@@ -410,7 +433,6 @@ open class Client {
410433 }
411434 default :
412435 var message = " "
413- var data = try await response. body. collect ( upTo: Int . max)
414436 var type = " "
415437
416438 do {
@@ -466,7 +488,7 @@ open class Client {
466488 var offset = 0
467489 var result = [ String: Any] ( )
468490
469- if idParamName != nil && params [ idParamName! ] as! String != " unique() " {
491+ if idParamName != nil {
470492 // Make a request to check if a file already exists
471493 do {
472494 let map = try await call (
0 commit comments