@@ -21,7 +21,7 @@ open class Client {
21
21
" x-sdk-name " : " Swift " ,
22
22
" x-sdk-platform " : " server " ,
23
23
" x-sdk-language " : " swift " ,
24
- " x-sdk-version " : " 6.2 .0" ,
24
+ " x-sdk-version " : " 7.0 .0" ,
25
25
" x-appwrite-response-format " : " 1.6.0 "
26
26
]
27
27
@@ -257,6 +257,26 @@ open class Client {
257
257
) ?? " "
258
258
}
259
259
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
+
260
280
///
261
281
/// Make an API call
262
282
///
@@ -392,15 +412,18 @@ open class Client {
392
412
}
393
413
}
394
414
415
+ var data = try await response. body. collect ( upTo: Int . max)
416
+
395
417
switch response. status. code {
396
418
case 0 ..< 400 :
397
419
switch T . self {
398
420
case is Bool . Type :
399
421
return true as! T
422
+ case is String . Type :
423
+ return ( data. readString ( length: data. readableBytes) ?? " " ) as! T
400
424
case is ByteBuffer . Type :
401
- return try await response . body . collect ( upTo : Int . max ) as! T
425
+ return data as! T
402
426
default :
403
- let data = try await response. body. collect ( upTo: Int . max)
404
427
if data. readableBytes == 0 {
405
428
return true as! T
406
429
}
@@ -410,7 +433,6 @@ open class Client {
410
433
}
411
434
default :
412
435
var message = " "
413
- var data = try await response. body. collect ( upTo: Int . max)
414
436
var type = " "
415
437
416
438
do {
@@ -466,7 +488,7 @@ open class Client {
466
488
var offset = 0
467
489
var result = [ String: Any] ( )
468
490
469
- if idParamName != nil && params [ idParamName! ] as! String != " unique() " {
491
+ if idParamName != nil {
470
492
// Make a request to check if a file already exists
471
493
do {
472
494
let map = try await call (
0 commit comments